aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java
diff options
context:
space:
mode:
authorGlodBlock <60341015+GlodBlock@users.noreply.github.com>2021-09-27 15:39:31 +0800
committerGitHub <noreply@github.com>2021-09-27 15:39:31 +0800
commit097438be70486735a8940dd5ce4e9484b6d951af (patch)
tree90f26b34d5059eb9858d9c82aabbd5373638acfa /src/main/java/gregtech/api/objects/ReverseShapedRecipe.java
parenta0a77f0b9868a4ca8a3df8ae8d50b4dcfb4030db (diff)
parent92433a5b85bb2fcca541ac25ca4033fac24f841e (diff)
downloadGT5-Unofficial-097438be70486735a8940dd5ce4e9484b6d951af.tar.gz
GT5-Unofficial-097438be70486735a8940dd5ce4e9484b6d951af.tar.bz2
GT5-Unofficial-097438be70486735a8940dd5ce4e9484b6d951af.zip
Merge pull request #1 from GlodBlock/fix-crack-recipe-check
Fix crack recipe check
Diffstat (limited to 'src/main/java/gregtech/api/objects/ReverseShapedRecipe.java')
-rw-r--r--src/main/java/gregtech/api/objects/ReverseShapedRecipe.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java b/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java
new file mode 100644
index 0000000000..cb9e7d4d83
--- /dev/null
+++ b/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java
@@ -0,0 +1,43 @@
+package gregtech.api.objects;
+
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler;
+import net.minecraft.item.ItemStack;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.Optional;
+import java.util.Queue;
+
+import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes;
+
+public class ReverseShapedRecipe {
+ private static Queue<ReverseShapedRecipe> reverseRecipes = new LinkedList<>();
+ private ItemStack aResult;
+ private Object[] aRecipe;
+
+ public static Queue<ReverseShapedRecipe> getReverseRecipes() {
+ return reverseRecipes;
+ }
+
+ public ReverseShapedRecipe(ItemStack output, Object[] aRecipe) {
+ this.aResult = output;
+ this.aRecipe = aRecipe;
+ reverseRecipes.add(this);
+ }
+
+ public static void runReverseRecipes() {
+ for (ReverseShapedRecipe x : reverseRecipes) {
+ Optional<GT_Recipe> recipeOptional = GT_Utility.reverseShapedRecipe(x.aResult, x.aRecipe);
+ if (!recipeOptional.isPresent())
+ continue;
+ GT_Recipe recipe = recipeOptional.get();
+ ItemStack[] replacement = new ItemStack[recipe.mOutputs.length];
+ GT_MetaTileEntity_Disassembler.handleRecipeTransformation(recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs));
+
+ recipe.mOutputs = replacement;
+ sDisassemblerRecipes.add(recipe);
+ }
+ }
+}