diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/BambooStalkBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/BambooStalkBlock.java.patch | 330 |
1 files changed, 330 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/BambooStalkBlock.java.patch new file mode 100644 index 0000000000..af738d0119 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -0,0 +1,330 @@ +--- a/net/minecraft/world/level/block/BambooStalkBlock.java ++++ b/net/minecraft/world/level/block/BambooStalkBlock.java +@@ -15,14 +15,14 @@ + 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.BambooLeaves; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.EnumProperty; + import net.minecraft.world.level.block.state.properties.IntegerProperty; + import net.minecraft.world.level.material.FluidState; +-import net.minecraft.world.level.pathfinder.PathComputationType; ++import net.minecraft.world.level.pathfinder.PathMode; + import net.minecraft.world.phys.Vec3; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; +@@ -46,79 +46,71 @@ + public static final int AGE_THICK_BAMBOO = 1; + + @Override +- @Override + public MapCodec<BambooStalkBlock> codec() { + return BambooStalkBlock.CODEC; + } + +- public BambooStalkBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(BambooStalkBlock.AGE, 0)).setValue(BambooStalkBlock.LEAVES, BambooLeaves.NONE)).setValue(BambooStalkBlock.STAGE, 0)); ++ public BambooStalkBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(BambooStalkBlock.AGE, 0)).setValue(BambooStalkBlock.LEAVES, BambooLeaves.NONE)).setValue(BambooStalkBlock.STAGE, 0)); + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(BambooStalkBlock.AGE, BambooStalkBlock.LEAVES, BambooStalkBlock.STAGE); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(BambooStalkBlock.AGE, BambooStalkBlock.LEAVES, BambooStalkBlock.STAGE); + } + + @Override +- @Override +- public boolean propagatesSkylightDown(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos) { ++ public boolean propagatesSkylightDown(IBlockData state, BlockGetter level, BlockPos pos) { + return true; + } + + @Override +- @Override +- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) { +- VoxelShape voxelshape = blockstate.getValue(BambooStalkBlock.LEAVES) == BambooLeaves.LARGE ? BambooStalkBlock.LARGE_SHAPE : BambooStalkBlock.SMALL_SHAPE; +- Vec3 vec3 = blockstate.getOffset(blockgetter, blockpos); ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ VoxelShape voxelshape = state.getValue(BambooStalkBlock.LEAVES) == BambooLeaves.LARGE ? BambooStalkBlock.LARGE_SHAPE : BambooStalkBlock.SMALL_SHAPE; ++ Vec3 vec3d = state.getOffset(level, pos); + +- return voxelshape.move(vec3.x, vec3.y, vec3.z); ++ return voxelshape.move(vec3d.x, vec3d.y, vec3d.z); + } + + @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; + } + + @Override +- @Override +- public VoxelShape getCollisionShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) { +- Vec3 vec3 = blockstate.getOffset(blockgetter, blockpos); ++ public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ Vec3 vec3d = state.getOffset(level, pos); + +- return BambooStalkBlock.COLLISION_SHAPE.move(vec3.x, vec3.y, vec3.z); ++ return BambooStalkBlock.COLLISION_SHAPE.move(vec3d.x, vec3d.y, vec3d.z); + } + + @Override +- @Override +- public boolean isCollisionShapeFullBlock(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos) { ++ public boolean isCollisionShapeFullBlock(IBlockData state, BlockGetter level, BlockPos pos) { + return false; + } + + @Nullable + @Override +- @Override +- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) { +- FluidState fluidstate = blockplacecontext.getLevel().getFluidState(blockplacecontext.getClickedPos()); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ FluidState fluid = context.getLevel().getFluidState(context.getClickedPos()); + +- if (!fluidstate.isEmpty()) { ++ if (!fluid.isEmpty()) { + return null; + } else { +- BlockState blockstate = blockplacecontext.getLevel().getBlockState(blockplacecontext.getClickedPos().below()); ++ IBlockData iblockdata = context.getLevel().getBlockState(context.getClickedPos().below()); + +- if (blockstate.is(BlockTags.BAMBOO_PLANTABLE_ON)) { +- if (blockstate.is(Blocks.BAMBOO_SAPLING)) { +- return (BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, 0); +- } else if (blockstate.is(Blocks.BAMBOO)) { +- int i = (Integer) blockstate.getValue(BambooStalkBlock.AGE) > 0 ? 1 : 0; ++ if (iblockdata.is(BlockTags.BAMBOO_PLANTABLE_ON)) { ++ if (iblockdata.is(Blocks.BAMBOO_SAPLING)) { ++ return (IBlockData) this.defaultBlockState().setValue(BambooStalkBlock.AGE, 0); ++ } else if (iblockdata.is(Blocks.BAMBOO)) { ++ int i = (Integer) iblockdata.getValue(BambooStalkBlock.AGE) > 0 ? 1 : 0; + +- return (BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, i); ++ return (IBlockData) this.defaultBlockState().setValue(BambooStalkBlock.AGE, i); + } else { +- BlockState blockstate1 = blockplacecontext.getLevel().getBlockState(blockplacecontext.getClickedPos().above()); ++ IBlockData iblockdata1 = context.getLevel().getBlockState(context.getClickedPos().above()); + +- return blockstate1.is(Blocks.BAMBOO) ? (BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, (Integer) blockstate1.getValue(BambooStalkBlock.AGE)) : Blocks.BAMBOO_SAPLING.defaultBlockState(); ++ return iblockdata1.is(Blocks.BAMBOO) ? (IBlockData) this.defaultBlockState().setValue(BambooStalkBlock.AGE, (Integer) iblockdata1.getValue(BambooStalkBlock.AGE)) : Blocks.BAMBOO_SAPLING.defaultBlockState(); + } + } else { + return null; +@@ -127,29 +119,26 @@ + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- if (!blockstate.canSurvive(serverlevel, blockpos)) { +- serverlevel.destroyBlock(blockpos, true); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ if (!state.canSurvive(level, pos)) { ++ level.destroyBlock(pos, true); + } + + } + + @Override +- @Override +- public boolean isRandomlyTicking(BlockState blockstate) { +- return (Integer) blockstate.getValue(BambooStalkBlock.STAGE) == 0; ++ public boolean isRandomlyTicking(IBlockData state) { ++ return (Integer) state.getValue(BambooStalkBlock.STAGE) == 0; + } + + @Override +- @Override +- public void randomTick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- if ((Integer) blockstate.getValue(BambooStalkBlock.STAGE) == 0) { +- if (randomsource.nextInt(3) == 0 && serverlevel.isEmptyBlock(blockpos.above()) && serverlevel.getRawBrightness(blockpos.above(), 0) >= 9) { +- int i = this.getHeightBelowUpToMax(serverlevel, blockpos) + 1; ++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ if ((Integer) state.getValue(BambooStalkBlock.STAGE) == 0) { ++ if (random.nextInt(3) == 0 && level.isEmptyBlock(pos.above()) && level.getRawBrightness(pos.above(), 0) >= 9) { ++ int i = this.getHeightBelowUpToMax(level, pos) + 1; + + if (i < 16) { +- this.growBamboo(blockstate, serverlevel, blockpos, randomsource, i); ++ this.growBamboo(state, level, pos, random, i); + } + } + +@@ -157,57 +146,52 @@ + } + + @Override +- @Override +- public boolean canSurvive(BlockState blockstate, LevelReader levelreader, BlockPos blockpos) { +- return levelreader.getBlockState(blockpos.below()).is(BlockTags.BAMBOO_PLANTABLE_ON); ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { ++ return level.getBlockState(pos.below()).is(BlockTags.BAMBOO_PLANTABLE_ON); + } + + @Override +- @Override +- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) { +- if (!blockstate.canSurvive(levelaccessor, blockpos)) { +- levelaccessor.scheduleTick(blockpos, (Block) this, 1); ++ public IBlockData updateShape(IBlockData state, Direction direction, IBlockData neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) { ++ if (!state.canSurvive(level, pos)) { ++ level.scheduleTick(pos, (Block) this, 1); + } + +- if (direction == Direction.UP && blockstate1.is(Blocks.BAMBOO) && (Integer) blockstate1.getValue(BambooStalkBlock.AGE) > (Integer) blockstate.getValue(BambooStalkBlock.AGE)) { +- levelaccessor.setBlock(blockpos, (BlockState) blockstate.cycle(BambooStalkBlock.AGE), 2); ++ if (direction == Direction.UP && neighborState.is(Blocks.BAMBOO) && (Integer) neighborState.getValue(BambooStalkBlock.AGE) > (Integer) state.getValue(BambooStalkBlock.AGE)) { ++ level.setBlock(pos, (IBlockData) state.cycle(BambooStalkBlock.AGE), 2); + } + +- return super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1); ++ return super.updateShape(state, direction, neighborState, level, pos, neighborPos); + } + + @Override +- @Override +- public boolean isValidBonemealTarget(LevelReader levelreader, BlockPos blockpos, BlockState blockstate) { +- int i = this.getHeightAboveUpToMax(levelreader, blockpos); +- int j = this.getHeightBelowUpToMax(levelreader, blockpos); ++ public boolean isValidBonemealTarget(LevelReader iworldreader, BlockPos blockposition, IBlockData iblockdata) { ++ int i = this.getHeightAboveUpToMax(iworldreader, blockposition); ++ int j = this.getHeightBelowUpToMax(iworldreader, blockposition); + +- return i + j + 1 < 16 && (Integer) levelreader.getBlockState(blockpos.above(i)).getValue(BambooStalkBlock.STAGE) != 1; ++ return i + j + 1 < 16 && (Integer) iworldreader.getBlockState(blockposition.above(i)).getValue(BambooStalkBlock.STAGE) != 1; + } + + @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) { +- int i = this.getHeightAboveUpToMax(serverlevel, blockpos); +- int j = this.getHeightBelowUpToMax(serverlevel, blockpos); ++ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, IBlockData state) { ++ int i = this.getHeightAboveUpToMax(level, pos); ++ int j = this.getHeightBelowUpToMax(level, pos); + int k = i + j + 1; +- int l = 1 + randomsource.nextInt(2); ++ int l = 1 + random.nextInt(2); + + for (int i1 = 0; i1 < l; ++i1) { +- BlockPos blockpos1 = blockpos.above(i); +- BlockState blockstate1 = serverlevel.getBlockState(blockpos1); ++ BlockPos blockposition1 = pos.above(i); ++ IBlockData iblockdata1 = level.getBlockState(blockposition1); + +- if (k >= 16 || (Integer) blockstate1.getValue(BambooStalkBlock.STAGE) == 1 || !serverlevel.isEmptyBlock(blockpos1.above())) { ++ if (k >= 16 || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !level.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here + return; + } + +- this.growBamboo(blockstate1, serverlevel, blockpos1, randomsource, k); ++ this.growBamboo(iblockdata1, level, blockposition1, random, k); + ++i; + ++k; + } +@@ -215,51 +199,61 @@ + } + + @Override +- @Override +- public float getDestroyProgress(BlockState blockstate, Player player, BlockGetter blockgetter, BlockPos blockpos) { +- return player.getMainHandItem().getItem() instanceof SwordItem ? 1.0F : super.getDestroyProgress(blockstate, player, blockgetter, blockpos); ++ public float getDestroyProgress(IBlockData state, Player player, BlockGetter level, BlockPos pos) { ++ return player.getMainHandItem().getItem() instanceof SwordItem ? 1.0F : super.getDestroyProgress(state, player, level, pos); + } + +- protected void growBamboo(BlockState blockstate, Level level, BlockPos blockpos, RandomSource randomsource, int i) { +- BlockState blockstate1 = level.getBlockState(blockpos.below()); +- BlockPos blockpos1 = blockpos.below(2); +- BlockState blockstate2 = level.getBlockState(blockpos1); +- BambooLeaves bambooleaves = BambooLeaves.NONE; ++ protected void growBamboo(IBlockData state, Level level, BlockPos pos, RandomSource random, int age) { ++ IBlockData iblockdata1 = level.getBlockState(pos.below()); ++ BlockPos blockposition1 = pos.below(2); ++ IBlockData iblockdata2 = level.getBlockState(blockposition1); ++ BambooLeaves blockpropertybamboosize = BambooLeaves.NONE; ++ boolean shouldUpdateOthers = false; // CraftBukkit + +- if (i >= 1) { +- if (blockstate1.is(Blocks.BAMBOO) && blockstate1.getValue(BambooStalkBlock.LEAVES) != BambooLeaves.NONE) { +- if (blockstate1.is(Blocks.BAMBOO) && blockstate1.getValue(BambooStalkBlock.LEAVES) != BambooLeaves.NONE) { +- bambooleaves = BambooLeaves.LARGE; +- if (blockstate2.is(Blocks.BAMBOO)) { +- level.setBlock(blockpos.below(), (BlockState) blockstate1.setValue(BambooStalkBlock.LEAVES, BambooLeaves.SMALL), 3); +- level.setBlock(blockpos1, (BlockState) blockstate2.setValue(BambooStalkBlock.LEAVES, BambooLeaves.NONE), 3); ++ if (age >= 1) { ++ if (iblockdata1.is(Blocks.BAMBOO) && iblockdata1.getValue(BambooStalkBlock.LEAVES) != BambooLeaves.NONE) { ++ if (iblockdata1.is(Blocks.BAMBOO) && iblockdata1.getValue(BambooStalkBlock.LEAVES) != BambooLeaves.NONE) { ++ blockpropertybamboosize = BambooLeaves.LARGE; ++ if (iblockdata2.is(Blocks.BAMBOO)) { ++ // CraftBukkit start - moved down ++ // world.setBlock(blockposition.below(), (IBlockData) iblockdata1.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); ++ // world.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3); ++ shouldUpdateOthers = true; ++ // CraftBukkit end + } + } + } else { +- bambooleaves = BambooLeaves.SMALL; ++ blockpropertybamboosize = BambooLeaves.SMALL; + } + } + +- int j = (Integer) blockstate.getValue(BambooStalkBlock.AGE) != 1 && !blockstate2.is(Blocks.BAMBOO) ? 0 : 1; +- int k = (i < 11 || randomsource.nextFloat() >= 0.25F) && i != 15 ? 0 : 1; ++ int j = (Integer) state.getValue(BambooStalkBlock.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1; ++ int k = (age < 11 || random.nextFloat() >= 0.25F) && age != 15 ? 0 : 1; + +- level.setBlock(blockpos.above(), (BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, j)).setValue(BambooStalkBlock.LEAVES, bambooleaves)).setValue(BambooStalkBlock.STAGE, k), 3); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, pos.above(), (IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(BambooStalkBlock.AGE, j)).setValue(BambooStalkBlock.LEAVES, blockpropertybamboosize)).setValue(BambooStalkBlock.STAGE, k), 3)) { ++ if (shouldUpdateOthers) { ++ level.setBlock(pos.below(), (IBlockData) iblockdata1.setValue(BambooStalkBlock.LEAVES, BambooLeaves.SMALL), 3); ++ level.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BambooStalkBlock.LEAVES, BambooLeaves.NONE), 3); ++ } ++ } ++ // CraftBukkit end + } + +- protected int getHeightAboveUpToMax(BlockGetter blockgetter, BlockPos blockpos) { ++ protected int getHeightAboveUpToMax(BlockGetter level, BlockPos pos) { + int i; + +- for (i = 0; i < 16 && blockgetter.getBlockState(blockpos.above(i + 1)).is(Blocks.BAMBOO); ++i) { ++ for (i = 0; i < 16 && level.getBlockState(pos.above(i + 1)).is(Blocks.BAMBOO); ++i) { + ; + } + + return i; + } + +- protected int getHeightBelowUpToMax(BlockGetter blockgetter, BlockPos blockpos) { ++ protected int getHeightBelowUpToMax(BlockGetter level, BlockPos pos) { + int i; + +- for (i = 0; i < 16 && blockgetter.getBlockState(blockpos.below(i + 1)).is(Blocks.BAMBOO); ++i) { ++ for (i = 0; i < 16 && level.getBlockState(pos.below(i + 1)).is(Blocks.BAMBOO); ++i) { + ; + } + |