From ccc420a95706d3fca88e8f6ea11fed76a3d6bad3 Mon Sep 17 00:00:00 2001 From: Scetra Date: Sat, 27 May 2017 21:16:13 -0400 Subject: Add support for preventing block drops in BreakEvent --- nms-patches/PlayerInteractManager.patch | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'nms-patches') diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch index 7362bf4a..f140fbe1 100644 --- a/nms-patches/PlayerInteractManager.patch +++ b/nms-patches/PlayerInteractManager.patch @@ -194,14 +194,14 @@ TileEntity tileentity = this.world.getTileEntity(blockposition); Block block = iblockdata.getBlock(); -+ // CraftBukkit start - Special case skulls, their item data comes from a tile entity -+ if (iblockdata.getBlock() == Blocks.SKULL && !this.isCreative()) { ++ // CraftBukkit start - Special case skulls, their item data comes from a tile entity (Also check if block should drop items) ++ if (iblockdata.getBlock() == Blocks.SKULL && !this.isCreative() && event.isDropItems()) { + iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0); + return this.c(blockposition); + } + -+ // And shulker boxes too for duplication on cancel reasons -+ if (iblockdata.getBlock() instanceof BlockShulkerBox) { ++ // 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(world, blockposition, iblockdata, 1.0F, 0); + return this.c(blockposition); + } @@ -210,20 +210,27 @@ if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) { this.world.notify(blockposition, iblockdata, iblockdata, 3); return false; -@@ -236,6 +369,12 @@ +@@ -231,10 +364,18 @@ + itemstack1.a(this.world, iblockdata, blockposition, this.player); } - } +- if (flag && flag1) { ++ // CraftBukkit start - Check if block should drop items ++ if (flag && flag1 && event.isDropItems()) { + iblockdata.getBlock().a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack2); + } ++ // CraftBukkit end ++ } ++ + // CraftBukkit start - Drop event experience + if (flag && event != null) { + iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop()); -+ } + } + // CraftBukkit end -+ + return flag; } - } -@@ -278,63 +417,90 @@ +@@ -278,63 +419,90 @@ } } -- cgit v1.2.3