From 7494ea5645fb76aec16f9852ebf3454f1fd197c4 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Tue, 3 Aug 2021 20:44:17 -0600 Subject: Add disassembler restrictions bypass --- src/main/java/gregtech/api/util/GT_Recipe.java | 2 ++ .../basic/GT_MetaTileEntity_Disassembler.java | 29 +++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 19f46dfd15..e10d58cd75 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -572,6 +572,8 @@ public class GT_Recipe implements Comparable { public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); + + /** Set {@code aSpecialValue = -100} to bypass the disassembler tier check and default recipe duration. */ public static final GT_Recipe_Map sDisassemblerRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.disassembler", "Disassembler", null, RES_PATH_GUI + "basicmachines/Disassembler", 1, 9, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java index b820dd44fd..13eefcd7a6 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -172,9 +172,6 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi ) return DID_NOT_FIND_RECIPE; - if (checkTier(is)) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - Integer handleHardOverride = handleHardOverride(is); if (handleHardOverride != null) return handleHardOverride; @@ -241,17 +238,31 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi GT_Recipe gt_recipe = GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.findRecipe(this.getBaseMetaTileEntity(), true, this.maxEUInput(), null, this.getAllInputs()); if (gt_recipe == null) return DID_NOT_FIND_RECIPE; - if (gt_recipe.isRecipeInputEqual(false, null, this.getAllInputs())) - return setOutputsAndTime(gt_recipe.mOutputs, gt_recipe.mInputs[0].stackSize) - ? FOUND_AND_SUCCESSFULLY_USED_RECIPE - : FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + if (gt_recipe.isRecipeInputEqual(false, null, this.getAllInputs())) { + if (gt_recipe.mSpecialValue == -100) { + // Bypass standard disassembler restrictions. + this.getInputAt(0).stackSize -= gt_recipe.mInputs[0].stackSize; + System.arraycopy(gt_recipe.mOutputs, 0, this.mOutputItems, 0, gt_recipe.mOutputs.length); + + this.calculateOverclockedNess(gt_recipe); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } else { + return setOutputsAndTime(gt_recipe.mOutputs, gt_recipe.mInputs[0].stackSize) + ? FOUND_AND_SUCCESSFULLY_USED_RECIPE + : FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + } return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } private boolean setOutputsAndTime(ItemStack[] inputs, int stackSize){ - if (this.getInputAt(0).stackSize >= stackSize) - this.getInputAt(0).stackSize -= stackSize; + ItemStack machineInput = this.getInputAt(0); + if (checkTier(machineInput)) + return false; + + if (machineInput.stackSize >= stackSize) + machineInput.stackSize -= stackSize; else return false; -- cgit