diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/DispenserBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/DispenserBlock.java.patch | 268 |
1 files changed, 268 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/DispenserBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/DispenserBlock.java.patch new file mode 100644 index 0000000000..5deb28528d --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/DispenserBlock.java.patch @@ -0,0 +1,268 @@ +--- a/net/minecraft/world/level/block/DispenserBlock.java ++++ b/net/minecraft/world/level/block/DispenserBlock.java +@@ -7,15 +7,15 @@ + import net.minecraft.Util; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; +-import net.minecraft.core.Position; +-import net.minecraft.core.dispenser.BlockSource; ++import net.minecraft.core.IPosition; + 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.stats.Stats; + import net.minecraft.util.RandomSource; + import net.minecraft.world.Containers; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.player.Player; +@@ -23,14 +23,14 @@ + import net.minecraft.world.item.Item; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.context.BlockPlaceContext; +-import net.minecraft.world.level.ItemLike; ++import net.minecraft.world.level.IMaterial; + import net.minecraft.world.level.Level; + 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.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 net.minecraft.world.level.block.state.StateDefinition; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.BooleanProperty; +@@ -43,39 +43,38 @@ + + private static final Logger LOGGER = LogUtils.getLogger(); + public static final MapCodec<DispenserBlock> CODEC = simpleCodec(DispenserBlock::new); +- public static final DirectionProperty FACING = DirectionalBlock.FACING; ++ public static final DirectionProperty FACING = BlockDirectional.FACING; + public static final BooleanProperty TRIGGERED = BlockStateProperties.TRIGGERED; +- private static final Map<Item, DispenseItemBehavior> DISPENSER_REGISTRY = (Map) Util.make(new Object2ObjectOpenHashMap(), (object2objectopenhashmap) -> { ++ public static final Map<Item, DispenseItemBehavior> DISPENSER_REGISTRY = (Map) Util.make(new Object2ObjectOpenHashMap(), (object2objectopenhashmap) -> { + object2objectopenhashmap.defaultReturnValue(new DefaultDispenseItemBehavior()); + }); + private static final int TRIGGER_DURATION = 4; ++ public static boolean eventFired = false; // CraftBukkit + + @Override +- @Override + public MapCodec<? extends DispenserBlock> codec() { + return DispenserBlock.CODEC; + } + +- public static void registerBehavior(ItemLike itemlike, DispenseItemBehavior dispenseitembehavior) { +- DispenserBlock.DISPENSER_REGISTRY.put(itemlike.asItem(), dispenseitembehavior); ++ public static void registerBehavior(IMaterial item, DispenseItemBehavior behavior) { ++ DispenserBlock.DISPENSER_REGISTRY.put(item.asItem(), behavior); + } + +- protected DispenserBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(DispenserBlock.FACING, Direction.NORTH)).setValue(DispenserBlock.TRIGGERED, false)); ++ protected DispenserBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(DispenserBlock.FACING, Direction.NORTH)).setValue(DispenserBlock.TRIGGERED, false)); + } + + @Override +- @Override +- public InteractionResult use(BlockState blockstate, Level level, BlockPos blockpos, Player player, InteractionHand interactionhand, BlockHitResult blockhitresult) { ++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) { + if (level.isClientSide) { + return InteractionResult.SUCCESS; + } else { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof DispenserBlockEntity) { +- player.openMenu((DispenserBlockEntity) blockentity); +- if (blockentity instanceof DropperBlockEntity) { ++ if (tileentity instanceof DispenserBlockEntity) { ++ player.openMenu((DispenserBlockEntity) tileentity); ++ if (tileentity instanceof TileEntityDropper) { + player.awardStat(Stats.INSPECT_DROPPER); + } else { + player.awardStat(Stats.INSPECT_DISPENSER); +@@ -86,126 +85,115 @@ + } + } + +- protected void dispenseFrom(ServerLevel serverlevel, BlockState blockstate, BlockPos blockpos) { +- DispenserBlockEntity dispenserblockentity = (DispenserBlockEntity) serverlevel.getBlockEntity(blockpos, BlockEntityType.DISPENSER).orElse((Object) null); ++ public void dispenseFrom(ServerLevel worldserver, IBlockData iblockdata, BlockPos blockposition) { ++ DispenserBlockEntity tileentitydispenser = (DispenserBlockEntity) worldserver.getBlockEntity(blockposition, BlockEntityType.DISPENSER).orElse(null); // CraftBukkit - decompile error + +- if (dispenserblockentity == null) { +- DispenserBlock.LOGGER.warn("Ignoring dispensing attempt for Dispenser without matching block entity at {}", blockpos); ++ if (tileentitydispenser == null) { ++ DispenserBlock.LOGGER.warn("Ignoring dispensing attempt for Dispenser 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); +- serverlevel.gameEvent(GameEvent.BLOCK_ACTIVATE, blockpos, GameEvent.Context.of(dispenserblockentity.getBlockState())); ++ worldserver.levelEvent(1001, blockposition, 0); ++ worldserver.gameEvent(GameEvent.BLOCK_ACTIVATE, blockposition, GameEvent.Context.of(tileentitydispenser.getBlockState())); + } else { +- ItemStack itemstack = dispenserblockentity.getItem(i); +- DispenseItemBehavior dispenseitembehavior = this.getDispenseMethod(itemstack); ++ ItemStack itemstack = tileentitydispenser.getItem(i); ++ DispenseItemBehavior idispensebehavior = this.getDispenseMethod(itemstack); + +- if (dispenseitembehavior != DispenseItemBehavior.NOOP) { +- dispenserblockentity.setItem(i, dispenseitembehavior.dispense(blocksource, itemstack)); ++ if (idispensebehavior != DispenseItemBehavior.NOOP) { ++ eventFired = false; // CraftBukkit - reset event status ++ tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack)); + } + + } + } + } + +- protected DispenseItemBehavior getDispenseMethod(ItemStack itemstack) { +- return (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(itemstack.getItem()); ++ protected DispenseItemBehavior getDispenseMethod(ItemStack stack) { ++ return (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(stack.getItem()); + } + + @Override +- @Override +- public void neighborChanged(BlockState blockstate, Level level, BlockPos blockpos, Block block, BlockPos blockpos1, boolean flag) { +- boolean flag1 = level.hasNeighborSignal(blockpos) || level.hasNeighborSignal(blockpos.above()); +- boolean flag2 = (Boolean) blockstate.getValue(DispenserBlock.TRIGGERED); ++ public void neighborChanged(IBlockData state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { ++ boolean flag1 = level.hasNeighborSignal(pos) || level.hasNeighborSignal(pos.above()); ++ boolean flag2 = (Boolean) state.getValue(DispenserBlock.TRIGGERED); + + if (flag1 && !flag2) { +- level.scheduleTick(blockpos, (Block) this, 4); +- level.setBlock(blockpos, (BlockState) blockstate.setValue(DispenserBlock.TRIGGERED, true), 2); ++ level.scheduleTick(pos, (Block) this, 4); ++ level.setBlock(pos, (IBlockData) state.setValue(DispenserBlock.TRIGGERED, true), 2); + } else if (!flag1 && flag2) { +- level.setBlock(blockpos, (BlockState) blockstate.setValue(DispenserBlock.TRIGGERED, false), 2); ++ level.setBlock(pos, (IBlockData) state.setValue(DispenserBlock.TRIGGERED, false), 2); + } + + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- this.dispenseFrom(serverlevel, blockstate, blockpos); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ this.dispenseFrom(level, state, pos); + } + + @Override +- @Override +- public BlockEntity newBlockEntity(BlockPos blockpos, BlockState blockstate) { +- return new DispenserBlockEntity(blockpos, blockstate); ++ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) { ++ return new DispenserBlockEntity(pos, state); + } + + @Override +- @Override +- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) { +- return (BlockState) this.defaultBlockState().setValue(DispenserBlock.FACING, blockplacecontext.getNearestLookingDirection().getOpposite()); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ return (IBlockData) this.defaultBlockState().setValue(DispenserBlock.FACING, context.getNearestLookingDirection().getOpposite()); + } + + @Override +- @Override +- public void setPlacedBy(Level level, BlockPos blockpos, BlockState blockstate, LivingEntity livingentity, ItemStack itemstack) { +- if (itemstack.hasCustomHoverName()) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ public void setPlacedBy(Level level, BlockPos pos, IBlockData state, LivingEntity placer, ItemStack stack) { ++ if (stack.hasCustomHoverName()) { ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof DispenserBlockEntity) { +- ((DispenserBlockEntity) blockentity).setCustomName(itemstack.getHoverName()); ++ if (tileentity instanceof DispenserBlockEntity) { ++ ((DispenserBlockEntity) tileentity).setCustomName(stack.getHoverName()); + } + } + + } + + @Override +- @Override +- public void onRemove(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- Containers.dropContentsOnDestroy(blockstate, blockstate1, level, blockpos); +- super.onRemove(blockstate, level, blockpos, blockstate1, flag); ++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) { ++ Containers.dropContentsOnDestroy(state, newState, level, pos); ++ super.onRemove(state, level, pos, newState, isMoving); + } + +- public static Position getDispensePosition(BlockSource blocksource) { +- Direction direction = (Direction) blocksource.state().getValue(DispenserBlock.FACING); ++ public static IPosition getDispensePosition(SourceBlock sourceblock) { ++ Direction enumdirection = (Direction) sourceblock.state().getValue(DispenserBlock.FACING); + +- return blocksource.center().add(0.7D * (double) direction.getStepX(), 0.7D * (double) direction.getStepY(), 0.7D * (double) direction.getStepZ()); ++ return sourceblock.center().add(0.7D * (double) enumdirection.getStepX(), 0.7D * (double) enumdirection.getStepY(), 0.7D * (double) enumdirection.getStepZ()); + } + + @Override +- @Override +- public boolean hasAnalogOutputSignal(BlockState blockstate) { ++ public boolean hasAnalogOutputSignal(IBlockData state) { + return true; + } + + @Override +- @Override +- public int getAnalogOutputSignal(BlockState blockstate, Level level, BlockPos blockpos) { +- return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(blockpos)); ++ public int getAnalogOutputSignal(IBlockData blockState, Level level, BlockPos pos) { ++ return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + + @Override +- @Override +- public RenderShape getRenderShape(BlockState blockstate) { +- return RenderShape.MODEL; ++ public EnumRenderType getRenderShape(IBlockData state) { ++ return EnumRenderType.MODEL; + } + + @Override +- @Override +- public BlockState rotate(BlockState blockstate, Rotation rotation) { +- return (BlockState) blockstate.setValue(DispenserBlock.FACING, rotation.rotate((Direction) blockstate.getValue(DispenserBlock.FACING))); ++ public IBlockData rotate(IBlockData state, Rotation rotation) { ++ return (IBlockData) state.setValue(DispenserBlock.FACING, rotation.rotate((Direction) state.getValue(DispenserBlock.FACING))); + } + + @Override +- @Override +- public BlockState mirror(BlockState blockstate, Mirror mirror) { +- return blockstate.rotate(mirror.getRotation((Direction) blockstate.getValue(DispenserBlock.FACING))); ++ public IBlockData mirror(IBlockData state, Mirror mirror) { ++ return state.rotate(mirror.getRotation((Direction) state.getValue(DispenserBlock.FACING))); + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(DispenserBlock.FACING, DispenserBlock.TRIGGERED); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(DispenserBlock.FACING, DispenserBlock.TRIGGERED); + } + } |