mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
Add support for preventing block drops in BreakEvent
This commit is contained in:
parent
c037fe3d44
commit
ccc420a957
@ -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 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user