From 7acd88171ba9e6b904fe7d66fbda065e29f6fb08 Mon Sep 17 00:00:00 2001 From: Dredonkey <39687299+Dredonkey@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:07:05 -0700 Subject: [PATCH] Fix crafting station sometimes detecting a chest next to a trapped chest as a double chest (#213) --- .../tools/logic/CraftingStationLogic.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/tconstruct/tools/logic/CraftingStationLogic.java b/src/main/java/tconstruct/tools/logic/CraftingStationLogic.java index 368d277b..15e59dbc 100644 --- a/src/main/java/tconstruct/tools/logic/CraftingStationLogic.java +++ b/src/main/java/tconstruct/tools/logic/CraftingStationLogic.java @@ -95,11 +95,20 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent ? sidedIvn.getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length : inv.getSizeInventory(); - if (tile instanceof TileEntityChest) { - checkForChest(world, xPos, yPos, zPos, 1, 0); - checkForChest(world, xPos, yPos, zPos, -1, 0); - checkForChest(world, xPos, yPos, zPos, 0, 1); - checkForChest(world, xPos, yPos, zPos, 0, -1); + if (tile instanceof TileEntityChest tileChest) { + if (tileChest.adjacentChestZPos != null) { + doubleChest = new WeakReference<>(tileChest.adjacentChestZPos); + doubleFirst = false; + } else if (tileChest.adjacentChestZNeg != null) { + doubleChest = new WeakReference<>(tileChest.adjacentChestZNeg); + doubleFirst = true; + } else if (tileChest.adjacentChestXPos != null) { + doubleChest = new WeakReference<>(tileChest.adjacentChestXPos); + doubleFirst = false; + } else if (tileChest.adjacentChestXNeg != null) { + doubleChest = new WeakReference<>(tileChest.adjacentChestXNeg); + doubleFirst = true; + } } slotCount = chestSize * (doubleChest != null ? 2 : 1); invRows = (int) Math.ceil((double) slotCount / invColumns); @@ -113,14 +122,6 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent return PHConstruct.craftingStationBlacklist.contains(clazz.getName()); } - void checkForChest(World world, int x, int y, int z, int dx, int dz) { - TileEntity tile = world.getTileEntity(x + dx, y, z + dz); - if (tile instanceof TileEntityChest) { - doubleChest = new WeakReference<>((IInventory) tile); - doubleFirst = dx + dz < 0; - } - } - public boolean isDoubleChest() { return this.doubleChest != null; }