From ddcf9489742b39f7dbb470117459d110a5f16913 Mon Sep 17 00:00:00 2001 From: hretsam Date: Wed, 10 Aug 2011 21:02:02 +0200 Subject: [PATCH] Fixed issue #376 "right-clicking with a compass on a door is treated if the door was not there and the left mousebutton was clicked." Also when you use the compass for jumpto/thru it wont interact with items anymore. --- .../java/com/sk89q/worldedit/LocalSession.java | 17 +++++++++++++++++ .../java/com/sk89q/worldedit/WorldEdit.java | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/LocalSession.java b/src/main/java/com/sk89q/worldedit/LocalSession.java index eb2e41cde..79ae249a0 100644 --- a/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -77,6 +77,7 @@ public class LocalSession { private boolean fastMode = false; private Mask mask; private TimeZone timezone = TimeZone.getDefault(); + private Boolean jumptoBlock = true; /** * Construct the object. @@ -702,4 +703,20 @@ public class LocalSession { public void setMask(Mask mask) { this.mask = mask; } + + /** + * This is used as a workaround for a bug. + * It blocks the compass from using the jumpto function after the thru function + */ + public void toggleJumptoBlock() { + this.jumptoBlock = !jumptoBlock; + } + + /** + * This is used as a workaround for a bug. + * @return true if the compass's jumpto function can be used again + */ + public Boolean canUseJumpto() { + return jumptoBlock; + } } diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 9b52981f0..090d9d7ad 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -43,6 +43,7 @@ import com.sk89q.worldedit.scripting.*; import com.sk89q.worldedit.tools.*; import com.sk89q.worldedit.masks.*; import com.sk89q.worldedit.patterns.*; +import com.sk89q.worldedit.util.TargetBlock; /** * This class is the main entry point for WorldEdit. All events are routed @@ -946,12 +947,19 @@ public class WorldEdit { if (player.getItemInHand() == config.navigationWand && config.navigationWandMaxDistance > 0 && player.hasPermission("worldedit.navigation.jumpto")) { - WorldVector pos = player.getSolidBlockTrace(config.navigationWandMaxDistance); + // Bug workaround + // Blocks this from being used after the thru function + if (!session.canUseJumpto()){ + session.toggleJumptoBlock(); + return false; + } + WorldVector pos = player.getSolidBlockTrace(config.navigationWandMaxDistance); if (pos != null) { player.findFreePosition(pos); } else { player.printError("No block in sight (or too far)!"); } + return true; } Tool tool = session.getTool(player.getItemInHand()); @@ -980,6 +988,11 @@ public class WorldEdit { if (!player.passThroughForwardWall(40)) { player.printError("Nothing to pass through!"); } + // Bug workaround, so it wont do the Jumpto compass function + // Right after this teleport + if (session.canUseJumpto()) + session.toggleJumptoBlock(); + return true; } Tool tool = session.getTool(player.getItemInHand());