2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/level/block/BlockDropper.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockDropper.java
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -15,6 +15,12 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.block.state.BlockBase;
|
2021-06-11 07:00:00 +02:00
|
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2021-03-15 23:00:00 +01:00
|
|
|
+import net.minecraft.world.InventoryLargeChest;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
|
|
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
|
|
|
+// CraftBukkit end
|
2016-11-17 02:41:03 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public class BlockDropper extends BlockDispenser {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private static final IDispenseBehavior DISPENSE_BEHAVIOUR = new DispenseBehaviorItem();
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -52,8 +58,25 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
if (iinventory == null) {
|
2021-06-11 07:00:00 +02:00
|
|
|
itemstack1 = BlockDropper.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack);
|
2018-07-15 02:00:00 +02:00
|
|
|
} else {
|
2021-11-21 23:00:00 +01:00
|
|
|
- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.copy().split(1), enumdirection.getOpposite());
|
2018-07-15 02:00:00 +02:00
|
|
|
- if (itemstack1.isEmpty()) {
|
|
|
|
+ // CraftBukkit start - Fire event when pushing items into other inventories
|
2021-11-21 23:00:00 +01:00
|
|
|
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.copy().split(1));
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ 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();
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2021-11-21 23:00:00 +01:00
|
|
|
+ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.getOpposite());
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) {
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
itemstack1 = itemstack.copy();
|
|
|
|
itemstack1.shrink(1);
|
2018-07-15 02:00:00 +02:00
|
|
|
} else {
|