mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
SPIGOT-5936: BlockPlaceEvent does not fire for lily_pad
This commit is contained in:
parent
145921e2a6
commit
b6a876bc34
1 changed files with 33 additions and 4 deletions
|
@ -12,7 +12,36 @@
|
|||
|
||||
public class ItemBlock extends Item {
|
||||
|
||||
@@ -55,7 +60,7 @@
|
||||
@@ -31,6 +36,12 @@
|
||||
return EnumInteractionResult.FAIL;
|
||||
} else {
|
||||
IBlockData iblockdata = this.c(blockactioncontext1);
|
||||
+ // CraftBukkit start - special case for handling block placement with water lilies
|
||||
+ org.bukkit.block.BlockState blockstate = null;
|
||||
+ if (this instanceof ItemWaterLily) {
|
||||
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(blockactioncontext1.getWorld(), blockactioncontext1.getClickPosition());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (iblockdata == null) {
|
||||
return EnumInteractionResult.FAIL;
|
||||
@@ -48,6 +59,15 @@
|
||||
iblockdata1 = this.a(blockposition, world, itemstack, iblockdata1);
|
||||
this.a(blockposition, world, entityhuman, itemstack, iblockdata1);
|
||||
block.postPlace(world, blockposition, iblockdata1, entityhuman, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ if (blockstate != null) {
|
||||
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent((WorldServer) world, entityhuman, blockactioncontext1.getHand(), blockstate, blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
|
||||
+ blockstate.update(true, false);
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition, itemstack);
|
||||
}
|
||||
@@ -55,7 +75,7 @@
|
||||
|
||||
SoundEffectType soundeffecttype = iblockdata1.getStepSound();
|
||||
|
||||
|
@ -21,7 +50,7 @@
|
|||
if (entityhuman == null || !entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
@@ -92,6 +97,21 @@
|
||||
@@ -92,6 +112,21 @@
|
||||
|
||||
if (nbttagcompound != null) {
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag");
|
||||
|
@ -43,7 +72,7 @@
|
|||
BlockStateList<Block, IBlockData> blockstatelist = iblockdata.getBlock().getStates();
|
||||
Iterator iterator = nbttagcompound1.getKeys().iterator();
|
||||
|
||||
@@ -106,11 +126,6 @@
|
||||
@@ -106,11 +141,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +84,7 @@
|
|||
return iblockdata1;
|
||||
}
|
||||
|
||||
@@ -123,8 +138,15 @@
|
||||
@@ -123,8 +153,15 @@
|
||||
protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
||||
EntityHuman entityhuman = blockactioncontext.getEntity();
|
||||
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman);
|
||||
|
|
Loading…
Reference in a new issue