forked from SteamWar/SteamWar
Hotfix PistonCalculator
This commit is contained in:
+9
-4
@@ -91,7 +91,7 @@ public class PistonCalculator implements Listener {
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 1);
|
||||
}, 3);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -146,7 +146,7 @@ public class PistonCalculator implements Listener {
|
||||
private boolean pulling = false;
|
||||
private List<Location> movedBlocks = new ArrayList<>();
|
||||
private List<Location> brokenBlocks = new ArrayList<>();
|
||||
private List<Location> immovableBlocks = new ArrayList<>();
|
||||
private Set<Location> immovableBlocks = new HashSet<>();
|
||||
|
||||
public void calculate() {
|
||||
movedBlocks.clear();
|
||||
@@ -173,7 +173,6 @@ public class PistonCalculator implements Listener {
|
||||
|
||||
Collections.reverse(movedBlocks);
|
||||
Collections.reverse(brokenBlocks);
|
||||
Collections.reverse(immovableBlocks);
|
||||
|
||||
visualize();
|
||||
}
|
||||
@@ -208,6 +207,7 @@ public class PistonCalculator implements Listener {
|
||||
|
||||
movedBlocks.remove(origin.getLocation());
|
||||
if (facing != direction) movedBlocks.remove(origin.getRelative(facing, 1).getLocation());
|
||||
if (pulling) immovableBlocks.remove(origin.getRelative(facing).getLocation());
|
||||
}
|
||||
|
||||
private void calcDirection(Block origin, Block blockOrigin, Block calcOrigin, Block ignore, BlockFace facing, BlockFace direction, List<Block> toCalc) {
|
||||
@@ -215,7 +215,9 @@ public class PistonCalculator implements Listener {
|
||||
Block block = calcOrigin.getRelative(direction, i);
|
||||
if (block.equals(ignore)) return;
|
||||
if (block.getPistonMoveReaction() == PistonMoveReaction.BREAK) {
|
||||
brokenBlocks.add(block.getLocation());
|
||||
if (!brokenBlocks.contains(block.getLocation())) {
|
||||
brokenBlocks.add(block.getLocation());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isImmovable(block)) {
|
||||
@@ -302,6 +304,9 @@ public class PistonCalculator implements Listener {
|
||||
}
|
||||
|
||||
private boolean isImmovable(Block block) {
|
||||
if (block.isEmpty() || block.isLiquid()) {
|
||||
return false;
|
||||
}
|
||||
BlockData blockData = block.getBlockData();
|
||||
if (blockData instanceof Piston) {
|
||||
return ((Piston) blockData).isExtended();
|
||||
|
||||
Reference in New Issue
Block a user