Add support for preventing block drops in BreakEvent

This commit is contained in:
Scetra 2017-05-27 21:16:13 -04:00 committed by md_5
parent c037fe3d44
commit ccc420a957

View File

@ -194,14 +194,14 @@
TileEntity tileentity = this.world.getTileEntity(blockposition); TileEntity tileentity = this.world.getTileEntity(blockposition);
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
+ // CraftBukkit start - Special case skulls, their item data comes from a tile entity + // 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()) { + if (iblockdata.getBlock() == Blocks.SKULL && !this.isCreative() && event.isDropItems()) {
+ iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0); + iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0);
+ return this.c(blockposition); + return this.c(blockposition);
+ } + }
+ +
+ // And shulker boxes too for duplication on cancel reasons + // And shulker boxes too for duplication on cancel reasons (Also check if block should drop items)
+ if (iblockdata.getBlock() instanceof BlockShulkerBox) { + if (iblockdata.getBlock() instanceof BlockShulkerBox && event.isDropItems()) {
+ iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0); + iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0);
+ return this.c(blockposition); + return this.c(blockposition);
+ } + }
@ -210,20 +210,27 @@
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;
@@ -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 + // CraftBukkit start - Drop event experience
+ if (flag && event != null) { + if (flag && event != null) {
+ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop()); + iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop());
+ } }
+ // CraftBukkit end + // CraftBukkit end
+
return flag; return flag;
} }
} @@ -278,63 +419,90 @@
@@ -278,63 +417,90 @@
} }
} }