Fixed oats not quite growing consistently

This commit is contained in:
Sollace 2022-12-15 09:14:55 +00:00
parent ed22f638ae
commit 0a31fee280

View file

@ -103,9 +103,24 @@ public class SegmentedCropBlock extends CropBlock implements SegmentedBlock {
@Override @Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
super.randomTick(state, world, pos, random); BlockPos tip = getTip(world, pos);
BlockPos base = getRoot(world, pos);
if (base.getY() != pos.getY()) {
return;
}
if (world.getBaseLightLevel(tip, 0) >= 9) {
int age = getAge(state);
if (age < getMaxAge()) {
float moisture = CropBlock.getAvailableMoisture(world.getBlockState(base).getBlock(), world, base);
if (random.nextInt((int)(25F / moisture) + 1) == 0) {
world.setBlockState(pos, withAge(age + 1), Block.NOTIFY_LISTENERS);
propagateGrowth(world, pos, state); propagateGrowth(world, pos, state);
} }
}
}
}
private void propagateGrowth(World world, BlockPos pos, BlockState state) { private void propagateGrowth(World world, BlockPos pos, BlockState state) {
int oldAge = getAge(state); int oldAge = getAge(state);