diff --git a/changelog.md b/changelog.md index 8f7eeb6..c9e6849 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog +## 1.2.1 +* Now requires InsaneLib 1.5.1 + ## 1.2.0 * Added Block Transformation. Liquids flowing near blocks can now be changed. The example data pack contains lava flowing near/onto Sand that's near Magma Blocks to transform into Glass. diff --git a/gradle.properties b/gradle.properties index 0d12a74..6f101ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,9 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=1.2.0 +mod_version=1.2.1 mc_version=1.18.2 -mixin_version=0.8.4 -lib_version=1.4.6 -forge_version=40.1.19 +mixin_version=0.8.5 +lib_version=1.5.1 +forge_version=40.1.51 jei_version=9.7.0.195 \ No newline at end of file diff --git a/libs/InsaneLib-1.4.6-mc1.18.2.jar b/libs/InsaneLib-1.4.6-mc1.18.2.jar deleted file mode 100644 index a068e95..0000000 Binary files a/libs/InsaneLib-1.4.6-mc1.18.2.jar and /dev/null differ diff --git a/libs/InsaneLib-1.5.1-mc1.18.2.jar b/libs/InsaneLib-1.5.1-mc1.18.2.jar new file mode 100644 index 0000000..522a3f2 Binary files /dev/null and b/libs/InsaneLib-1.5.1-mc1.18.2.jar differ diff --git a/src/main/java/insane96mcp/customfluidmixin/data/CFM.java b/src/main/java/insane96mcp/customfluidmixin/data/CFM.java index 6239909..13d101c 100644 --- a/src/main/java/insane96mcp/customfluidmixin/data/CFM.java +++ b/src/main/java/insane96mcp/customfluidmixin/data/CFM.java @@ -1,26 +1,20 @@ package insane96mcp.customfluidmixin.data; +import com.google.gson.JsonParseException; import com.google.gson.annotations.SerializedName; -import insane96mcp.customfluidmixin.exception.JsonValidationException; import insane96mcp.insanelib.util.IdTagMatcher; import net.minecraft.commands.CommandFunction; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; -import net.minecraft.tags.TagKey; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.EmptyFluid; -import net.minecraft.world.level.material.Fluid; import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.tags.ITag; import java.util.ArrayList; import java.util.List; @@ -47,40 +41,40 @@ public class CFM { public transient IdTagMatcher blockToTransform; public transient List blocksNearby; - public void validate() throws JsonValidationException { + public void validate() throws JsonParseException { if (type == null) - throw new JsonValidationException("Missing type"); + throw new JsonParseException("Missing type"); if (_flowing == null) - throw new JsonValidationException("Missing flowing block"); + throw new JsonParseException("Missing flowing block"); flowing = IdTagMatcher.parseLine(_flowing); if (flowing == null) - throw new JsonValidationException("Failed to parse flowing"); + throw new JsonParseException("Failed to parse flowing"); if (type == Type.BLOCK_TRANSFORM) { if (_blockToTransform == null) - throw new JsonValidationException("Missing block_to_transform block"); + throw new JsonParseException("Missing block_to_transform block"); blockToTransform = IdTagMatcher.parseLine(_blockToTransform); if (blockToTransform == null) - throw new JsonValidationException("Failed to parse block_to_transform"); + throw new JsonParseException("Failed to parse block_to_transform"); } if (_blocksNearby == null) - throw new JsonValidationException("Missing blocks_nearby"); + throw new JsonParseException("Missing blocks_nearby"); int minBlocksNearby = this.type == Type.FLOWING_MIXIN ? 1 : 0; if (_blocksNearby.size() < minBlocksNearby || _blocksNearby.size() > 5) - throw new JsonValidationException("Invalid blocks_nearby. There must be at least one block nearby (0 works too if type = 'block_transform') and less than 5 blocks"); + throw new JsonParseException("Invalid blocks_nearby. There must be at least one block nearby (0 works too if type = 'block_transform') and less than 5 blocks"); blocksNearby = new ArrayList<>(); for (String s : _blocksNearby) { IdTagMatcher idTagMatcher = IdTagMatcher.parseLine(s); if (idTagMatcher == null) - throw new JsonValidationException("Failed to parse a block nearby " + s); + throw new JsonParseException("Failed to parse a block nearby " + s); blocksNearby.add(idTagMatcher); } if (result == null) - throw new JsonValidationException("Missing result"); + throw new JsonParseException("Missing result"); result.validate(); if (this.fizz == null) @@ -90,7 +84,7 @@ public void validate() throws JsonValidationException { public static CFM createFlowingMixin(String flowing, List blocksNearby, String blockResult) { CFM cfm = new CFM(); cfm.type = Type.FLOWING_MIXIN; - cfm.flowing = new IdTagMatcher(null, new ResourceLocation(flowing)); + cfm.flowing = new IdTagMatcher(IdTagMatcher.Type.ID, new ResourceLocation(flowing)); cfm.blocksNearby = blocksNearby; cfm.result = MixinResult.newBlockResult(blockResult); return cfm; @@ -99,7 +93,7 @@ public static CFM createFlowingMixin(String flowing, List blocksNe public static CFM createBlockTransformation(String flowing, IdTagMatcher blockToTransform, List blocksNearby, String blockResult) { CFM cfm = new CFM(); cfm.type = Type.BLOCK_TRANSFORM; - cfm.flowing = new IdTagMatcher(null, new ResourceLocation(flowing)); + cfm.flowing = new IdTagMatcher(IdTagMatcher.Type.ID, new ResourceLocation(flowing)); cfm.blockToTransform = blockToTransform; cfm.blocksNearby = blocksNearby; cfm.result = MixinResult.newBlockResult(blockResult); @@ -110,53 +104,23 @@ public static CFM createBlockTransformation(String flowing, IdTagMatcher blockTo * Returns a list with all the fluid stacks in the "flowing" key */ public List getFlowingStacks() { - return getFluidStacks(this.flowing); + return this.flowing.getAllFluidStacks(); } /** * Returns a list with all the fluids stacks in the "block_to_transform" key */ public List getFluidToTransformStacks() { - return getFluidStacks(this.blockToTransform); + return this.blockToTransform.getAllFluidStacks(); } /** * Returns a list with all the block stacks in the "block_to_transform" key */ public List getBlockToTransformStacks() { - return getItemStacks(this.blockToTransform); + return this.blockToTransform.getAllItemStacks(); } - public static List getFluidStacks(IdTagMatcher idTagMatcher) { - List fluidStacks = new ArrayList<>(); - if (idTagMatcher.id != null) { - Fluid fluid = ForgeRegistries.FLUIDS.getValue(idTagMatcher.id); - if (!(fluid instanceof EmptyFluid)) - fluidStacks.add(new FluidStack(fluid, 1000)); - } - else { - TagKey fluidTagKey = TagKey.create(Registry.FLUID_REGISTRY, idTagMatcher.tag); - ITag fluidITag = ForgeRegistries.FLUIDS.tags().getTag(fluidTagKey); - fluidITag.stream().forEach(fluid -> fluidStacks.add(new FluidStack(fluid, 1000))); - } - return fluidStacks; - } - - public static List getItemStacks(IdTagMatcher idTagMatcher) { - List itemStacks = new ArrayList<>(); - if (idTagMatcher.id != null) { - Block block = ForgeRegistries.BLOCKS.getValue(idTagMatcher.id); - itemStacks.add(new ItemStack(block)); - } - else { - TagKey blockTagKey = TagKey.create(Registry.BLOCK_REGISTRY, idTagMatcher.tag); - ITag blockITag = ForgeRegistries.BLOCKS.tags().getTag(blockTagKey); - blockITag.stream().forEach(block -> itemStacks.add(new ItemStack(block))); - } - return itemStacks; - } - - @Override public String toString() { return String.format("CFM[flowing: %s, blocks_nearby: %s, result: %s]", this.flowing, this.blocksNearby, @@ -187,28 +151,28 @@ public static MixinResult newBlockResult(String block) { return m; } - public void validate() throws JsonValidationException { + public void validate() throws JsonParseException { if (this.type == null) - throw new JsonValidationException("Missing type for result"); + throw new JsonParseException("Missing type for result"); switch (this.type) { case BLOCK -> { if (this._block == null) - throw new JsonValidationException("Missing block for block result"); + throw new JsonParseException("Missing block for block result"); ResourceLocation blockRL = ResourceLocation.tryParse(_block); if (blockRL == null) - throw new JsonValidationException("Invalid block for block result"); + throw new JsonParseException("Invalid block for block result"); this.block = ForgeRegistries.BLOCKS.getValue(blockRL).defaultBlockState(); } case EXPLOSION -> { if (this.explosionPower == null) - throw new JsonValidationException("Missing power for explosion result"); + throw new JsonParseException("Missing power for explosion result"); if (this.shouldGenerateFire == null) this.shouldGenerateFire = false; } case FUNCTION -> { if (this._function == null) - throw new JsonValidationException("Missing function for function result"); + throw new JsonParseException("Missing function for function result"); this.function = new CommandFunction.CacheableFunction(new ResourceLocation(this._function)); } } diff --git a/src/main/java/insane96mcp/customfluidmixin/data/CFMListener.java b/src/main/java/insane96mcp/customfluidmixin/data/CFMListener.java index 3cf0a77..c70d5bd 100644 --- a/src/main/java/insane96mcp/customfluidmixin/data/CFMListener.java +++ b/src/main/java/insane96mcp/customfluidmixin/data/CFMListener.java @@ -4,9 +4,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; -import com.google.gson.JsonSyntaxException; +import com.google.gson.JsonParseException; import insane96mcp.customfluidmixin.CustomFluidMixin; -import insane96mcp.customfluidmixin.exception.JsonValidationException; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; @@ -48,10 +47,7 @@ protected void apply(Map map, ResourceManager res this.customFluidMixin.put(name, cfm); } - catch (JsonValidationException e) { - CustomFluidMixin.LOGGER.error("Validation error loading Custom Fluid Mixin {}: {}", entry.getKey(), e.getMessage()); - } - catch (JsonSyntaxException e) { + catch (JsonParseException e) { CustomFluidMixin.LOGGER.error("Parsing error loading Custom Fluid Mixin {}: {}", entry.getKey(), e.getMessage()); } catch (Exception e) { diff --git a/src/main/java/insane96mcp/customfluidmixin/exception/JsonValidationException.java b/src/main/java/insane96mcp/customfluidmixin/exception/JsonValidationException.java deleted file mode 100644 index 4cb9513..0000000 --- a/src/main/java/insane96mcp/customfluidmixin/exception/JsonValidationException.java +++ /dev/null @@ -1,8 +0,0 @@ -package insane96mcp.customfluidmixin.exception; - -public class JsonValidationException extends Exception { - - public JsonValidationException(String message) { - super(message); - } -} diff --git a/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMBlockTransformationCategory.java b/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMBlockTransformationCategory.java index ef9e33f..2588145 100644 --- a/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMBlockTransformationCategory.java +++ b/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMBlockTransformationCategory.java @@ -81,8 +81,8 @@ public void setRecipe(IRecipeLayoutBuilder builder, CFM recipe, IFocusGroup focu if (blocksNearby.size() <= 3) y += 8; builder.addSlot(RecipeIngredientRole.CATALYST, x, y) - .addIngredients(ForgeTypes.FLUID_STACK, CFM.getFluidStacks(blockNearby)) - .addItemStacks(CFM.getItemStacks(blockNearby)); + .addIngredients(ForgeTypes.FLUID_STACK, blockNearby.getAllFluidStacks()) + .addItemStacks(blockNearby.getAllItemStacks()); catalysts++; } } diff --git a/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMFluidMixinCategory.java b/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMFluidMixinCategory.java index de068b9..823c8b4 100644 --- a/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMFluidMixinCategory.java +++ b/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMFluidMixinCategory.java @@ -76,8 +76,8 @@ public void setRecipe(IRecipeLayoutBuilder builder, CFM recipe, IFocusGroup focu if (blocksNearby.size() <= 3) y += 8; builder.addSlot(RecipeIngredientRole.CATALYST, x, y) - .addIngredients(ForgeTypes.FLUID_STACK, CFM.getFluidStacks(blockNearby)) - .addItemStacks(CFM.getItemStacks(blockNearby)); + .addIngredients(ForgeTypes.FLUID_STACK, blockNearby.getAllFluidStacks()) + .addItemStacks(blockNearby.getAllItemStacks()); catalysts++; } } diff --git a/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMJeiPlugin.java b/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMJeiPlugin.java index 094189c..a8d7bb9 100644 --- a/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMJeiPlugin.java +++ b/src/main/java/insane96mcp/customfluidmixin/integration/jei/CFMJeiPlugin.java @@ -38,19 +38,19 @@ public void registerCategories(IRecipeCategoryRegistration registration) { private final CFM CFM_COBBLESTONE = CFM.createFlowingMixin("minecraft:lava", List.of( - new IdTagMatcher(null, new ResourceLocation("minecraft:water"))), + new IdTagMatcher(IdTagMatcher.Type.ID, new ResourceLocation("minecraft:water"))), "minecraft:cobblestone"); private final CFM CFM_BASALT = CFM.createFlowingMixin("minecraft:lava", List.of( - new IdTagMatcher(new ResourceLocation("minecraft:soul_soil"), null), - new IdTagMatcher(new ResourceLocation("minecraft:blue_ice"), null)), + new IdTagMatcher(IdTagMatcher.Type.ID, new ResourceLocation("minecraft:soul_soil")), + new IdTagMatcher(IdTagMatcher.Type.ID, new ResourceLocation("minecraft:blue_ice"))), "minecraft:basalt"); private final CFM CFM_OBSIDIAN = CFM.createBlockTransformation("minecraft:water", - new IdTagMatcher(null, new ResourceLocation("minecraft:lava")), + new IdTagMatcher(IdTagMatcher.Type.ID, new ResourceLocation("minecraft:lava")), List.of(), "minecraft:obsidian"); private final CFM CFM_STONE = CFM.createBlockTransformation("minecraft:lava", - new IdTagMatcher(null, new ResourceLocation("minecraft:water")), + new IdTagMatcher(IdTagMatcher.Type.ID, new ResourceLocation("minecraft:water")), List.of(), "minecraft:stone"); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index f4ec098..70c7b10 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -27,6 +27,6 @@ Modpack maker tool to make custom output when fluids flow (much like vanilla doe [[dependencies.customfluidmixin]] modId="insanelib" mandatory=true - versionRange="[1.4.3,)" + versionRange="[1.5.1,)" ordering="NONE" side="BOTH"