From 3ffd67e7f3ee4780466d32b813ebc6230fa3b45e Mon Sep 17 00:00:00 2001 From: sk89q Date: Mon, 25 Apr 2011 02:05:58 -0700 Subject: [PATCH] Added left click support to /repl to pick up the block. --- .../sk89q/worldedit/tools/BlockReplacer.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/com/sk89q/worldedit/tools/BlockReplacer.java b/src/com/sk89q/worldedit/tools/BlockReplacer.java index 1aba1c0a5..83ae422e2 100644 --- a/src/com/sk89q/worldedit/tools/BlockReplacer.java +++ b/src/com/sk89q/worldedit/tools/BlockReplacer.java @@ -22,13 +22,14 @@ package com.sk89q.worldedit.tools; import com.sk89q.worldedit.*; import com.sk89q.worldedit.bags.BlockBag; import com.sk89q.worldedit.blocks.BaseBlock; +import com.sk89q.worldedit.blocks.BlockType; /** * A mode that replaces one block. * * @author sk89q */ -public class BlockReplacer implements BlockTool { +public class BlockReplacer implements DoubleActionBlockTool { private BaseBlock targetBlock; public BlockReplacer(BaseBlock targetBlock) { @@ -57,4 +58,20 @@ public class BlockReplacer implements BlockTool { return true; } + @Override + public boolean actSecondary(ServerInterface server, + LocalConfiguration config, LocalPlayer player, + LocalSession session, WorldVector clicked) { + + LocalWorld world = clicked.getWorld(); + targetBlock = (new EditSession(world, -1)).getBlock(clicked); + BlockType type = BlockType.fromID(targetBlock.getType()); + + if (type != null) { + player.print("Replacer tool switched to: " + type.getName()); + } + + return true; + } + }