diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/CakeBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/CakeBlock.java.patch | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/CakeBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CakeBlock.java.patch new file mode 100644 index 0000000000..80c2aa613b --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CakeBlock.java.patch @@ -0,0 +1,188 @@ +--- a/net/minecraft/world/level/block/CakeBlock.java ++++ b/net/minecraft/world/level/block/CakeBlock.java +@@ -7,8 +7,9 @@ + 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; + import net.minecraft.world.item.Item; + import net.minecraft.world.item.ItemStack; +@@ -17,62 +18,57 @@ + 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; + + public class CakeBlock extends Block { ++ + public static final MapCodec<CakeBlock> CODEC = simpleCodec(CakeBlock::new); + public static final int MAX_BITES = 6; + public static final IntegerProperty BITES = BlockStateProperties.BITES; + public static final int FULL_CAKE_SIGNAL = getOutputSignal(0); + protected static final float AABB_OFFSET = 1.0F; + protected static final float AABB_SIZE_PER_BITE = 2.0F; +- protected static final VoxelShape[] SHAPE_BY_BITE = new VoxelShape[]{ +- Block.box(1.0, 0.0, 1.0, 15.0, 8.0, 15.0), +- Block.box(3.0, 0.0, 1.0, 15.0, 8.0, 15.0), +- Block.box(5.0, 0.0, 1.0, 15.0, 8.0, 15.0), +- Block.box(7.0, 0.0, 1.0, 15.0, 8.0, 15.0), +- Block.box(9.0, 0.0, 1.0, 15.0, 8.0, 15.0), +- Block.box(11.0, 0.0, 1.0, 15.0, 8.0, 15.0), +- Block.box(13.0, 0.0, 1.0, 15.0, 8.0, 15.0) +- }; ++ 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 + public MapCodec<CakeBlock> codec() { +- return CODEC; ++ return CakeBlock.CODEC; + } + + protected CakeBlock(BlockBehaviour.Properties properties) { + super(properties); +- this.registerDefaultState(this.stateDefinition.any().setValue(BITES, Integer.valueOf(0))); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(CakeBlock.BITES, 0)); + } + + @Override +- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- return SHAPE_BY_BITE[state.getValue(BITES)]; ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return CakeBlock.SHAPE_BY_BITE[(Integer) state.getValue(CakeBlock.BITES)]; + } + + @Override +- public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { +- ItemStack itemInHand = player.getItemInHand(hand); +- Item item = itemInHand.getItem(); +- if (itemInHand.is(ItemTags.CANDLES) && state.getValue(BITES) == 0) { ++ 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) state.getValue(CakeBlock.BITES) == 0) { + Block block = Block.byItem(item); ++ + if (block instanceof CandleBlock) { + if (!player.isCreative()) { +- itemInHand.shrink(1); ++ itemstack.shrink(1); + } + +- level.playSound(null, pos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F); ++ level.playSound((Player) null, pos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F); + level.setBlockAndUpdate(pos, CandleCakeBlock.byCandle(block)); +- level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); ++ level.gameEvent((Entity) player, GameEvent.BLOCK_CHANGE, pos); + player.awardStat(Stats.ITEM_USED.get(item)); + return InteractionResult.SUCCESS; + } +@@ -83,7 +79,7 @@ + return InteractionResult.SUCCESS; + } + +- if (itemInHand.isEmpty()) { ++ if (itemstack.isEmpty()) { + return InteractionResult.CONSUME; + } + } +@@ -91,19 +87,31 @@ + return eat(level, pos, state, player); + } + +- protected static InteractionResult eat(LevelAccessor level, BlockPos pos, BlockState state, 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 = state.getValue(BITES); +- level.gameEvent(player, GameEvent.EAT, pos); ++ // CraftBukkit start ++ // entityhuman.getFoodData().eat(2, 0.1F); ++ int oldFoodLevel = player.getFoodData().foodLevel; ++ ++ 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) { +- level.setBlock(pos, state.setValue(BITES, Integer.valueOf(i + 1)), 3); ++ level.setBlock(pos, (IBlockData) state.setValue(CakeBlock.BITES, i + 1), 3); + } else { + level.removeBlock(pos, false); +- level.gameEvent(player, GameEvent.BLOCK_DESTROY, pos); ++ level.gameEvent((Entity) player, GameEvent.BLOCK_DESTROY, pos); + } + + return InteractionResult.SUCCESS; +@@ -111,25 +119,23 @@ + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState 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); ++ 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 +- public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { + return level.getBlockState(pos.below()).isSolid(); + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(BITES); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(CakeBlock.BITES); + } + + @Override +- public int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) { +- return getOutputSignal(blockState.getValue(BITES)); ++ public int getAnalogOutputSignal(IBlockData blockState, Level level, BlockPos pos) { ++ return getOutputSignal((Integer) blockState.getValue(CakeBlock.BITES)); + } + + public static int getOutputSignal(int eaten) { +@@ -137,12 +143,12 @@ + } + + @Override +- public boolean hasAnalogOutputSignal(BlockState state) { ++ public boolean hasAnalogOutputSignal(IBlockData state) { + return true; + } + + @Override +- public boolean isPathfindable(BlockState state, BlockGetter level, BlockPos pos, PathComputationType type) { ++ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) { + return false; + } + } |