aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
authorJaiden Baker <jaidencolebaker@gmail.com>2023-09-13 20:44:42 +1200
committerGitHub <noreply@github.com>2023-09-13 10:44:42 +0200
commit62bb20ef6271b09dab45d66103a185774aba523e (patch)
tree220291daf534c7a4eb0fa2d8331c97ff132c9781 /src/main/java/gregtech/common
parent999327f2e4e7a4c9d4e1a8dbd2ad11c4ced1d4a5 (diff)
downloadGT5-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/common')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java15
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java10
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/IDualInputHatch.java5
3 files changed, 29 insertions, 1 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java
index 83a5789430..e7af09ef90 100644
--- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java
+++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java
@@ -715,7 +715,7 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_
needPatternSync = true;
}
- private ItemStack[] getSharedItems() {
+ public ItemStack[] getSharedItems() {
ItemStack[] sharedItems = new ItemStack[SLOT_MANUAL_SIZE + 1];
sharedItems[0] = mInventory[SLOT_CIRCUIT];
System.arraycopy(mInventory, SLOT_MANUAL_START, sharedItems, 1, SLOT_MANUAL_SIZE);
@@ -952,4 +952,17 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_
public void setCustomName(String name) {
customName = name;
}
+
+ @Override
+ public Optional<IDualInputInventory> getFirstNonEmptyInventory() {
+ for (PatternSlot slot : internalInventory) {
+ if (slot != null && !slot.isEmpty()) return Optional.of(slot);
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public boolean supportsFluids() {
+ return this.supportFluids;
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java
index 2ea053995c..f2048f82ce 100644
--- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java
+++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java
@@ -144,6 +144,16 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_Slave extends GT_MetaTileEnti
}
@Override
+ public Optional<IDualInputInventory> getFirstNonEmptyInventory() {
+ return getMaster() != null ? getMaster().getFirstNonEmptyInventory() : Optional.empty();
+ }
+
+ @Override
+ public boolean supportsFluids() {
+ return getMaster() != null && getMaster().supportsFluids();
+ }
+
+ @Override
public boolean justUpdated() {
return getMaster() != null && getMaster().justUpdated();
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/IDualInputHatch.java b/src/main/java/gregtech/common/tileentities/machines/IDualInputHatch.java
index 54b1acbdfa..c89aaaff40 100644
--- a/src/main/java/gregtech/common/tileentities/machines/IDualInputHatch.java
+++ b/src/main/java/gregtech/common/tileentities/machines/IDualInputHatch.java
@@ -1,6 +1,7 @@
package gregtech.common.tileentities.machines;
import java.util.Iterator;
+import java.util.Optional;
import net.minecraft.item.ItemStack;
@@ -13,4 +14,8 @@ public interface IDualInputHatch {
void updateTexture(int id);
void updateCraftingIcon(ItemStack icon);
+
+ Optional<IDualInputInventory> getFirstNonEmptyInventory();
+
+ public boolean supportsFluids();
}