diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch new file mode 100644 index 0000000000..15101aa821 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch @@ -0,0 +1,167 @@ +--- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java ++++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java +@@ -9,7 +9,7 @@ + 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; +@@ -23,103 +23,94 @@ + public static final int MAX_AGE = 25; + private final double growPerTickProbability; + +- protected GrowingPlantHeadBlock(BlockBehaviour.Properties blockbehaviour_properties, Direction direction, VoxelShape voxelshape, boolean flag, double d0) { +- super(blockbehaviour_properties, direction, voxelshape, flag); +- this.growPerTickProbability = d0; +- this.registerDefaultState((BlockState) ((BlockState) this.stateDefinition.any()).setValue(GrowingPlantHeadBlock.AGE, 0)); ++ protected GrowingPlantHeadBlock(BlockBehaviour.Properties properties, Direction growthDirection, VoxelShape shape, boolean scheduleFluidTicks, double growPerTickProbability) { ++ super(properties, growthDirection, shape, scheduleFluidTicks); ++ this.growPerTickProbability = growPerTickProbability; ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(GrowingPlantHeadBlock.AGE, 0)); + } + + @Override +- @Override + protected abstract MapCodec<? extends GrowingPlantHeadBlock> codec(); + + @Override +- @Override +- public BlockState getStateForPlacement(LevelAccessor levelaccessor) { +- return (BlockState) this.defaultBlockState().setValue(GrowingPlantHeadBlock.AGE, levelaccessor.getRandom().nextInt(25)); ++ public IBlockData getStateForPlacement(LevelAccessor level) { ++ return (IBlockData) this.defaultBlockState().setValue(GrowingPlantHeadBlock.AGE, level.getRandom().nextInt(25)); + } + + @Override +- @Override +- public boolean isRandomlyTicking(BlockState blockstate) { +- return (Integer) blockstate.getValue(GrowingPlantHeadBlock.AGE) < 25; ++ public boolean isRandomlyTicking(IBlockData state) { ++ return (Integer) state.getValue(GrowingPlantHeadBlock.AGE) < 25; + } + + @Override +- @Override +- public void randomTick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- if ((Integer) blockstate.getValue(GrowingPlantHeadBlock.AGE) < 25 && randomsource.nextDouble() < this.growPerTickProbability) { +- BlockPos blockpos1 = blockpos.relative(this.growthDirection); ++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ if ((Integer) state.getValue(GrowingPlantHeadBlock.AGE) < 25 && random.nextDouble() < this.growPerTickProbability) { ++ BlockPos blockposition1 = pos.relative(this.growthDirection); + +- if (this.canGrowInto(serverlevel.getBlockState(blockpos1))) { +- serverlevel.setBlockAndUpdate(blockpos1, this.getGrowIntoState(blockstate, serverlevel.random)); ++ if (this.canGrowInto(level.getBlockState(blockposition1))) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockposition1, this.getGrowIntoState(state, level.random)); // CraftBukkit + } + } + + } + +- protected BlockState getGrowIntoState(BlockState blockstate, RandomSource randomsource) { +- return (BlockState) blockstate.cycle(GrowingPlantHeadBlock.AGE); ++ protected IBlockData getGrowIntoState(IBlockData state, RandomSource random) { ++ return (IBlockData) state.cycle(GrowingPlantHeadBlock.AGE); + } + +- public BlockState getMaxAgeState(BlockState blockstate) { +- return (BlockState) blockstate.setValue(GrowingPlantHeadBlock.AGE, 25); ++ public IBlockData getMaxAgeState(IBlockData state) { ++ return (IBlockData) state.setValue(GrowingPlantHeadBlock.AGE, 25); + } + +- public boolean isMaxAge(BlockState blockstate) { +- return (Integer) blockstate.getValue(GrowingPlantHeadBlock.AGE) == 25; ++ public boolean isMaxAge(IBlockData state) { ++ return (Integer) state.getValue(GrowingPlantHeadBlock.AGE) == 25; + } + +- protected BlockState updateBodyAfterConvertedFromHead(BlockState blockstate, BlockState blockstate1) { +- return blockstate1; ++ protected IBlockData updateBodyAfterConvertedFromHead(IBlockData head, IBlockData body) { ++ return body; + } + + @Override +- @Override +- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) { +- if (direction == this.growthDirection.getOpposite() && !blockstate.canSurvive(levelaccessor, blockpos)) { +- levelaccessor.scheduleTick(blockpos, (Block) this, 1); ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ if (facing == this.growthDirection.getOpposite() && !state.canSurvive(level, currentPos)) { ++ level.scheduleTick(currentPos, (Block) this, 1); + } + +- if (direction == this.growthDirection && (blockstate1.is((Block) this) || blockstate1.is(this.getBodyBlock()))) { +- return this.updateBodyAfterConvertedFromHead(blockstate, this.getBodyBlock().defaultBlockState()); ++ if (facing == this.growthDirection && (facingState.is((Block) this) || facingState.is(this.getBodyBlock()))) { ++ return this.updateBodyAfterConvertedFromHead(state, this.getBodyBlock().defaultBlockState()); + } else { + if (this.scheduleFluidTicks) { +- levelaccessor.scheduleTick(blockpos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(levelaccessor)); ++ level.scheduleTick(currentPos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(level)); + } + +- return super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1); ++ return super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(GrowingPlantHeadBlock.AGE); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(GrowingPlantHeadBlock.AGE); + } + + @Override +- @Override +- public boolean isValidBonemealTarget(LevelReader levelreader, BlockPos blockpos, BlockState blockstate) { +- return this.canGrowInto(levelreader.getBlockState(blockpos.relative(this.growthDirection))); ++ public boolean isValidBonemealTarget(LevelReader iworldreader, BlockPos blockposition, IBlockData iblockdata) { ++ return this.canGrowInto(iworldreader.getBlockState(blockposition.relative(this.growthDirection))); + } + + @Override +- @Override +- public boolean isBonemealSuccess(Level level, RandomSource randomsource, BlockPos blockpos, BlockState blockstate) { ++ public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, IBlockData state) { + return true; + } + + @Override +- @Override +- public void performBonemeal(ServerLevel serverlevel, RandomSource randomsource, BlockPos blockpos, BlockState blockstate) { +- BlockPos blockpos1 = blockpos.relative(this.growthDirection); +- int i = Math.min((Integer) blockstate.getValue(GrowingPlantHeadBlock.AGE) + 1, 25); +- int j = this.getBlocksToGrowWhenBonemealed(randomsource); ++ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, IBlockData state) { ++ BlockPos blockposition1 = pos.relative(this.growthDirection); ++ int i = Math.min((Integer) state.getValue(GrowingPlantHeadBlock.AGE) + 1, 25); ++ int j = this.getBlocksToGrowWhenBonemealed(random); + +- for (int k = 0; k < j && this.canGrowInto(serverlevel.getBlockState(blockpos1)); ++k) { +- serverlevel.setBlockAndUpdate(blockpos1, (BlockState) blockstate.setValue(GrowingPlantHeadBlock.AGE, i)); +- blockpos1 = blockpos1.relative(this.growthDirection); ++ for (int k = 0; k < j && this.canGrowInto(level.getBlockState(blockposition1)); ++k) { ++ level.setBlockAndUpdate(blockposition1, (IBlockData) state.setValue(GrowingPlantHeadBlock.AGE, i)); ++ blockposition1 = blockposition1.relative(this.growthDirection); + i = Math.min(i + 1, 25); + } + +@@ -127,10 +118,9 @@ + + protected abstract int getBlocksToGrowWhenBonemealed(RandomSource random); + +- protected abstract boolean canGrowInto(BlockState state); ++ protected abstract boolean canGrowInto(IBlockData state); + + @Override +- @Override + protected GrowingPlantHeadBlock getHeadBlock() { + return this; + } |