[Bleeding] Use player.getItemInHand(), instead of a new ItemStack. Addresses BUKKIT-767

By: Feildmaster <admin@feildmaster.com>
This commit is contained in:
CraftBukkit/Spigot 2012-02-18 09:14:44 -06:00
parent 2beeb597e3
commit 4122f831fb

View file

@ -64,27 +64,18 @@ public class CraftEventFactory {
/** /**
* Block place methods * Block place methods
*/ */
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, int type) { public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) {
return callBlockPlaceEvent(world, who, replacedBlockState, clickedX, clickedY, clickedZ, net.minecraft.server.Block.byId[type]);
}
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, net.minecraft.server.Block block) {
return callBlockPlaceEvent(world, who, replacedBlockState, clickedX, clickedY, clickedZ, new ItemStack(block));
}
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, ItemStack itemstack) {
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer(); CraftServer craftServer = ((WorldServer) world).getServer();
Player player = (who == null) ? null : (Player) who.getBukkitEntity(); Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(itemstack);
Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ); Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
Block placedBlock = replacedBlockState.getBlock(); Block placedBlock = replacedBlockState.getBlock();
boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ()); boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ());
BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, itemInHand, player, canBuild); BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, player.getItemInHand(), player, canBuild);
craftServer.getPluginManager().callEvent(event); craftServer.getPluginManager().callEvent(event);
return event; return event;