From 93ad1ff2c3fcdf8129b42dfffabf85c435a6b0e0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 28 Nov 2021 14:54:27 +0100 Subject: [PATCH] Fix Panzern Signed-off-by: yoyosource --- .../features/slaves/panzern/Panzern.java | 6 +++--- .../panzern/algorithms/AdjacentHoney.java | 17 +++++++++++++---- .../panzern/algorithms/AdjacentSlime.java | 17 +++++++++++++---- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java index cda31d41..81740e55 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java @@ -58,7 +58,7 @@ public class Panzern { private BaseBlock blockType; private BaseBlock slabType; private static final BaseBlock jukeboxType = BlockTypes.JUKEBOX.getDefaultState().toBaseBlock(); - private static final BaseBlock hopperType = BlockTypes.HOPPER.getDefaultState().toBaseBlock(); + private static final BaseBlock cobwebType = BlockTypes.COBWEB.getDefaultState().toBaseBlock(); private static final BaseBlock airType = BlockTypes.AIR.getDefaultState().toBaseBlock(); @Getter @@ -131,8 +131,8 @@ public class Panzern { editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, jukeboxType)); break; case UNMOVABLE_SLAB: - currentBlock.setType(Material.HOPPER); - editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, hopperType)); + currentBlock.setType(Material.COBWEB); + editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, cobwebType)); break; default: emptyBlocks.add(currentBlock.getLocation().toVector()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentHoney.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentHoney.java index aca57cd7..cf989623 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentHoney.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentHoney.java @@ -33,17 +33,26 @@ import java.util.Set; @Linked(LinkageType.PANZERN) public class AdjacentHoney implements PanzernAlgorithm { + private PistonLine pistonLine = new PistonLine(); + @Override public PanzernResult check(Block source, Map adjacent, Set adjacentMaterials) { if (adjacentMaterials.contains(Material.HONEY_BLOCK)) { - if (adjacent.get(BlockFace.DOWN).getType() == Material.REDSTONE_WIRE) { - for (BlockFace face : HORIZONTAL_FACES) { - if (adjacent.get(face).getType() == Material.REDSTONE_WIRE) { + for (BlockFace face : HORIZONTAL_FACES) { + if (!adjacent.containsKey(face)) continue; + if (adjacent.get(face).getType() == Material.REDSTONE_WIRE) { + PanzernResult panzernResult = pistonLine.check(source, adjacent, adjacentMaterials); + if (panzernResult == PanzernResult.DEFAULT) { return PanzernResult.UNMOVABLE_SLAB; } + return panzernResult; } } - return PanzernResult.UNMOVABLE; + PanzernResult panzernResult = pistonLine.check(source, adjacent, adjacentMaterials); + if (panzernResult == PanzernResult.DEFAULT) { + return PanzernResult.UNMOVABLE; + } + return panzernResult; } return PanzernResult.DEFAULT; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentSlime.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentSlime.java index ff9ca4f6..c3f27eaa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentSlime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentSlime.java @@ -33,17 +33,26 @@ import java.util.Set; @Linked(LinkageType.PANZERN) public class AdjacentSlime implements PanzernAlgorithm { + private PistonLine pistonLine = new PistonLine(); + @Override public PanzernResult check(Block source, Map adjacent, Set adjacentMaterials) { if (adjacentMaterials.contains(Material.SLIME_BLOCK)) { - if (adjacent.get(BlockFace.DOWN).getType() == Material.REDSTONE_WIRE) { - for (BlockFace face : HORIZONTAL_FACES) { - if (adjacent.get(face).getType() == Material.REDSTONE_WIRE) { + for (BlockFace face : HORIZONTAL_FACES) { + if (!adjacent.containsKey(face)) continue; + if (adjacent.get(face).getType() == Material.REDSTONE_WIRE) { + PanzernResult panzernResult = pistonLine.check(source, adjacent, adjacentMaterials); + if (panzernResult == PanzernResult.DEFAULT) { return PanzernResult.UNMOVABLE_SLAB; } + return panzernResult; } } - return PanzernResult.UNMOVABLE; + PanzernResult panzernResult = pistonLine.check(source, adjacent, adjacentMaterials); + if (panzernResult == PanzernResult.DEFAULT) { + return PanzernResult.UNMOVABLE; + } + return panzernResult; } return PanzernResult.DEFAULT; }