diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/CakeBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/CakeBlock.java.patch | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CakeBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CakeBlock.java.patch new file mode 100644 index 0000000000..99b7c77da0 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CakeBlock.java.patch @@ -0,0 +1,183 @@ +--- a/net/minecraft/world/level/block/CakeBlock.java ++++ b/net/minecraft/world/level/block/CakeBlock.java +@@ -7,7 +7,7 @@ + import net.minecraft.sounds.SoundSource; + import net.minecraft.stats.Stats; + import net.minecraft.tags.ItemTags; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.player.Player; +@@ -18,12 +18,12 @@ + import net.minecraft.world.level.LevelAccessor; + import net.minecraft.world.level.LevelReader; + 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.IntegerProperty; + import net.minecraft.world.level.gameevent.GameEvent; +-import net.minecraft.world.level.pathfinder.PathComputationType; ++import net.minecraft.world.level.pathfinder.PathMode; + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; +@@ -39,29 +39,26 @@ + protected static final VoxelShape[] SHAPE_BY_BITE = new VoxelShape[]{Block.box(1.0D, 0.0D, 1.0D, 15.0D, 8.0D, 15.0D), Block.box(3.0D, 0.0D, 1.0D, 15.0D, 8.0D, 15.0D), Block.box(5.0D, 0.0D, 1.0D, 15.0D, 8.0D, 15.0D), Block.box(7.0D, 0.0D, 1.0D, 15.0D, 8.0D, 15.0D), Block.box(9.0D, 0.0D, 1.0D, 15.0D, 8.0D, 15.0D), Block.box(11.0D, 0.0D, 1.0D, 15.0D, 8.0D, 15.0D), Block.box(13.0D, 0.0D, 1.0D, 15.0D, 8.0D, 15.0D)}; + + @Override +- @Override + public MapCodec<CakeBlock> codec() { + return CakeBlock.CODEC; + } + +- protected CakeBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) this.stateDefinition.any()).setValue(CakeBlock.BITES, 0)); ++ protected CakeBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(CakeBlock.BITES, 0)); + } + + @Override +- @Override +- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) { +- return CakeBlock.SHAPE_BY_BITE[(Integer) blockstate.getValue(CakeBlock.BITES)]; ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return CakeBlock.SHAPE_BY_BITE[(Integer) state.getValue(CakeBlock.BITES)]; + } + + @Override +- @Override +- public InteractionResult use(BlockState blockstate, Level level, BlockPos blockpos, Player player, InteractionHand interactionhand, BlockHitResult blockhitresult) { +- ItemStack itemstack = player.getItemInHand(interactionhand); ++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) { ++ ItemStack itemstack = player.getItemInHand(hand); + Item item = itemstack.getItem(); + +- if (itemstack.is(ItemTags.CANDLES) && (Integer) blockstate.getValue(CakeBlock.BITES) == 0) { ++ if (itemstack.is(ItemTags.CANDLES) && (Integer) state.getValue(CakeBlock.BITES) == 0) { + Block block = Block.byItem(item); + + if (block instanceof CandleBlock) { +@@ -69,16 +66,16 @@ + itemstack.shrink(1); + } + +- level.playSound((Player) null, blockpos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F); +- level.setBlockAndUpdate(blockpos, CandleCakeBlock.byCandle(block)); +- level.gameEvent((Entity) player, GameEvent.BLOCK_CHANGE, blockpos); ++ level.playSound((Player) null, pos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F); ++ level.setBlockAndUpdate(pos, CandleCakeBlock.byCandle(block)); ++ level.gameEvent((Entity) player, GameEvent.BLOCK_CHANGE, pos); + player.awardStat(Stats.ITEM_USED.get(item)); + return InteractionResult.SUCCESS; + } + } + + if (level.isClientSide) { +- if (eat(level, blockpos, blockstate, player).consumesAction()) { ++ if (eat(level, pos, state, player).consumesAction()) { + return InteractionResult.SUCCESS; + } + +@@ -87,23 +84,34 @@ + } + } + +- return eat(level, blockpos, blockstate, player); ++ return eat(level, pos, state, player); + } + +- protected static InteractionResult eat(LevelAccessor levelaccessor, BlockPos blockpos, BlockState blockstate, Player player) { ++ protected static InteractionResult eat(LevelAccessor level, BlockPos pos, IBlockData state, Player player) { + if (!player.canEat(false)) { + return InteractionResult.PASS; + } else { + player.awardStat(Stats.EAT_CAKE_SLICE); +- player.getFoodData().eat(2, 0.1F); +- int i = (Integer) blockstate.getValue(CakeBlock.BITES); ++ // CraftBukkit start ++ // entityhuman.getFoodData().eat(2, 0.1F); ++ int oldFoodLevel = player.getFoodData().foodLevel; + +- levelaccessor.gameEvent((Entity) player, GameEvent.EAT, blockpos); ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, 2 + oldFoodLevel); ++ ++ if (!event.isCancelled()) { ++ player.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F); ++ } ++ ++ ((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().sendHealthUpdate(); ++ // CraftBukkit end ++ int i = (Integer) state.getValue(CakeBlock.BITES); ++ ++ level.gameEvent((Entity) player, GameEvent.EAT, pos); + if (i < 6) { +- levelaccessor.setBlock(blockpos, (BlockState) blockstate.setValue(CakeBlock.BITES, i + 1), 3); ++ level.setBlock(pos, (IBlockData) state.setValue(CakeBlock.BITES, i + 1), 3); + } else { +- levelaccessor.removeBlock(blockpos, false); +- levelaccessor.gameEvent((Entity) player, GameEvent.BLOCK_DESTROY, blockpos); ++ level.removeBlock(pos, false); ++ level.gameEvent((Entity) player, GameEvent.BLOCK_DESTROY, pos); + } + + return InteractionResult.SUCCESS; +@@ -111,42 +119,36 @@ + } + + @Override +- @Override +- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) { +- return direction == Direction.DOWN && !blockstate.canSurvive(levelaccessor, blockpos) ? Blocks.AIR.defaultBlockState() : super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1); ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ return facing == Direction.DOWN && !state.canSurvive(level, currentPos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } + + @Override +- @Override +- public boolean canSurvive(BlockState blockstate, LevelReader levelreader, BlockPos blockpos) { +- return levelreader.getBlockState(blockpos.below()).isSolid(); ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { ++ return level.getBlockState(pos.below()).isSolid(); + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(CakeBlock.BITES); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(CakeBlock.BITES); + } + + @Override +- @Override +- public int getAnalogOutputSignal(BlockState blockstate, Level level, BlockPos blockpos) { +- return getOutputSignal((Integer) blockstate.getValue(CakeBlock.BITES)); ++ public int getAnalogOutputSignal(IBlockData blockState, Level level, BlockPos pos) { ++ return getOutputSignal((Integer) blockState.getValue(CakeBlock.BITES)); + } + +- public static int getOutputSignal(int i) { +- return (7 - i) * 2; ++ public static int getOutputSignal(int eaten) { ++ return (7 - eaten) * 2; + } + + @Override +- @Override +- public boolean hasAnalogOutputSignal(BlockState blockstate) { ++ public boolean hasAnalogOutputSignal(IBlockData state) { + return true; + } + + @Override +- @Override +- public boolean isPathfindable(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, PathComputationType pathcomputationtype) { ++ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) { + return false; + } + } |