diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/LeavesBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/LeavesBlock.java.patch | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LeavesBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LeavesBlock.java.patch new file mode 100644 index 0000000000..e0918cec94 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -0,0 +1,207 @@ +--- a/net/minecraft/world/level/block/LeavesBlock.java ++++ b/net/minecraft/world/level/block/LeavesBlock.java +@@ -14,7 +14,7 @@ + import net.minecraft.world.level.Level; + import net.minecraft.world.level.LevelAccessor; + 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; +@@ -24,6 +24,7 @@ + import net.minecraft.world.level.material.Fluids; + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; ++import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit + + public class LeavesBlock extends Block implements SimpleWaterloggedBlock { + +@@ -35,130 +36,127 @@ + private static final int TICK_DELAY = 1; + + @Override +- @Override + public MapCodec<? extends LeavesBlock> codec() { + return LeavesBlock.CODEC; + } + +- public LeavesBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(LeavesBlock.DISTANCE, 7)).setValue(LeavesBlock.PERSISTENT, false)).setValue(LeavesBlock.WATERLOGGED, false)); ++ public LeavesBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(LeavesBlock.DISTANCE, 7)).setValue(LeavesBlock.PERSISTENT, false)).setValue(LeavesBlock.WATERLOGGED, false)); + } + + @Override +- @Override +- public VoxelShape getBlockSupportShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos) { ++ public VoxelShape getBlockSupportShape(IBlockData state, BlockGetter reader, BlockPos pos) { + return Shapes.empty(); + } + + @Override +- @Override +- public boolean isRandomlyTicking(BlockState blockstate) { +- return (Integer) blockstate.getValue(LeavesBlock.DISTANCE) == 7 && !(Boolean) blockstate.getValue(LeavesBlock.PERSISTENT); ++ public boolean isRandomlyTicking(IBlockData state) { ++ return (Integer) state.getValue(LeavesBlock.DISTANCE) == 7 && !(Boolean) state.getValue(LeavesBlock.PERSISTENT); + } + + @Override +- @Override +- public void randomTick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- if (this.decaying(blockstate)) { +- dropResources(blockstate, serverlevel, blockpos); +- serverlevel.removeBlock(blockpos, false); ++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ if (this.decaying(state)) { ++ // CraftBukkit start ++ LeavesDecayEvent event = new LeavesDecayEvent(level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ level.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled() || level.getBlockState(pos).getBlock() != this) { ++ return; ++ } ++ // CraftBukkit end ++ dropResources(state, level, pos); ++ level.removeBlock(pos, false); + } + + } + +- protected boolean decaying(BlockState blockstate) { +- return !(Boolean) blockstate.getValue(LeavesBlock.PERSISTENT) && (Integer) blockstate.getValue(LeavesBlock.DISTANCE) == 7; ++ protected boolean decaying(IBlockData state) { ++ return !(Boolean) state.getValue(LeavesBlock.PERSISTENT) && (Integer) state.getValue(LeavesBlock.DISTANCE) == 7; + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- serverlevel.setBlock(blockpos, updateDistance(blockstate, serverlevel, blockpos), 3); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ level.setBlock(pos, updateDistance(state, level, pos), 3); + } + + @Override +- @Override +- public int getLightBlock(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos) { ++ public int getLightBlock(IBlockData state, BlockGetter level, BlockPos pos) { + return 1; + } + + @Override +- @Override +- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) { +- if ((Boolean) blockstate.getValue(LeavesBlock.WATERLOGGED)) { +- levelaccessor.scheduleTick(blockpos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(levelaccessor)); ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ if ((Boolean) state.getValue(LeavesBlock.WATERLOGGED)) { ++ level.scheduleTick(currentPos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(level)); + } + +- int i = getDistanceAt(blockstate1) + 1; ++ int i = getDistanceAt(facingState) + 1; + +- if (i != 1 || (Integer) blockstate.getValue(LeavesBlock.DISTANCE) != i) { +- levelaccessor.scheduleTick(blockpos, (Block) this, 1); ++ if (i != 1 || (Integer) state.getValue(LeavesBlock.DISTANCE) != i) { ++ level.scheduleTick(currentPos, (Block) this, 1); + } + +- return blockstate; ++ return state; + } + +- private static BlockState updateDistance(BlockState blockstate, LevelAccessor levelaccessor, BlockPos blockpos) { ++ private static IBlockData updateDistance(IBlockData state, LevelAccessor level, BlockPos pos) { + int i = 7; +- BlockPos.MutableBlockPos blockpos_mutableblockpos = new BlockPos.MutableBlockPos(); +- Direction[] adirection = Direction.values(); +- int j = adirection.length; ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); ++ Direction[] aenumdirection = Direction.values(); ++ int j = aenumdirection.length; + + for (int k = 0; k < j; ++k) { +- Direction direction = adirection[k]; ++ Direction enumdirection = aenumdirection[k]; + +- blockpos_mutableblockpos.setWithOffset(blockpos, direction); +- i = Math.min(i, getDistanceAt(levelaccessor.getBlockState(blockpos_mutableblockpos)) + 1); ++ blockposition_mutableblockposition.setWithOffset(pos, enumdirection); ++ i = Math.min(i, getDistanceAt(level.getBlockState(blockposition_mutableblockposition)) + 1); + if (i == 1) { + break; + } + } + +- return (BlockState) blockstate.setValue(LeavesBlock.DISTANCE, i); ++ return (IBlockData) state.setValue(LeavesBlock.DISTANCE, i); + } + +- private static int getDistanceAt(BlockState blockstate) { +- return getOptionalDistanceAt(blockstate).orElse(7); ++ private static int getDistanceAt(IBlockData neighbor) { ++ return getOptionalDistanceAt(neighbor).orElse(7); + } + +- public static OptionalInt getOptionalDistanceAt(BlockState blockstate) { +- return blockstate.is(BlockTags.LOGS) ? OptionalInt.of(0) : (blockstate.hasProperty(LeavesBlock.DISTANCE) ? OptionalInt.of((Integer) blockstate.getValue(LeavesBlock.DISTANCE)) : OptionalInt.empty()); ++ public static OptionalInt getOptionalDistanceAt(IBlockData state) { ++ return state.is(BlockTags.LOGS) ? OptionalInt.of(0) : (state.hasProperty(LeavesBlock.DISTANCE) ? OptionalInt.of((Integer) state.getValue(LeavesBlock.DISTANCE)) : OptionalInt.empty()); + } + + @Override +- @Override +- public FluidState getFluidState(BlockState blockstate) { +- return (Boolean) blockstate.getValue(LeavesBlock.WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockstate); ++ public FluidState getFluidState(IBlockData state) { ++ return (Boolean) state.getValue(LeavesBlock.WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + } + + @Override +- @Override +- public void animateTick(BlockState blockstate, Level level, BlockPos blockpos, RandomSource randomsource) { +- if (level.isRainingAt(blockpos.above())) { +- if (randomsource.nextInt(15) == 1) { +- BlockPos blockpos1 = blockpos.below(); +- BlockState blockstate1 = level.getBlockState(blockpos1); ++ public void animateTick(IBlockData state, Level level, BlockPos pos, RandomSource random) { ++ if (level.isRainingAt(pos.above())) { ++ if (random.nextInt(15) == 1) { ++ BlockPos blockposition1 = pos.below(); ++ IBlockData iblockdata1 = level.getBlockState(blockposition1); + +- if (!blockstate1.canOcclude() || !blockstate1.isFaceSturdy(level, blockpos1, Direction.UP)) { +- ParticleUtils.spawnParticleBelow(level, blockpos, randomsource, ParticleTypes.DRIPPING_WATER); ++ if (!iblockdata1.canOcclude() || !iblockdata1.isFaceSturdy(level, blockposition1, Direction.UP)) { ++ ParticleUtils.spawnParticleBelow(level, pos, random, ParticleTypes.DRIPPING_WATER); + } + } + } + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(LeavesBlock.DISTANCE, LeavesBlock.PERSISTENT, LeavesBlock.WATERLOGGED); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(LeavesBlock.DISTANCE, LeavesBlock.PERSISTENT, LeavesBlock.WATERLOGGED); + } + + @Override +- @Override +- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) { +- FluidState fluidstate = blockplacecontext.getLevel().getFluidState(blockplacecontext.getClickedPos()); +- BlockState blockstate = (BlockState) ((BlockState) this.defaultBlockState().setValue(LeavesBlock.PERSISTENT, true)).setValue(LeavesBlock.WATERLOGGED, fluidstate.getType() == Fluids.WATER); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ FluidState fluid = context.getLevel().getFluidState(context.getClickedPos()); ++ IBlockData iblockdata = (IBlockData) ((IBlockData) this.defaultBlockState().setValue(LeavesBlock.PERSISTENT, true)).setValue(LeavesBlock.WATERLOGGED, fluid.getType() == Fluids.WATER); + +- return updateDistance(blockstate, blockplacecontext.getLevel(), blockplacecontext.getClickedPos()); ++ return updateDistance(iblockdata, context.getLevel(), context.getClickedPos()); + } + } |