diff options
author | Jason Mitchell <mitchej+github@gmail.com> | 2020-12-31 09:30:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-31 09:30:05 -0800 |
commit | 0ed11a6794e34ef4b104ff3a6ebc224d5efa80df (patch) | |
tree | 744a8d24726da1b06beb5f0490306ad0dde77a66 /src/main/java/gregtech/api/objects | |
parent | 23b550192c3b528dac9ef25c85da99611e00529f (diff) | |
parent | 116009659e461ac81f451406a5041a9b55f80a6f (diff) | |
download | GT5-Unofficial-0ed11a6794e34ef4b104ff3a6ebc224d5efa80df.tar.gz GT5-Unofficial-0ed11a6794e34ef4b104ff3a6ebc224d5efa80df.tar.bz2 GT5-Unofficial-0ed11a6794e34ef4b104ff3a6ebc224d5efa80df.zip |
Merge branch 'experimental' into long_distance_transfer
Diffstat (limited to 'src/main/java/gregtech/api/objects')
-rw-r--r-- | src/main/java/gregtech/api/objects/ReverseShapedRecipe.java | 43 | ||||
-rw-r--r-- | src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java | 43 |
2 files changed, 86 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); + } + } +} diff --git a/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java b/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java new file mode 100644 index 0000000000..1c5e27d246 --- /dev/null +++ b/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.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 ReverseShapelessRecipe { + private static Queue<ReverseShapelessRecipe> reverseRecipes = new LinkedList<>(); + private ItemStack aResult; + private Object[] aRecipe; + + public static Queue<ReverseShapelessRecipe> getReverseRecipes() { + return reverseRecipes; + } + + public ReverseShapelessRecipe(ItemStack output, Object[] aRecipe) { + this.aResult = output; + this.aRecipe = aRecipe; + reverseRecipes.add(this); + } + + public static void runReverseRecipes() { + for (ReverseShapelessRecipe x : reverseRecipes) { + Optional<GT_Recipe> recipeOptional = GT_Utility.reverseShapelessRecipe(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); + } + } +} |