Added left click support to /repl to pick up the block.

This commit is contained in:
sk89q 2011-04-25 02:05:58 -07:00
parent 47268bef20
commit 3ffd67e7f3

View File

@ -22,13 +22,14 @@ package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.bags.BlockBag; import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockType;
/** /**
* A mode that replaces one block. * A mode that replaces one block.
* *
* @author sk89q * @author sk89q
*/ */
public class BlockReplacer implements BlockTool { public class BlockReplacer implements DoubleActionBlockTool {
private BaseBlock targetBlock; private BaseBlock targetBlock;
public BlockReplacer(BaseBlock targetBlock) { public BlockReplacer(BaseBlock targetBlock) {
@ -57,4 +58,20 @@ public class BlockReplacer implements BlockTool {
return true; 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;
}
} }