Private
Public Access
1
0

WIP: Implemented the rest of bonemeal block overrides.

This commit is contained in:
2025-06-05 01:42:34 +01:00
parent 2936944530
commit cec7583cf2

View File

@ -36,18 +36,22 @@ public class FireflyBushBlock extends BushBlock implements BonemealableBlock {
@Override @Override
public boolean isBonemealSuccess(Level pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) { public boolean isBonemealSuccess(Level pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) {
return false; return true;
} }
@Override @Override
public void performBonemeal(ServerLevel pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) { public void performBonemeal(ServerLevel pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) {
findSpreadableNeighbourPos(pLevel, pPos, pState).ifPresent(x -> pLevel.setBlockAndUpdate(x, this.defaultBlockState()));
} }
static boolean hasSpreadableNeighbourPos(LevelReader levelReader, BlockPos blockPos, BlockState blockState) { static boolean hasSpreadableNeighbourPos(LevelReader levelReader, BlockPos blockPos, BlockState blockState) {
return getSpreadableNeighbourPos(Direction.Plane.HORIZONTAL.stream().toList(), levelReader, blockPos, blockState).isPresent(); return getSpreadableNeighbourPos(Direction.Plane.HORIZONTAL.stream().toList(), levelReader, blockPos, blockState).isPresent();
} }
static Optional<BlockPos> findSpreadableNeighbourPos(Level level, BlockPos blockPos, BlockState blockState) {
return getSpreadableNeighbourPos(Direction.Plane.HORIZONTAL.shuffledCopy(level.random), level, blockPos, blockState);
}
static Optional<BlockPos> getSpreadableNeighbourPos(List<Direction> directions, LevelReader levelReader, BlockPos blockPos, BlockState blockState) { static Optional<BlockPos> getSpreadableNeighbourPos(List<Direction> directions, LevelReader levelReader, BlockPos blockPos, BlockState blockState) {
for (Direction direction : directions) { for (Direction direction : directions) {
BlockPos blockPosDirection = blockPos.relative(direction); BlockPos blockPosDirection = blockPos.relative(direction);