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.
This commit is contained in:
hretsam 2011-08-10 21:02:02 +02:00 committed by Wizjany
parent 5e45fd1625
commit ddcf948974
2 changed files with 31 additions and 1 deletions

View File

@ -77,6 +77,7 @@ public class LocalSession {
private boolean fastMode = false; private boolean fastMode = false;
private Mask mask; private Mask mask;
private TimeZone timezone = TimeZone.getDefault(); private TimeZone timezone = TimeZone.getDefault();
private Boolean jumptoBlock = true;
/** /**
* Construct the object. * Construct the object.
@ -702,4 +703,20 @@ public Mask getMask() {
public void setMask(Mask mask) { public void setMask(Mask mask) {
this.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;
}
} }

View File

@ -43,6 +43,7 @@
import com.sk89q.worldedit.tools.*; import com.sk89q.worldedit.tools.*;
import com.sk89q.worldedit.masks.*; import com.sk89q.worldedit.masks.*;
import com.sk89q.worldedit.patterns.*; import com.sk89q.worldedit.patterns.*;
import com.sk89q.worldedit.util.TargetBlock;
/** /**
* This class is the main entry point for WorldEdit. All events are routed * This class is the main entry point for WorldEdit. All events are routed
@ -946,12 +947,19 @@ public boolean handleArmSwing(LocalPlayer player) {
if (player.getItemInHand() == config.navigationWand if (player.getItemInHand() == config.navigationWand
&& config.navigationWandMaxDistance > 0 && config.navigationWandMaxDistance > 0
&& player.hasPermission("worldedit.navigation.jumpto")) { && 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) { if (pos != null) {
player.findFreePosition(pos); player.findFreePosition(pos);
} else { } else {
player.printError("No block in sight (or too far)!"); player.printError("No block in sight (or too far)!");
} }
return true;
} }
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player.getItemInHand());
@ -980,6 +988,11 @@ public boolean handleRightClick(LocalPlayer player) {
if (!player.passThroughForwardWall(40)) { if (!player.passThroughForwardWall(40)) {
player.printError("Nothing to pass through!"); 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()); Tool tool = session.getTool(player.getItemInHand());