diff --git a/src/main/java/com/minelittlepony/unicopia/entity/mob/StormCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/mob/StormCloudEntity.java index f522b812..828b2593 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/mob/StormCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/mob/StormCloudEntity.java @@ -257,21 +257,24 @@ public class StormCloudEntity extends Entity implements MagicImmune { private void pickRandomPoints(int count, Consumer action) { BlockPos.iterateRandomly(random, 3, getBlockPos(), getSizeInBlocks()).forEach(pos -> { - - BlockPos.Mutable mutable = new BlockPos.Mutable(); - mutable.set(pos); - while (getWorld().isInBuildLimit(mutable) && getWorld().isAir(mutable)) { - mutable.move(Direction.DOWN); - } - while (getWorld().isInBuildLimit(mutable) && !getWorld().isAir(mutable)) { - mutable.move(Direction.UP); - } - mutable.move(Direction.DOWN); - - action.accept(pos); + action.accept(findSurfaceBelow(getWorld(), pos)); }); } + public static BlockPos findSurfaceBelow(World world, BlockPos pos) { + BlockPos.Mutable mutable = new BlockPos.Mutable(); + mutable.set(pos); + while (world.isInBuildLimit(mutable) && world.isAir(mutable)) { + mutable.move(Direction.DOWN); + } + while (world.isInBuildLimit(mutable) && !world.isAir(mutable)) { + mutable.move(Direction.UP); + } + mutable.move(Direction.DOWN); + + return mutable; + } + private void spawnLightningStrike(BlockPos pos, boolean cosmetic, boolean infect) { if (infect) { if (!CrystalShardsEntity.infestBlock((ServerWorld)getWorld(), pos)) {