diff --git a/CHANGELOG.md b/CHANGELOG.md index 01cd85f..fc28d57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning]. - fixed recipe viewer integration endpoints for Fabric - fixed unnecessary memory usage for debug handler - fixed Mekanism recipe unifier using wrong recipe keys +- fixed EnderIO Sag Mill recipe output unification causing serialization failures ## [1.1.0] - 2024-09-27 diff --git a/Common/src/main/java/com/almostreliable/unified/api/constant/ModConstants.java b/Common/src/main/java/com/almostreliable/unified/api/constant/ModConstants.java index 23fd8df..3fbe33c 100644 --- a/Common/src/main/java/com/almostreliable/unified/api/constant/ModConstants.java +++ b/Common/src/main/java/com/almostreliable/unified/api/constant/ModConstants.java @@ -19,6 +19,7 @@ public interface ModConstants { String ARS_NOUVEAU = "ars_nouveau"; String ARS_SCALAES = "ars_scalaes"; String CYCLIC = "cyclic"; + String ENDER_IO = "enderio"; String GREGTECH_MODERN = "gtceu"; String IMMERSIVE_ENGINEERING = "immersiveengineering"; String INTEGRATED_DYNAMICS = "integrateddynamics"; diff --git a/NeoForge/src/main/java/com/almostreliable/unified/compat/unification/EnderIORecipeUnifier.java b/NeoForge/src/main/java/com/almostreliable/unified/compat/unification/EnderIORecipeUnifier.java new file mode 100644 index 0000000..915b488 --- /dev/null +++ b/NeoForge/src/main/java/com/almostreliable/unified/compat/unification/EnderIORecipeUnifier.java @@ -0,0 +1,48 @@ +package com.almostreliable.unified.compat.unification; + +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; + +import com.almostreliable.unified.api.constant.RecipeConstants; +import com.almostreliable.unified.api.unification.bundled.GenericRecipeUnifier; +import com.almostreliable.unified.api.unification.recipe.RecipeJson; +import com.almostreliable.unified.api.unification.recipe.RecipeUnifier; +import com.almostreliable.unified.api.unification.recipe.UnificationHelper; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; + +public class EnderIORecipeUnifier implements RecipeUnifier { + + @Override + public void unify(UnificationHelper helper, RecipeJson recipe) { + GenericRecipeUnifier.INSTANCE.unifyInputs(helper, recipe); + + if (!(recipe.getProperty(RecipeConstants.OUTPUTS) instanceof JsonArray outputArray)) { + return; + } + + for (JsonElement outputElement : outputArray) { + if (!(outputElement instanceof JsonObject outputObject)) { + continue; + } + + if (!(outputObject.get(RecipeConstants.ITEM) instanceof JsonObject itemObject)) { + continue; + } + + if (itemObject.has(RecipeConstants.ID)) { + helper.unifyOutputItem(itemObject); + continue; + } + + if (itemObject.get(RecipeConstants.TAG) instanceof JsonPrimitive tagPrimitive) { + var tag = TagKey.create(Registries.ITEM, ResourceLocation.parse(tagPrimitive.getAsString())); + helper.handleTagToItemReplacement(itemObject, RecipeConstants.ID, tag); + } + } + } +} diff --git a/NeoForge/src/main/java/com/almostreliable/unified/core/NeoForgePlugin.java b/NeoForge/src/main/java/com/almostreliable/unified/core/NeoForgePlugin.java index 560f769..1e98551 100644 --- a/NeoForge/src/main/java/com/almostreliable/unified/core/NeoForgePlugin.java +++ b/NeoForge/src/main/java/com/almostreliable/unified/core/NeoForgePlugin.java @@ -11,6 +11,7 @@ import com.almostreliable.unified.api.unification.recipe.RecipeUnifierRegistry; import com.almostreliable.unified.compat.unification.ArsNouveauRecipeUnifier; import com.almostreliable.unified.compat.unification.CompoundIngredientUnifier; import com.almostreliable.unified.compat.unification.CyclicRecipeUnifier; +import com.almostreliable.unified.compat.unification.EnderIORecipeUnifier; import com.almostreliable.unified.compat.unification.ImmersiveEngineeringRecipeUnifier; import com.almostreliable.unified.compat.unification.IntegratedDynamicsRecipeUnifier; import com.almostreliable.unified.compat.unification.MekanismRecipeUnifier; @@ -39,6 +40,10 @@ public class NeoForgePlugin implements AlmostUnifiedPlugin { ModConstants.ARS_SCALAES ).forEach(modId -> registry.registerForModId(modId, new ArsNouveauRecipeUnifier())); registry.registerForModId(ModConstants.CYCLIC, new CyclicRecipeUnifier()); + registry.registerForRecipeType( + ResourceLocation.fromNamespaceAndPath(ModConstants.ENDER_IO, "sag_milling"), + new EnderIORecipeUnifier() + ); registry.registerForModId(ModConstants.IMMERSIVE_ENGINEERING, new ImmersiveEngineeringRecipeUnifier()); registry.registerForModId(ModConstants.INTEGRATED_DYNAMICS, new IntegratedDynamicsRecipeUnifier()); registry.registerForModId(ModConstants.MEKANISM, new MekanismRecipeUnifier());