Extend block drop capture to capture all items added to the world

This commit is contained in:
Shane Freeder
2020-09-17 00:36:05 +01:00
parent a4cc307c2b
commit af1fabed04
2 changed files with 42 additions and 34 deletions

View File

@@ -110,9 +110,9 @@
+ this.player.connection.send(tileentity.getUpdatePacket());
+ }
+ // CraftBukkit end
+ return;
+ }
+
return;
}
+ // CraftBukkit start
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
+ if (event.isCancelled()) {
@@ -123,10 +123,10 @@
+ if (tileentity != null) {
+ this.player.connection.send(tileentity.getUpdatePacket());
+ }
return;
}
+ return;
+ }
+ // CraftBukkit end
+
if (this.isCreative()) {
this.destroyAndAck(pos, sequence, "creative destroy");
return;
@@ -295,7 +295,7 @@
BlockState iblockdata1 = block.playerWillDestroy(this.level, pos, iblockdata, this.player);
boolean flag = this.level.removeBlock(pos, false);
@@ -263,19 +421,32 @@
@@ -263,19 +421,34 @@
}
if (this.isCreative()) {
@@ -316,10 +316,12 @@
+ // return true; // CraftBukkit
}
+ // CraftBukkit start
+ java.util.List<net.minecraft.world.entity.item.ItemEntity> itemsToDrop = this.level.captureDrops; // Paper - capture all item additions to the world
+ this.level.captureDrops = null; // Paper - capture all item additions to the world; Remove this earlier so that we can actually drop stuff
+ if (event.isDropItems()) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, this.level.captureDrops);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - capture all item additions to the world
+ }
+ this.level.captureDrops = null;
+ //this.level.captureDrops = null; // Paper - capture all item additions to the world; move up
+
+ // Drop event experience
+ if (flag && event != null) {
@@ -331,7 +333,7 @@
}
}
}
@@ -321,15 +492,58 @@
@@ -321,15 +494,58 @@
}
}
@@ -390,7 +392,7 @@
if (itileinventory != null) {
player.openMenu(itileinventory);
return InteractionResult.CONSUME;
@@ -359,7 +573,7 @@
@@ -359,7 +575,7 @@
}
}