diff options
author | Kiwi <42833050+Kiwi233@users.noreply.github.com> | 2021-07-05 22:06:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-05 22:06:44 +0800 |
commit | 4eaefbb5455dc3402b43dcbf6cba208cea4e301a (patch) | |
tree | b7e34b2e20af663cdd72c616fd7424301304e3e4 /src/main/java/gregtech/api/objects/ReverseShapedRecipe.java | |
parent | 36406947fc5c0de1ee71da2644ec057b5fbc8d25 (diff) | |
parent | 703a8930bee25b1f908e9c4ea4f52cef24337d03 (diff) | |
download | GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.tar.gz GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.tar.bz2 GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.zip |
Merge pull request #3 from GTNewHorizons/experimental
gregtech-5.09.35.00
Diffstat (limited to 'src/main/java/gregtech/api/objects/ReverseShapedRecipe.java')
-rw-r--r-- | src/main/java/gregtech/api/objects/ReverseShapedRecipe.java | 43 |
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); + } + } +} |