-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix EnderIO sag mill outputs unification breaking recipes
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...rge/src/main/java/com/almostreliable/unified/compat/unification/EnderIORecipeUnifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters