From 62bb20ef6271b09dab45d66103a185774aba523e Mon Sep 17 00:00:00 2001 From: Jaiden Baker Date: Wed, 13 Sep 2023 20:44:42 +1200 Subject: Make Crafting Input Bus / Hatch compatible with some non-GPL multis (#2266) * Add crafting input bus items to getStoredInputs * Add crafting input hatch fluids to getStoredFluids * Respect internal input isolation * List.of -> Arrays.asList * Skip fluids on non-supporting bus * Fix NPE * Change return type to Optional & add Slave support --- .../GT_MetaTileEntity_MultiBlockBase.java | 34 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') 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 ff2ecfa83f..8890f025e9 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 @@ -34,6 +34,7 @@ import org.jetbrains.annotations.TestOnly; import org.lwjgl.input.Keyboard; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -82,11 +83,7 @@ import gregtech.client.GT_SoundLoop; import gregtech.common.GT_Pollution; import gregtech.common.gui.modularui.widget.CheckRecipeResultSyncer; import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Output_ME; -import gregtech.common.tileentities.machines.IDualInputHatch; -import gregtech.common.tileentities.machines.IDualInputInventory; +import gregtech.common.tileentities.machines.*; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -1330,6 +1327,19 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity } public ArrayList getStoredFluids() { + if (supportsCraftingMEBuffer()) { + for (IDualInputHatch tHatch : mDualInputHatches) { + if (tHatch.supportsFluids()) { + Optional inventory = tHatch.getFirstNonEmptyInventory(); + if (inventory.isPresent()) { + return Lists.newArrayList( + inventory.get() + .getFluidInputs()); + } + } + } + } + ArrayList rList = new ArrayList<>(); for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { tHatch.mRecipeMap = getRecipeMap(); @@ -1349,12 +1359,25 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity } } } + return rList; } public ArrayList getStoredInputs() { + if (supportsCraftingMEBuffer()) { + for (IDualInputHatch tHatch : mDualInputHatches) { + Optional inventory = tHatch.getFirstNonEmptyInventory(); + if (inventory.isPresent()) { + return Lists.newArrayList( + inventory.get() + .getItemInputs()); + } + } + } + ArrayList rList = new ArrayList<>(); HashMap rInputBusMeList = new HashMap<>(); + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch)) { @@ -1372,6 +1395,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity } } } + if (getStackInSlot(1) != null && getStackInSlot(1).getUnlocalizedName() .startsWith("gt.integrated_circuit")) rList.add(getStackInSlot(1)); if (!rInputBusMeList.isEmpty()) rList.addAll(rInputBusMeList.values()); -- cgit