From c891bdf3adcef5d4c6254ba53a2bb1bc43d9739c Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 15 Feb 2022 17:36:56 +0300 Subject: [PATCH] Fix WG --- .../ru/redguy/extendedpistons/WorldListener.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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; }