From 43f9acb69098025bb2085dd4431a9ac9cee21fb8 Mon Sep 17 00:00:00 2001 From: sk89q Date: Wed, 19 Jan 2011 02:43:26 -0800 Subject: [PATCH] Added the navigation wand. --- src/com/sk89q/worldedit/LocalConfiguration.java | 2 ++ src/com/sk89q/worldedit/WorldEditController.java | 8 ++++++++ src/com/sk89q/worldedit/bukkit/BukkitConfiguration.java | 2 ++ 3 files changed, 12 insertions(+) diff --git a/src/com/sk89q/worldedit/LocalConfiguration.java b/src/com/sk89q/worldedit/LocalConfiguration.java index a40ec35ac..ca65fa785 100644 --- a/src/com/sk89q/worldedit/LocalConfiguration.java +++ b/src/com/sk89q/worldedit/LocalConfiguration.java @@ -52,6 +52,8 @@ public abstract class LocalConfiguration { public boolean noDoubleSlash = false; public boolean useInventory = false; public boolean useInventoryOverride = false; + public int navigationWand = 345; + public int navigationWandMaxDistance = 50; /** * Loads the configuration. diff --git a/src/com/sk89q/worldedit/WorldEditController.java b/src/com/sk89q/worldedit/WorldEditController.java index 34ca9d685..25b853c6d 100644 --- a/src/com/sk89q/worldedit/WorldEditController.java +++ b/src/com/sk89q/worldedit/WorldEditController.java @@ -1913,6 +1913,14 @@ public class WorldEditController { player, session, null); return true; } + } else if (player.getItemInHand() == config.navigationWand + && config.navigationWandMaxDistance > 0) { + WorldVector pos = player.getSolidBlockTrace(config.navigationWandMaxDistance); + if (pos != null) { + player.findFreePosition(pos); + } else { + player.printError("No block in sight (or too far)!"); + } } return false; diff --git a/src/com/sk89q/worldedit/bukkit/BukkitConfiguration.java b/src/com/sk89q/worldedit/bukkit/BukkitConfiguration.java index cefda3658..5b7bdac34 100644 --- a/src/com/sk89q/worldedit/bukkit/BukkitConfiguration.java +++ b/src/com/sk89q/worldedit/bukkit/BukkitConfiguration.java @@ -61,6 +61,8 @@ public class BukkitConfiguration extends LocalConfiguration { useInventoryOverride = config.getBoolean("use-inventory.allow-override", useInventoryOverride); maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius); + navigationWand = config.getInt("navigation-wand-item", navigationWand); + navigationWandMaxDistance = config.getInt("navigation-wand-max-distance", navigationWandMaxDistance); disallowedBlocks = new HashSet(config.getIntList("limits.disallowed-blocks", null));