diff options
author | Jaiden Baker <jaidencolebaker@gmail.com> | 2023-09-13 20:44:42 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-13 10:44:42 +0200 |
commit | 62bb20ef6271b09dab45d66103a185774aba523e (patch) | |
tree | 220291daf534c7a4eb0fa2d8331c97ff132c9781 /src/main/java/gregtech/api/metatileentity | |
parent | 999327f2e4e7a4c9d4e1a8dbd2ad11c4ced1d4a5 (diff) | |
download | GT5-Unofficial-62bb20ef6271b09dab45d66103a185774aba523e.tar.gz GT5-Unofficial-62bb20ef6271b09dab45d66103a185774aba523e.tar.bz2 GT5-Unofficial-62bb20ef6271b09dab45d66103a185774aba523e.zip |
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
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
-rw-r--r-- | src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java | 34 |
1 files changed, 29 insertions, 5 deletions
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<FluidStack> getStoredFluids() { + if (supportsCraftingMEBuffer()) { + for (IDualInputHatch tHatch : mDualInputHatches) { + if (tHatch.supportsFluids()) { + Optional<IDualInputInventory> inventory = tHatch.getFirstNonEmptyInventory(); + if (inventory.isPresent()) { + return Lists.newArrayList( + inventory.get() + .getFluidInputs()); + } + } + } + } + ArrayList<FluidStack> 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<ItemStack> getStoredInputs() { + if (supportsCraftingMEBuffer()) { + for (IDualInputHatch tHatch : mDualInputHatches) { + Optional<IDualInputInventory> inventory = tHatch.getFirstNonEmptyInventory(); + if (inventory.isPresent()) { + return Lists.newArrayList( + inventory.get() + .getItemInputs()); + } + } + } + ArrayList<ItemStack> rList = new ArrayList<>(); HashMap<String, ItemStack> 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()); |