From 1b9445b6f2b14a974f88d91a1c16a44bfd39cd3f Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 24 Nov 2013 16:54:01 +0100 Subject: [PATCH] Added a "pos1" pseudo block type, which uses the block type from the "primary position". --- src/main/java/com/sk89q/worldedit/WorldEdit.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 3f1f2a751..c5fe05436 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -404,6 +404,18 @@ public class WorldEdit { return blockInHand; } + blockId = blockInHand.getId(); + blockType = BlockType.fromID(blockId); + data = blockInHand.getData(); + } else if ("pos1".equalsIgnoreCase(testID)) { + // Get the block type from the "primary position" + final LocalWorld world = player.getWorld(); + final BlockVector primaryPosition = getSession(player).getRegionSelector(world).getPrimaryPosition(); + final BaseBlock blockInHand = world.getBlock(primaryPosition); + if (blockInHand.getClass() != BaseBlock.class) { + return blockInHand; + } + blockId = blockInHand.getId(); blockType = BlockType.fromID(blockId); data = blockInHand.getData();