diff --git a/src/main/java/ru/redguy/extendedpistons/WorldListener.java b/src/main/java/ru/redguy/extendedpistons/WorldListener.java index b67b637..3e3fd33 100644 --- a/src/main/java/ru/redguy/extendedpistons/WorldListener.java +++ b/src/main/java/ru/redguy/extendedpistons/WorldListener.java @@ -82,7 +82,7 @@ public class WorldListener implements Listener { List toBreak = checker.getBrokenBlocksObjects(); if (isMovable) { - if(!isBlocksAllowedToInteract(copyWithAdd(blocks,toBreak))) continue; + if(!isBlocksAllowedToInteract(copyWithAdd(blocks,toBreak),piston.getFacing())) continue; for (Block block1 : toBreak) { block1.breakNaturally(); } @@ -193,7 +193,7 @@ public class WorldListener implements Listener { } if (isMovable) { - if(!isBlocksAllowedToInteract(copyWithAdd(blocks,toBreak))) return; + if(!isBlocksAllowedToInteract(copyWithAdd(blocks,toBreak),piston.getFacing())) return; Collections.reverse(blocks); for (Block block1 : toBreak) { block1.breakNaturally(); @@ -264,7 +264,7 @@ public class WorldListener implements Listener { List toBreak = checker.getBrokenBlocksObjects(); if (isMovable) { - if(!isBlocksAllowedToInteract(copyWithAdd(blocks,toBreak))) continue; + if(!isBlocksAllowedToInteract(copyWithAdd(blocks,toBreak),piston.getFacing())) continue; for (Block block1 : toBreak) { block1.breakNaturally(); } @@ -362,7 +362,7 @@ public class WorldListener implements Listener { } if (isMovable) { - if(!isBlocksAllowedToInteract(copyWithAdd(blocks,toBreak))) return; + if(!isBlocksAllowedToInteract(copyWithAdd(blocks,toBreak),piston.getFacing())) return; Collections.reverse(blocks); for (Block block1 : toBreak) { block1.breakNaturally(); @@ -403,7 +403,7 @@ public class WorldListener implements Listener { return 12; } - public boolean isBlocksAllowedToInteract(List blocks) { + public boolean isBlocksAllowedToInteract(List blocks, BlockFace bf) { WorldGuardPlugin wg = ExtendedPistons.INSTANCE.wg; RegionContainer container = wg.getRegionContainer(); RegionQuery query = container.createQuery(); @@ -411,6 +411,9 @@ public class WorldListener implements Listener { boolean state = query.testState(block.getLocation(),(Player)null, DefaultFlag.PISTONS); if(!state) return false; + state = query.testState(block.getRelative(bf).getLocation(),(Player)null, DefaultFlag.PISTONS); + if(!state) + return false; } return true; }