mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 12:02:36 +01:00
b3a8254758
By: md_5 <git@md-5.net>
43 lines
2.5 KiB
Diff
43 lines
2.5 KiB
Diff
--- a/net/minecraft/world/level/block/BlockDropper.java
|
|
+++ b/net/minecraft/world/level/block/BlockDropper.java
|
|
@@ -16,6 +16,12 @@
|
|
import net.minecraft.world.level.block.state.BlockBase;
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
|
|
+// CraftBukkit start
|
|
+import net.minecraft.world.InventoryLargeChest;
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class BlockDropper extends BlockDispenser {
|
|
|
|
private static final IDispenseBehavior DISPENSE_BEHAVIOUR = new DispenseBehaviorItem();
|
|
@@ -53,8 +59,25 @@
|
|
if (iinventory == null) {
|
|
itemstack1 = BlockDropper.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack);
|
|
} else {
|
|
- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite());
|
|
- if (itemstack1.isEmpty()) {
|
|
+ // CraftBukkit start - Fire event when pushing items into other inventories
|
|
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1));
|
|
+
|
|
+ org.bukkit.inventory.Inventory destinationInventory;
|
|
+ // Have to special case large chests as they work oddly
|
|
+ if (iinventory instanceof InventoryLargeChest) {
|
|
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
|
|
+ } else {
|
|
+ destinationInventory = iinventory.getOwner().getInventory();
|
|
+ }
|
|
+
|
|
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
|
|
+ worldserver.getServer().getPluginManager().callEvent(event);
|
|
+ if (event.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
|
|
+ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) {
|
|
+ // CraftBukkit end
|
|
itemstack1 = itemstack.cloneItemStack();
|
|
itemstack1.subtract(1);
|
|
} else {
|