From 4dc0170bad1794f8f530745aa6556fde340f538a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 8 Oct 2021 16:50:27 +0200 Subject: [PATCH] Fix edge cases in PowerableActivation and SmartPlaceListener while placing hopper on an inventory holder Signed-off-by: yoyosource --- .../slaves/panzern/algorithms/PowerableActivation.java | 7 +++++-- .../bausystem/features/smartplace/SmartPlaceListener.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PowerableActivation.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PowerableActivation.java index 0fc5d4d4..121e97c4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PowerableActivation.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PowerableActivation.java @@ -41,17 +41,20 @@ public class PowerableActivation implements PanzernAlgorithm { public PanzernResult check(Block source, Map adjacent, Set adjacentMaterials) { int powered = 0; int powerable = 0; - for (BlockFace blockFace : HORIZONTAL_FACES) { + for (BlockFace blockFace : BLOCK_FACES) { if (!adjacent.containsKey(blockFace)) { continue; } Block block = adjacent.get(blockFace); - if (block.getBlockData() instanceof Powerable || block.getBlockData() instanceof AnaloguePowerable && block.getType() != Material.OBSERVER) { + if ((block.getType() == Material.HOPPER || block.getBlockData() instanceof Powerable || block.getBlockData() instanceof AnaloguePowerable) && block.getType() != Material.OBSERVER) { powerable++; } if (block.getType() == Material.TNT) { powerable++; } + if (blockFace == BlockFace.DOWN || blockFace == BlockFace.UP) { + continue; + } switch (block.getType()) { case REDSTONE_WIRE: RedstoneWire redstoneWire = (RedstoneWire) block.getBlockData(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index 84b0053c..7ee8fd45 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -96,7 +96,7 @@ public class SmartPlaceListener implements Listener { return; } - if (event.getClickedBlock().getType() == event.getMaterial()) { + if (event.getClickedBlock().getType() == event.getMaterial() || event.getMaterial() == Material.HOPPER) { if (!(event.getClickedBlock().getState() instanceof InventoryHolder)) { return; }