aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/block/LeavesBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/LeavesBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/block/LeavesBlock.java.patch199
1 files changed, 199 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/LeavesBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/LeavesBlock.java.patch
new file mode 100644
index 0000000000..9772e8b635
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/LeavesBlock.java.patch
@@ -0,0 +1,199 @@
+--- a/net/minecraft/world/level/block/LeavesBlock.java
++++ b/net/minecraft/world/level/block/LeavesBlock.java
+@@ -14,17 +14,20 @@
+ 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;
+ import net.minecraft.world.level.block.state.properties.IntegerProperty;
++import net.minecraft.world.level.material.Fluid;
+ import net.minecraft.world.level.material.FluidState;
+ 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 {
++
+ public static final MapCodec<LeavesBlock> CODEC = simpleCodec(LeavesBlock::new);
+ public static final int DECAY_DISTANCE = 7;
+ public static final IntegerProperty DISTANCE = BlockStateProperties.DISTANCE;
+@@ -34,105 +37,110 @@
+
+ @Override
+ public MapCodec<? extends LeavesBlock> codec() {
+- return CODEC;
++ return LeavesBlock.CODEC;
+ }
+
+ public LeavesBlock(BlockBehaviour.Properties properties) {
+ super(properties);
+- this.registerDefaultState(
+- this.stateDefinition
+- .any()
+- .setValue(DISTANCE, Integer.valueOf(7))
+- .setValue(PERSISTENT, Boolean.valueOf(false))
+- .setValue(WATERLOGGED, Boolean.valueOf(false))
+- );
++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(LeavesBlock.DISTANCE, 7)).setValue(LeavesBlock.PERSISTENT, false)).setValue(LeavesBlock.WATERLOGGED, false));
+ }
+
+ @Override
+- public VoxelShape getBlockSupportShape(BlockState state, BlockGetter reader, BlockPos pos) {
++ public VoxelShape getBlockSupportShape(IBlockData state, BlockGetter reader, BlockPos pos) {
+ return Shapes.empty();
+ }
+
+ @Override
+- public boolean isRandomlyTicking(BlockState state) {
+- return state.getValue(DISTANCE) == 7 && !state.getValue(PERSISTENT);
++ public boolean isRandomlyTicking(IBlockData state) {
++ return (Integer) state.getValue(LeavesBlock.DISTANCE) == 7 && !(Boolean) state.getValue(LeavesBlock.PERSISTENT);
+ }
+
+ @Override
+- public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
++ 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 state) {
+- return !state.getValue(PERSISTENT) && state.getValue(DISTANCE) == 7;
++ protected boolean decaying(IBlockData state) {
++ return !(Boolean) state.getValue(LeavesBlock.PERSISTENT) && (Integer) state.getValue(LeavesBlock.DISTANCE) == 7;
+ }
+
+ @Override
+- public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
+ level.setBlock(pos, updateDistance(state, level, pos), 3);
+ }
+
+ @Override
+- public int getLightBlock(BlockState state, BlockGetter level, BlockPos pos) {
++ public int getLightBlock(IBlockData state, BlockGetter level, BlockPos pos) {
+ return 1;
+ }
+
+ @Override
+- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
+- if (state.getValue(WATERLOGGED)) {
+- level.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
++ 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(facingState) + 1;
+- if (i != 1 || state.getValue(DISTANCE) != i) {
+- level.scheduleTick(currentPos, this, 1);
++
++ if (i != 1 || (Integer) state.getValue(LeavesBlock.DISTANCE) != i) {
++ level.scheduleTick(currentPos, (Block) this, 1);
+ }
+
+ return state;
+ }
+
+- private static BlockState updateDistance(BlockState state, LevelAccessor level, BlockPos pos) {
++ private static IBlockData updateDistance(IBlockData state, LevelAccessor level, BlockPos pos) {
+ int i = 7;
+- BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
++ Direction[] aenumdirection = Direction.values();
++ int j = aenumdirection.length;
+
+- for (Direction direction : Direction.values()) {
+- mutableBlockPos.setWithOffset(pos, direction);
+- i = Math.min(i, getDistanceAt(level.getBlockState(mutableBlockPos)) + 1);
++ for (int k = 0; k < j; ++k) {
++ Direction enumdirection = aenumdirection[k];
++
++ blockposition_mutableblockposition.setWithOffset(pos, enumdirection);
++ i = Math.min(i, getDistanceAt(level.getBlockState(blockposition_mutableblockposition)) + 1);
+ if (i == 1) {
+ break;
+ }
+ }
+
+- return state.setValue(DISTANCE, Integer.valueOf(i));
++ return (IBlockData) state.setValue(LeavesBlock.DISTANCE, i);
+ }
+
+- private static int getDistanceAt(BlockState neighbor) {
++ private static int getDistanceAt(IBlockData neighbor) {
+ return getOptionalDistanceAt(neighbor).orElse(7);
+ }
+
+- public static OptionalInt getOptionalDistanceAt(BlockState state) {
+- if (state.is(BlockTags.LOGS)) {
+- return OptionalInt.of(0);
+- } else {
+- return state.hasProperty(DISTANCE) ? OptionalInt.of(state.getValue(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
+- public FluidState getFluidState(BlockState state) {
+- return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
++ public FluidState getFluidState(IBlockData state) {
++ return (Boolean) state.getValue(LeavesBlock.WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
+ }
+
+ @Override
+- public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) {
++ public void animateTick(IBlockData state, Level level, BlockPos pos, RandomSource random) {
+ if (level.isRainingAt(pos.above())) {
+ if (random.nextInt(15) == 1) {
+- BlockPos blockPos = pos.below();
+- BlockState blockState = level.getBlockState(blockPos);
+- if (!blockState.canOcclude() || !blockState.isFaceSturdy(level, blockPos, Direction.UP)) {
++ BlockPos blockposition1 = pos.below();
++ IBlockData iblockdata1 = level.getBlockState(blockposition1);
++
++ if (!iblockdata1.canOcclude() || !iblockdata1.isFaceSturdy(level, blockposition1, Direction.UP)) {
+ ParticleUtils.spawnParticleBelow(level, pos, random, ParticleTypes.DRIPPING_WATER);
+ }
+ }
+@@ -140,16 +148,15 @@
+ }
+
+ @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
+- builder.add(DISTANCE, PERSISTENT, WATERLOGGED);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(LeavesBlock.DISTANCE, LeavesBlock.PERSISTENT, LeavesBlock.WATERLOGGED);
+ }
+
+ @Override
+- public BlockState getStateForPlacement(BlockPlaceContext context) {
+- FluidState fluidState = context.getLevel().getFluidState(context.getClickedPos());
+- BlockState blockState = this.defaultBlockState()
+- .setValue(PERSISTENT, Boolean.valueOf(true))
+- .setValue(WATERLOGGED, Boolean.valueOf(fluidState.getType() == Fluids.WATER));
+- return updateDistance(blockState, context.getLevel(), context.getClickedPos());
++ 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(iblockdata, context.getLevel(), context.getClickedPos());
+ }
+ }