diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/CactusBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/CactusBlock.java.patch | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/CactusBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CactusBlock.java.patch new file mode 100644 index 0000000000..b60b073829 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CactusBlock.java.patch @@ -0,0 +1,173 @@ +--- a/net/minecraft/world/level/block/CactusBlock.java ++++ b/net/minecraft/world/level/block/CactusBlock.java +@@ -1,6 +1,7 @@ + package net.minecraft.world.level.block; + + import com.mojang.serialization.MapCodec; ++import java.util.Iterator; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.server.level.ServerLevel; +@@ -13,107 +14,124 @@ + 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.pathfinder.PathComputationType; ++import net.minecraft.world.level.pathfinder.PathMode; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; ++import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + + public class CactusBlock extends Block { ++ + public static final MapCodec<CactusBlock> CODEC = simpleCodec(CactusBlock::new); + public static final IntegerProperty AGE = BlockStateProperties.AGE_15; + public static final int MAX_AGE = 15; + protected static final int AABB_OFFSET = 1; +- protected static final VoxelShape COLLISION_SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 15.0, 15.0); +- protected static final VoxelShape OUTLINE_SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 16.0, 15.0); ++ protected static final VoxelShape COLLISION_SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 15.0D, 15.0D); ++ protected static final VoxelShape OUTLINE_SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); + + @Override + public MapCodec<CactusBlock> codec() { +- return CODEC; ++ return CactusBlock.CODEC; + } + + protected CactusBlock(BlockBehaviour.Properties properties) { + super(properties); +- this.registerDefaultState(this.stateDefinition.any().setValue(AGE, Integer.valueOf(0))); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(CactusBlock.AGE, 0)); + } + + @Override +- public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { + if (!state.canSurvive(level, pos)) { + level.destroyBlock(pos, true); + } ++ + } + + @Override +- public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { +- BlockPos blockPos = pos.above(); +- if (level.isEmptyBlock(blockPos)) { +- int i = 1; ++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ BlockPos blockposition1 = pos.above(); + +- while (level.getBlockState(pos.below(i)).is(this)) { +- i++; ++ if (level.isEmptyBlock(blockposition1)) { ++ int i; ++ ++ for (i = 1; level.getBlockState(pos.below(i)).is((Block) this); ++i) { ++ ; + } + + if (i < 3) { +- int i1 = state.getValue(AGE); +- if (i1 == 15) { +- level.setBlockAndUpdate(blockPos, this.defaultBlockState()); +- BlockState blockState = state.setValue(AGE, Integer.valueOf(0)); +- level.setBlock(pos, blockState, 4); +- level.neighborChanged(blockState, blockPos, this, pos, false); ++ int j = (Integer) state.getValue(CactusBlock.AGE); ++ ++ if (j == 15) { ++ CraftEventFactory.handleBlockGrowEvent(level, blockposition1, this.defaultBlockState()); // CraftBukkit ++ IBlockData iblockdata1 = (IBlockData) state.setValue(CactusBlock.AGE, 0); ++ ++ level.setBlock(pos, iblockdata1, 4); ++ level.neighborChanged(iblockdata1, blockposition1, this, pos, false); + } else { +- level.setBlock(pos, state.setValue(AGE, Integer.valueOf(i1 + 1)), 4); ++ level.setBlock(pos, (IBlockData) state.setValue(CactusBlock.AGE, j + 1), 4); + } ++ + } + } + } + + @Override +- public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- return COLLISION_SHAPE; ++ public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return CactusBlock.COLLISION_SHAPE; + } + + @Override +- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- return OUTLINE_SHAPE; ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return CactusBlock.OUTLINE_SHAPE; + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { + if (!state.canSurvive(level, currentPos)) { +- level.scheduleTick(currentPos, this, 1); ++ level.scheduleTick(currentPos, (Block) this, 1); + } + + return super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } + + @Override +- public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { +- for (Direction direction : Direction.Plane.HORIZONTAL) { +- BlockState blockState = level.getBlockState(pos.relative(direction)); +- if (blockState.isSolid() || level.getFluidState(pos.relative(direction)).is(FluidTags.LAVA)) { +- return false; ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { ++ Iterator iterator = Direction.Plane.HORIZONTAL.iterator(); ++ ++ Direction enumdirection; ++ IBlockData iblockdata1; ++ ++ do { ++ if (!iterator.hasNext()) { ++ IBlockData iblockdata2 = level.getBlockState(pos.below()); ++ ++ return (iblockdata2.is(Blocks.CACTUS) || iblockdata2.is(BlockTags.SAND)) && !level.getBlockState(pos.above()).liquid(); + } +- } + +- BlockState blockState1 = level.getBlockState(pos.below()); +- return (blockState1.is(Blocks.CACTUS) || blockState1.is(BlockTags.SAND)) && !level.getBlockState(pos.above()).liquid(); ++ enumdirection = (Direction) iterator.next(); ++ iblockdata1 = level.getBlockState(pos.relative(enumdirection)); ++ } while (!iblockdata1.isSolid() && !level.getFluidState(pos.relative(enumdirection)).is(FluidTags.LAVA)); ++ ++ return false; + } + + @Override +- public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { ++ public void entityInside(IBlockData state, Level level, BlockPos pos, Entity entity) { ++ CraftEventFactory.blockDamage = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); // CraftBukkit + entity.hurt(level.damageSources().cactus(), 1.0F); ++ CraftEventFactory.blockDamage = null; // CraftBukkit + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(AGE); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(CactusBlock.AGE); + } + + @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; + } + } |