diff options
author | Maxim <maxim235@gmx.de> | 2023-07-14 12:54:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-14 12:54:49 +0200 |
commit | b8bd619bbfdecddccf8a1a3129a11e0fccca200b (patch) | |
tree | c38967470d94d954a4ac126009c7e4462bbc6700 /src/main | |
parent | 4dd7f2f9494880712c15fd66637d0e96004e40a6 (diff) | |
download | GT5-Unofficial-b8bd619bbfdecddccf8a1a3129a11e0fccca200b.tar.gz GT5-Unofficial-b8bd619bbfdecddccf8a1a3129a11e0fccca200b.tar.bz2 GT5-Unofficial-b8bd619bbfdecddccf8a1a3129a11e0fccca200b.zip |
GPL Special Item access (#2134)
* Added getters to allow a machine to set the special item for recipe checking
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/gregtech/api/logic/ProcessingLogic.java | 17 | ||||
-rw-r--r-- | src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java | 29 |
2 files changed, 35 insertions, 11 deletions
diff --git a/src/main/java/gregtech/api/logic/ProcessingLogic.java b/src/main/java/gregtech/api/logic/ProcessingLogic.java index db97ac151f..bcf460e5e1 100644 --- a/src/main/java/gregtech/api/logic/ProcessingLogic.java +++ b/src/main/java/gregtech/api/logic/ProcessingLogic.java @@ -29,6 +29,7 @@ public class ProcessingLogic { protected IRecipeLockable recipeLockableMachine; protected Supplier<GT_Recipe_Map> recipeMapSupplier; protected GT_Recipe lastRecipe; + protected ItemStack specialSlotItem; protected ItemStack[] inputItems; protected ItemStack[] outputItems; protected ItemStack[] currentOutputItems; @@ -73,6 +74,11 @@ public class ProcessingLogic { return this; } + public ProcessingLogic setSpecialSlotItem(ItemStack specialSlotItem) { + this.specialSlotItem = specialSlotItem; + return this; + } + /** * Overwrites item output result of the calculation. */ @@ -213,6 +219,7 @@ public class ProcessingLogic { public ProcessingLogic clear() { this.inputItems = null; this.inputFluids = null; + this.specialSlotItem = null; this.outputItems = null; this.outputFluids = null; this.calculatedEut = 0; @@ -252,8 +259,14 @@ public class ProcessingLogic { recipeLockableMachine.getSingleRecipeCheck() .getRecipe()); } else { - findRecipeResult = recipeMap - .findRecipeWithResult(lastRecipe, false, false, availableVoltage, inputFluids, null, inputItems); + findRecipeResult = recipeMap.findRecipeWithResult( + lastRecipe, + false, + false, + availableVoltage, + inputFluids, + specialSlotItem, + inputItems); } GT_Recipe recipe; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 0d383bc768..36266d6329 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -692,14 +692,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity CheckRecipeResult result = CheckRecipeResultRegistry.NO_RECIPE; - processingLogic.clear(); - processingLogic.setMachine(this); - processingLogic.setRecipeMapSupplier(this::getRecipeMap); - processingLogic.setVoidProtection(protectsExcessItem(), protectsExcessFluid()); - processingLogic.setBatchSize(isBatchModeEnabled() ? getMaxBatchSize() : 1); - processingLogic.setRecipeLocking(this, isRecipeLockingEnabled()); - processingLogic.setInputFluids(getStoredFluids()); - setProcessingLogicPower(processingLogic); + setupProcessingLogic(processingLogic); + if (isInputSeparationEnabled()) { for (GT_MetaTileEntity_Hatch_InputBus bus : mInputBusses) { List<ItemStack> inputItems = new ArrayList<>(); @@ -742,6 +736,17 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity return result; } + protected void setupProcessingLogic(ProcessingLogic logic) { + logic.clear(); + logic.setMachine(this); + logic.setRecipeMapSupplier(this::getRecipeMap); + logic.setVoidProtection(protectsExcessItem(), protectsExcessFluid()); + logic.setBatchSize(isBatchModeEnabled() ? getMaxBatchSize() : 1); + logic.setRecipeLocking(this, isRecipeLockingEnabled()); + logic.setInputFluids(getStoredFluids()); + setProcessingLogicPower(logic); + } + protected void setProcessingLogicPower(ProcessingLogic logic) { logic.setAvailableVoltage(GT_Utility.roundDownVoltage(getMaxInputVoltage())); logic.setAvailableAmperage(1); @@ -1998,6 +2003,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity @Override public void addGregTechLogo(ModularWindow.Builder builder) {} + protected boolean shouldDisplayCheckRecipeResult() { + return true; + } + protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inventorySlot) { screenElements.setSynced(false) .setSpace(0) @@ -2074,7 +2083,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity TextWidget.dynamicString(() -> checkRecipeResult.getDisplayString()) .setSynced(false) .setTextAlignment(Alignment.CenterLeft) - .setEnabled(widget -> GT_Utility.isStringValid(checkRecipeResult.getDisplayString()))) + .setEnabled( + widget -> GT_Utility.isStringValid(checkRecipeResult.getDisplayString()) + && shouldDisplayCheckRecipeResult())) .widget(new CheckRecipeResultSyncer(() -> checkRecipeResult, (result) -> checkRecipeResult = result)); screenElements.widget( |