fix EnderIO sag mill outputs unification breaking recipes

This commit is contained in:
rlnt 2024-10-06 18:26:52 +02:00
parent 5065b1a35e
commit f5da433df4
No known key found for this signature in database
4 changed files with 55 additions and 0 deletions

View file

@ -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

View file

@ -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";

View file

@ -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);
}
}
}
}

View file

@ -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());