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