mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
[Bleeding] Use player.getItemInHand(), instead of a new ItemStack. Addresses BUKKIT-767
By: Feildmaster <admin@feildmaster.com>
This commit is contained in:
parent
2beeb597e3
commit
4122f831fb
1 changed files with 2 additions and 11 deletions
|
@ -64,27 +64,18 @@ public class CraftEventFactory {
|
|||
/**
|
||||
* Block place methods
|
||||
*/
|
||||
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, int type) {
|
||||
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) {
|
||||
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) {
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer craftServer = ((WorldServer) world).getServer();
|
||||
|
||||
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
|
||||
Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
|
||||
Block placedBlock = replacedBlockState.getBlock();
|
||||
|
||||
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);
|
||||
|
||||
return event;
|
||||
|
|
Loading…
Reference in a new issue