mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 06:50:12 +01:00
Fix BlockDropItemEvent for Skulls and Shulker Boxes
This commit is contained in:
parent
5932f8a7da
commit
f17d591cc9
1 changed files with 28 additions and 19 deletions
|
@ -82,8 +82,8 @@
|
|||
f = iblockdata.getDamage(this.player, this.player.world, blockposition);
|
||||
+ // Allow fire punching to be blocked
|
||||
+ this.world.douseFire((EntityHuman) null, blockposition, enumdirection);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ if (event.useItemInHand() == Event.Result.DENY) {
|
||||
+ // If we 'insta destroyed' then the client needs to be informed.
|
||||
+ if (f > 1.0f) {
|
||||
|
@ -97,8 +97,8 @@
|
|||
+ // Let the client know the block still exists
|
||||
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ return;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ if (blockEvent.getInstaBreak()) {
|
||||
+ f = 2.0f;
|
||||
+ }
|
||||
|
@ -126,7 +126,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -190,13 +252,88 @@
|
||||
@@ -190,13 +252,97 @@
|
||||
|
||||
public boolean breakBlock(BlockPosition blockposition) {
|
||||
IBlockData iblockdata = this.world.getType(blockposition);
|
||||
|
@ -180,7 +180,8 @@
|
|||
+ for (EnumDirection dir : EnumDirection.values()) {
|
||||
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir)));
|
||||
+ }
|
||||
+
|
||||
|
||||
- if (!this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) {
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = this.world.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
|
@ -190,8 +191,7 @@
|
|||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
- if (!this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) {
|
||||
+
|
||||
+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false
|
||||
return false;
|
||||
} else {
|
||||
|
@ -201,22 +201,31 @@
|
|||
Block block = iblockdata.getBlock();
|
||||
|
||||
+ // CraftBukkit start - Special case skulls, their item data comes from a tile entity (Also check if block should drop items)
|
||||
+ if (iblockdata.getBlock() instanceof BlockSkullAbstract && !this.isCreative() && event.isDropItems()) {
|
||||
+ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0);
|
||||
+ return this.c(blockposition);
|
||||
+ }
|
||||
+ // And shulker boxes too for duplication on BlockPlaceEvent cancel reasons (Also check if block should drop items)
|
||||
+ if ((iblockdata.getBlock() instanceof BlockSkullAbstract || iblockdata.getBlock() instanceof BlockShulkerBox) && !this.isCreative() && event.isDropItems()) {
|
||||
+ org.bukkit.block.BlockState state = bblock.getState();
|
||||
+ world.captureDrops = new ArrayList<>();
|
||||
+
|
||||
+ // And shulker boxes too for duplication on cancel reasons (Also check if block should drop items)
|
||||
+ if (iblockdata.getBlock() instanceof BlockShulkerBox && event.isDropItems()) {
|
||||
+ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0);
|
||||
+ return this.c(blockposition);
|
||||
+ boolean flag = this.c(blockposition);
|
||||
+
|
||||
+ if (event.isDropItems()) {
|
||||
+ for (EntityItem item : world.captureDrops) {
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropItemEvent(bblock, state, this.player, item).isCancelled()) {
|
||||
+ world.addEntity(item);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ world.captureDrops = null;
|
||||
+ return flag;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) {
|
||||
this.world.notify(blockposition, iblockdata, iblockdata, 3);
|
||||
return false;
|
||||
@@ -221,6 +358,10 @@
|
||||
@@ -221,6 +367,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +236,7 @@
|
|||
boolean flag = this.c(blockposition);
|
||||
|
||||
if (!this.isCreative()) {
|
||||
@@ -228,13 +369,31 @@
|
||||
@@ -228,13 +378,31 @@
|
||||
boolean flag1 = this.player.hasBlock(iblockdata);
|
||||
|
||||
itemstack1.a(this.world, iblockdata, blockposition, this.player);
|
||||
|
@ -260,7 +269,7 @@
|
|||
return flag;
|
||||
}
|
||||
}
|
||||
@@ -277,11 +436,40 @@
|
||||
@@ -277,11 +445,40 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +310,7 @@
|
|||
|
||||
if (tileentity instanceof ITileInventory) {
|
||||
Block block = iblockdata.getBlock();
|
||||
@@ -305,24 +493,26 @@
|
||||
@@ -305,24 +502,26 @@
|
||||
boolean flag = !entityhuman.getItemInMainHand().isEmpty() || !entityhuman.getItemInOffHand().isEmpty();
|
||||
boolean flag1 = entityhuman.isSneaking() && flag;
|
||||
|
||||
|
|
Loading…
Reference in a new issue