From 0a31fee28081037e1e1f8129429364e267f9d925 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 15 Dec 2022 09:14:55 +0000 Subject: [PATCH] Fixed oats not quite growing consistently --- .../unicopia/block/SegmentedCropBlock.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/block/SegmentedCropBlock.java b/src/main/java/com/minelittlepony/unicopia/block/SegmentedCropBlock.java index a71ba5bb..c792588b 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SegmentedCropBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/SegmentedCropBlock.java @@ -103,8 +103,23 @@ public class SegmentedCropBlock extends CropBlock implements SegmentedBlock { @Override public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - super.randomTick(state, world, pos, random); - propagateGrowth(world, pos, state); + 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); + } + } + } } private void propagateGrowth(World world, BlockPos pos, BlockState state) {