3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Fix BlockDropItemEvent for Skulls and Shulker Boxes

Dieser Commit ist enthalten in:
md_5 2019-01-07 13:57:35 +11:00
Ursprung 5932f8a7da
Commit f17d591cc9

Datei anzeigen

@ -82,8 +82,8 @@
f = iblockdata.getDamage(this.player, this.player.world, blockposition); f = iblockdata.getDamage(this.player, this.player.world, blockposition);
+ // Allow fire punching to be blocked + // Allow fire punching to be blocked
+ this.world.douseFire((EntityHuman) null, blockposition, enumdirection); + this.world.douseFire((EntityHuman) null, blockposition, enumdirection);
+ } }
+
+ if (event.useItemInHand() == Event.Result.DENY) { + if (event.useItemInHand() == Event.Result.DENY) {
+ // If we 'insta destroyed' then the client needs to be informed. + // If we 'insta destroyed' then the client needs to be informed.
+ if (f > 1.0f) { + if (f > 1.0f) {
@ -97,8 +97,8 @@
+ // Let the client know the block still exists + // Let the client know the block still exists
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
+ return; + return;
} + }
+
+ if (blockEvent.getInstaBreak()) { + if (blockEvent.getInstaBreak()) {
+ f = 2.0f; + f = 2.0f;
+ } + }
@ -126,7 +126,7 @@
} }
} }
@@ -190,13 +252,88 @@ @@ -190,13 +252,97 @@
public boolean breakBlock(BlockPosition blockposition) { public boolean breakBlock(BlockPosition blockposition) {
IBlockData iblockdata = this.world.getType(blockposition); IBlockData iblockdata = this.world.getType(blockposition);
@ -180,7 +180,8 @@
+ for (EnumDirection dir : EnumDirection.values()) { + for (EnumDirection dir : EnumDirection.values()) {
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir))); + ((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 + // Update any tile entity data for this block
+ TileEntity tileentity = this.world.getTileEntity(blockposition); + TileEntity tileentity = this.world.getTileEntity(blockposition);
+ if (tileentity != null) { + if (tileentity != null) {
@ -190,8 +191,7 @@
+ } + }
+ } + }
+ // CraftBukkit end + // 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 + if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false
return false; return false;
} else { } else {
@ -201,22 +201,31 @@
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
+ // CraftBukkit start - Special case skulls, their item data comes from a tile entity (Also check if block should drop items) + // 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()) { + // 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<>();
+
+ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0); + 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);
+ }
+ }
+ } + }
+ +
+ // And shulker boxes too for duplication on cancel reasons (Also check if block should drop items) + world.captureDrops = null;
+ if (iblockdata.getBlock() instanceof BlockShulkerBox && event.isDropItems()) { + return flag;
+ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0);
+ return this.c(blockposition);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) { if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) {
this.world.notify(blockposition, iblockdata, iblockdata, 3); this.world.notify(blockposition, iblockdata, iblockdata, 3);
return false; return false;
@@ -221,6 +358,10 @@ @@ -221,6 +367,10 @@
} }
} }
@ -227,7 +236,7 @@
boolean flag = this.c(blockposition); boolean flag = this.c(blockposition);
if (!this.isCreative()) { if (!this.isCreative()) {
@@ -228,13 +369,31 @@ @@ -228,13 +378,31 @@
boolean flag1 = this.player.hasBlock(iblockdata); boolean flag1 = this.player.hasBlock(iblockdata);
itemstack1.a(this.world, iblockdata, blockposition, this.player); itemstack1.a(this.world, iblockdata, blockposition, this.player);
@ -260,7 +269,7 @@
return flag; return flag;
} }
} }
@@ -277,11 +436,40 @@ @@ -277,11 +445,40 @@
} }
} }
@ -301,7 +310,7 @@
if (tileentity instanceof ITileInventory) { if (tileentity instanceof ITileInventory) {
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
@@ -305,24 +493,26 @@ @@ -305,24 +502,26 @@
boolean flag = !entityhuman.getItemInMainHand().isEmpty() || !entityhuman.getItemInOffHand().isEmpty(); boolean flag = !entityhuman.getItemInMainHand().isEmpty() || !entityhuman.getItemInOffHand().isEmpty();
boolean flag1 = entityhuman.isSneaking() && flag; boolean flag1 = entityhuman.isSneaking() && flag;