diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/DropperBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/DropperBlock.java.patch | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/DropperBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/DropperBlock.java.patch new file mode 100644 index 0000000000..e7aa037c18 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/DropperBlock.java.patch @@ -0,0 +1,53 @@ +--- a/net/minecraft/world/level/block/DropperBlock.java ++++ b/net/minecraft/world/level/block/DropperBlock.java +@@ -18,11 +19,14 @@ + import net.minecraft.world.level.block.state.BlockBehaviour; + import net.minecraft.world.level.block.state.BlockState; + import org.slf4j.Logger; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.inventory.InventoryMoveItemEvent; ++// CraftBukkit end + + public class DropperBlock extends DispenserBlock { + private static final Logger LOGGER = LogUtils.getLogger(); + public static final MapCodec<DropperBlock> CODEC = simpleCodec(DropperBlock::new); +- private static final DispenseItemBehavior DISPENSE_BEHAVIOUR = new DefaultDispenseItemBehavior(); ++ private static final DispenseItemBehavior DISPENSE_BEHAVIOUR = new DefaultDispenseItemBehavior(true); // CraftBukkit + + @Override + public MapCodec<DropperBlock> codec() { +@@ -62,13 +71,30 @@ + if (containerAt == null) { + itemStack = DISPENSE_BEHAVIOUR.dispense(blockSource, item); + } else { +- itemStack = HopperBlockEntity.addItem(dispenserBlockEntity, containerAt, item.copy().split(1), direction.getOpposite()); +- if (itemStack.isEmpty()) { +- itemStack = item.copy(); +- itemStack.shrink(1); ++ // CraftBukkit start - Fire event when pushing items into other inventories ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.copy().split(1)); ++ ++ org.bukkit.inventory.Inventory destinationInventory; ++ // Have to special case large chests as they work oddly ++ if (iinventory instanceof CompoundContainer) { ++ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory); + } else { + itemStack = item.copy(); + } ++ ++ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); ++ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } ++ itemstack1 = HopperBlockEntity.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.getOpposite()); ++ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) { ++ // CraftBukkit end ++ itemstack1 = itemstack.copy(); ++ itemstack1.shrink(1); ++ } else { ++ itemstack1 = itemstack.copy(); ++ } + } + + dispenserBlockEntity.setItem(randomSlot, itemStack); |