From b0330aa83cae97595b2c71e73e58c42acf662dc8 Mon Sep 17 00:00:00 2001 From: sk89q Date: Wed, 10 Nov 2010 01:54:07 -0800 Subject: [PATCH] Fixed /jumpto and the help for //expand and //contract. --- src/WorldEditListener.java | 6 +++--- src/WorldEditPlayer.java | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/WorldEditListener.java b/src/WorldEditListener.java index c4bd6499d..ce2224583 100644 --- a/src/WorldEditListener.java +++ b/src/WorldEditListener.java @@ -157,8 +157,8 @@ public class WorldEditListener extends PluginListener { commands.put("//limit", "[Num] - See documentation"); commands.put("//mode", "[Mode] - Set super pickaxe mode (single/recursive/area)"); commands.put("//tool", "[Tool] - Set pickaxe tool (none/tree)"); - commands.put("//expand", " [Num] - Expands the selection"); - commands.put("//contract", " [Num] - Contracts the selection"); + commands.put("//expand", "[Num] - Expands the selection"); + commands.put("//contract", "[Num] - Contracts the selection"); commands.put("//rotate", "[Angle] - Rotate the clipboard"); commands.put("//hcyl", "[ID] [Radius] - Create a vertical hollow cylinder"); commands.put("//cyl", "[ID] [Radius] - Create a vertical cylinder"); @@ -429,7 +429,7 @@ public class WorldEditListener extends PluginListener { // Jump to the block in sight } else if (split[0].equalsIgnoreCase("/jumpto")) { checkArgs(split, 0, 0, split[0]); - Vector pos = player.getBlockTrace(300); + Vector pos = player.getSolidBlockTrace(300); if (pos != null) { player.findFreePosition(pos); player.print("Poof!"); diff --git a/src/WorldEditPlayer.java b/src/WorldEditPlayer.java index 53516fe73..e35c6c6e4 100644 --- a/src/WorldEditPlayer.java +++ b/src/WorldEditPlayer.java @@ -315,6 +315,27 @@ public class WorldEditPlayer { return new Vector(block.getX(), block.getY(), block.getZ()); } + /** + * Get the point of the block being looked at. May return null. + * + * @param range + * @return point + */ + public Vector getSolidBlockTrace(int range) { + HitBlox hitBlox = new HitBlox(player, range, 0.2); + Block block = null; + + while (hitBlox.getNextBlock() != null + && BlockType.canPassThrough(hitBlox.getCurBlock().getType())); + + block = hitBlox.getCurBlock(); + + if (block == null) { + return null; + } + return new Vector(block.getX(), block.getY(), block.getZ()); + } + /** * Get the player's cardinal direction (N, W, NW, etc.). *