From 344ae127a9e7714158c918cd50af16121407aaea Mon Sep 17 00:00:00 2001 From: QuImUfu Date: Thu, 1 Apr 2021 21:59:22 +0200 Subject: [PATCH] Update for 1.16.5 --- build.gradle | 23 ++- gradle.properties | 10 +- .../simple_creator/BlockResourceLoader.java | 162 ++++++++++++------ .../GenericManualResourceLoader.java | 25 ++- .../simple_creator/ItemResourceLoader.java | 4 +- .../simple_creator/MaterialSettingsPojo.java | 2 +- .../simple_creator/SimpleCreatorConfig.java | 4 +- .../simple_creator/SimpleCreatorMod.java | 5 +- .../SimpleCreatorModMenuIntegration.java | 11 +- 9 files changed, 159 insertions(+), 87 deletions(-) diff --git a/build.gradle b/build.gradle index 139e089..10a7f1f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.2.6-SNAPSHOT' + id 'fabric-loom' version '0.6-SNAPSHOT' id 'maven-publish' } @@ -13,6 +13,11 @@ group = project.maven_group minecraft { } +repositories { + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/releases/" } +} + dependencies { //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" @@ -20,12 +25,16 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" implementation 'com.google.code.findbugs:jsr305:3.0.2' modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" - - modCompile "me.sargunvohra.mcmods:autoconfig1u:2.0" - include "me.sargunvohra.mcmods:autoconfig1u:2.0" - modApi "me.shedaniel.cloth:config-2:2.13.1" - include "me.shedaniel.cloth:config-2:2.13.1" - modImplementation "io.github.prospector:modmenu:1.10.0+build.28" + + modApi("me.shedaniel.cloth:cloth-config-fabric:4.11.18") { + exclude(group: "net.fabricmc.fabric-api") + } + modApi("com.terraformersmc:modmenu:1.16.8") + //modCompile "me.sargunvohra.mcmods:autoconfig1u:2.0" + //include "me.sargunvohra.mcmods:autoconfig1u:2.0" + //modApi "me.shedaniel.cloth:config-2:2.13.1" + //include "me.shedaniel.cloth:config-2:2.13.1" + //modImplementation "io.github.prospector:modmenu:1.10.0+build.28" } processResources { diff --git a/gradle.properties b/gradle.properties index 1614403..81f98c2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,14 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties -minecraft_version = 1.15.2 -yarn_mappings = 1.15.2+build.15 -loader_version = 0.8.2+build.194 +minecraft_version = 1.16.5 +yarn_mappings = 1.16.5+build.6 +loader_version = 0.11.3 #Mod properties -mod_version = 0.8.0 +mod_version = 0.9.0 maven_group = quimufu.simple_creator archives_base_name = simple_creator #Dependencies -fabric_api_version = 0.5.12+build.296-1.15 +fabric_api_version = 0.32.5+1.16 diff --git a/src/main/java/quimufu/simple_creator/BlockResourceLoader.java b/src/main/java/quimufu/simple_creator/BlockResourceLoader.java index 795fc82..fbe523b 100644 --- a/src/main/java/quimufu/simple_creator/BlockResourceLoader.java +++ b/src/main/java/quimufu/simple_creator/BlockResourceLoader.java @@ -4,6 +4,9 @@ import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; +import net.fabricmc.fabric.mixin.object.builder.AbstractBlockSettingsAccessor; import net.minecraft.block.*; import net.minecraft.block.piston.PistonBehavior; import net.minecraft.item.BlockItem; @@ -16,7 +19,6 @@ import net.minecraft.util.Pair; import net.minecraft.util.registry.Registry; import org.apache.logging.log4j.Level; -import java.lang.reflect.Field; import java.util.Map; import static quimufu.simple_creator.SimpleCreatorMod.log; @@ -58,7 +60,7 @@ public class BlockResourceLoader extends GenericManualResourceLoader(resB, resI); } private Material getSettings(MaterialSettingsPojo mspj) { return new Material( - MaterialColor.PINK, + getMaterialColor(mspj.materialColor), mspj.liquid, mspj.solid, mspj.blocksMovement, mspj.blocksLight, mspj.breakByHand, mspj.burnable, - mspj.replaceable, getPistonBehavior(mspj.pistonBehavior)); } @@ -123,7 +119,8 @@ public class BlockResourceLoader extends GenericManualResourceLoader material.getColor()); + bs.setCollidable(bspj.collidable); + fabricBlockSettings.sounds(getSoundGroup(bspj.soundGroup)); + bs.setLuminanceFunction(ignored -> bspj.lightLevel); + bs.setResistance(bspj.explosionResistance); + bs.setHardness(bspj.hardness); + fabricBlockSettings.slipperiness(bspj.slipperiness); + fabricBlockSettings.velocityMultiplier(bspj.slowDownMultiplier); + fabricBlockSettings.jumpVelocityMultiplier(bspj.jumpVelocityMultiplier); + bs.setLootTableId(getDropTableId(bspj.dropTableId)); + bs.setOpaque(bspj.opaque); + return fabricBlockSettings; } private Identifier getDropTableId(String s) { @@ -285,6 +281,8 @@ public class BlockResourceLoader extends GenericManualResourceLoader { @@ -50,11 +52,19 @@ public abstract class GenericManualResourceLoader { public void load() { config = AutoConfig.getConfigHolder(SimpleCreatorConfig.class).getConfig(); - ResourcePackManager resourcePackManager = new ResourcePackManager<>(ResourcePackProfile::new); - resourcePackManager.registerProvider(new VanillaDataPackProvider()); - resourcePackManager.registerProvider(new FileResourcePackProvider(new File("./datapacks"))); - if (config.enableTestThings) - resourcePackManager.registerProvider(new ModResourcePackCreator(ResourceType.SERVER_DATA)); + ResourcePackManager resourcePackManager; + if (!config.enableTestThings) { + resourcePackManager = + new ResourcePackManager(ResourcePackProfile::new, + new VanillaDataPackProvider(), + new FileResourcePackProvider(new File("./datapacks"), method_29486("pack.source.global"))); + } else { + resourcePackManager = + new ResourcePackManager(ResourcePackProfile::new, + new VanillaDataPackProvider(), + new FileResourcePackProvider(new File("./datapacks"), method_29486("pack.source.global")), + new ModResourcePackCreator(ResourceType.SERVER_DATA)); + } resourcePackManager.scanPacks(); List ep = Lists.newArrayList(resourcePackManager.getEnabledProfiles()); for (ResourcePackProfile rpp : resourcePackManager.getProfiles()) { @@ -62,8 +72,7 @@ public abstract class GenericManualResourceLoader { rpp.getInitialPosition().insert(ep, rpp, resourcePackProfile -> resourcePackProfile, false); } } - resourcePackManager.setEnabledProfiles(ep); - + resourcePackManager.setEnabledProfiles(ep.stream().map(ResourcePackProfile::getName).collect(Collectors.toList())); ArrayList> itemJsonList = new ArrayList<>(); HashMap itemJsonMap = Maps.newHashMap(); diff --git a/src/main/java/quimufu/simple_creator/ItemResourceLoader.java b/src/main/java/quimufu/simple_creator/ItemResourceLoader.java index 447b547..200ae71 100644 --- a/src/main/java/quimufu/simple_creator/ItemResourceLoader.java +++ b/src/main/java/quimufu/simple_creator/ItemResourceLoader.java @@ -136,12 +136,12 @@ public class ItemResourceLoader extends GenericManualResourceLoader { public static ItemGroup findGroup(String filter) { for (ItemGroup g : ItemGroup.GROUPS) { - if (g.getName().toLowerCase().equals(filter.toLowerCase())) { + if (g.getName().equalsIgnoreCase(filter)) { return g; } } log(Level.WARN, "Item Group " + filter + " not found, using misc"); - log(Level.INFO, "Valid groups:" + Arrays.stream(ItemGroup.GROUPS).map(ItemGroup::getId)); + log(Level.INFO, "Valid groups:" + Arrays.stream(ItemGroup.GROUPS).map(ItemGroup::getName)); return ItemGroup.MISC; } diff --git a/src/main/java/quimufu/simple_creator/MaterialSettingsPojo.java b/src/main/java/quimufu/simple_creator/MaterialSettingsPojo.java index 5d07547..ca9a55f 100644 --- a/src/main/java/quimufu/simple_creator/MaterialSettingsPojo.java +++ b/src/main/java/quimufu/simple_creator/MaterialSettingsPojo.java @@ -4,12 +4,12 @@ import net.minecraft.block.MaterialColor; import net.minecraft.block.piston.PistonBehavior; public class MaterialSettingsPojo { + String materialColor = "PINK"; String pistonBehavior = "normal"; boolean blocksMovement = true; boolean burnable = false; boolean breakByHand = true; boolean liquid = false; - boolean replaceable = false; boolean solid = true; boolean blocksLight = true; } diff --git a/src/main/java/quimufu/simple_creator/SimpleCreatorConfig.java b/src/main/java/quimufu/simple_creator/SimpleCreatorConfig.java index 1fc79c5..1460eef 100644 --- a/src/main/java/quimufu/simple_creator/SimpleCreatorConfig.java +++ b/src/main/java/quimufu/simple_creator/SimpleCreatorConfig.java @@ -1,7 +1,7 @@ package quimufu.simple_creator; -import me.sargunvohra.mcmods.autoconfig1u.ConfigData; -import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; +import me.shedaniel.autoconfig.ConfigData; +import me.shedaniel.autoconfig.annotation.Config; @Config(name = "simple_creator") public class SimpleCreatorConfig implements ConfigData { diff --git a/src/main/java/quimufu/simple_creator/SimpleCreatorMod.java b/src/main/java/quimufu/simple_creator/SimpleCreatorMod.java index dce5ddd..b4042c6 100644 --- a/src/main/java/quimufu/simple_creator/SimpleCreatorMod.java +++ b/src/main/java/quimufu/simple_creator/SimpleCreatorMod.java @@ -1,8 +1,7 @@ package quimufu.simple_creator; -import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; -import me.sargunvohra.mcmods.autoconfig1u.ConfigHolder; -import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer; +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; import net.fabricmc.api.ModInitializer; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/quimufu/simple_creator/SimpleCreatorModMenuIntegration.java b/src/main/java/quimufu/simple_creator/SimpleCreatorModMenuIntegration.java index f4069e8..8c7e993 100644 --- a/src/main/java/quimufu/simple_creator/SimpleCreatorModMenuIntegration.java +++ b/src/main/java/quimufu/simple_creator/SimpleCreatorModMenuIntegration.java @@ -1,15 +1,12 @@ package quimufu.simple_creator; -import io.github.prospector.modmenu.api.ConfigScreenFactory; -import io.github.prospector.modmenu.api.ModMenuApi; -import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import me.shedaniel.autoconfig.AutoConfig; import net.minecraft.client.gui.screen.Screen; public class SimpleCreatorModMenuIntegration implements ModMenuApi { - @Override - public String getModId() { - return SimpleCreatorMod.MOD_ID; - } @Override public ConfigScreenFactory getModConfigScreenFactory() {