aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/level/block/DropperBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/DropperBlock.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/level/block/DropperBlock.java.patch131
1 files changed, 131 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/DropperBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/DropperBlock.java.patch
new file mode 100644
index 0000000000..792829fede
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/DropperBlock.java.patch
@@ -0,0 +1,131 @@
+--- a/net/minecraft/world/level/block/DropperBlock.java
++++ b/net/minecraft/world/level/block/DropperBlock.java
+@@ -4,75 +4,92 @@
+ import com.mojang.serialization.MapCodec;
+ import net.minecraft.core.BlockPos;
+ import net.minecraft.core.Direction;
+-import net.minecraft.core.dispenser.BlockSource;
+ import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
+ import net.minecraft.core.dispenser.DispenseItemBehavior;
++import net.minecraft.core.dispenser.SourceBlock;
+ import net.minecraft.server.level.ServerLevel;
++import net.minecraft.world.CompoundContainer;
+ import net.minecraft.world.Container;
+ import net.minecraft.world.item.ItemStack;
+ import net.minecraft.world.level.block.entity.BlockEntity;
+ import net.minecraft.world.level.block.entity.BlockEntityType;
+ import net.minecraft.world.level.block.entity.DispenserBlockEntity;
+-import net.minecraft.world.level.block.entity.DropperBlockEntity;
+ import net.minecraft.world.level.block.entity.HopperBlockEntity;
++import net.minecraft.world.level.block.entity.TileEntityDropper;
+ import net.minecraft.world.level.block.state.BlockBehaviour;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ 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
+- @Override
+ public MapCodec<DropperBlock> codec() {
+ return DropperBlock.CODEC;
+ }
+
+- public DropperBlock(BlockBehaviour.Properties blockbehaviour_properties) {
+- super(blockbehaviour_properties);
++ public DropperBlock(BlockBehaviour.Properties properties) {
++ super(properties);
+ }
+
+ @Override
+- @Override
+- protected DispenseItemBehavior getDispenseMethod(ItemStack itemstack) {
++ protected DispenseItemBehavior getDispenseMethod(ItemStack stack) {
+ return DropperBlock.DISPENSE_BEHAVIOUR;
+ }
+
+ @Override
+- @Override
+- public BlockEntity newBlockEntity(BlockPos blockpos, BlockState blockstate) {
+- return new DropperBlockEntity(blockpos, blockstate);
++ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) {
++ return new TileEntityDropper(pos, state);
+ }
+
+ @Override
+- @Override
+- protected void dispenseFrom(ServerLevel serverlevel, BlockState blockstate, BlockPos blockpos) {
+- DispenserBlockEntity dispenserblockentity = (DispenserBlockEntity) serverlevel.getBlockEntity(blockpos, BlockEntityType.DROPPER).orElse((Object) null);
++ public void dispenseFrom(ServerLevel worldserver, IBlockData iblockdata, BlockPos blockposition) {
++ DispenserBlockEntity tileentitydispenser = (DispenserBlockEntity) worldserver.getBlockEntity(blockposition, BlockEntityType.DROPPER).orElse(null); // CraftBukkit - decompile error
+
+- if (dispenserblockentity == null) {
+- DropperBlock.LOGGER.warn("Ignoring dispensing attempt for Dropper without matching block entity at {}", blockpos);
++ if (tileentitydispenser == null) {
++ DropperBlock.LOGGER.warn("Ignoring dispensing attempt for Dropper without matching block entity at {}", blockposition);
+ } else {
+- BlockSource blocksource = new BlockSource(serverlevel, blockpos, blockstate, dispenserblockentity);
+- int i = dispenserblockentity.getRandomSlot(serverlevel.random);
++ SourceBlock sourceblock = new SourceBlock(worldserver, blockposition, iblockdata, tileentitydispenser);
++ int i = tileentitydispenser.getRandomSlot(worldserver.random);
+
+ if (i < 0) {
+- serverlevel.levelEvent(1001, blockpos, 0);
++ worldserver.levelEvent(1001, blockposition, 0);
+ } else {
+- ItemStack itemstack = dispenserblockentity.getItem(i);
++ ItemStack itemstack = tileentitydispenser.getItem(i);
+
+ if (!itemstack.isEmpty()) {
+- Direction direction = (Direction) serverlevel.getBlockState(blockpos).getValue(DropperBlock.FACING);
+- Container container = HopperBlockEntity.getContainerAt(serverlevel, blockpos.relative(direction));
++ Direction enumdirection = (Direction) worldserver.getBlockState(blockposition).getValue(DropperBlock.FACING);
++ Container iinventory = HopperBlockEntity.getContainerAt(worldserver, blockposition.relative(enumdirection));
+ ItemStack itemstack1;
+
+- if (container == null) {
+- itemstack1 = DropperBlock.DISPENSE_BEHAVIOUR.dispense(blocksource, itemstack);
++ if (iinventory == null) {
++ itemstack1 = DropperBlock.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack);
+ } else {
+- itemstack1 = HopperBlockEntity.addItem(dispenserblockentity, container, itemstack.copy().split(1), direction.getOpposite());
+- if (itemstack1.isEmpty()) {
++ // 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 {
++ destinationInventory = iinventory.getOwner().getInventory();
++ }
++
++ 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 {
+@@ -80,7 +97,7 @@
+ }
+ }
+
+- dispenserblockentity.setItem(i, itemstack1);
++ tileentitydispenser.setItem(i, itemstack1);
+ }
+ }
+ }