Skip to content

Commit

Permalink
fix EnderIO sag mill outputs unification breaking recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
rlnt committed Oct 6, 2024
1 parent 5065b1a commit f5da433
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;
Expand Down Expand Up @@ -39,6 +40,10 @@ public void registerRecipeUnifiers(RecipeUnifierRegistry registry) {
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());
Expand Down

0 comments on commit f5da433

Please sign in to comment.