Fixed storm clouds not spawning lightning in the correct place

This commit is contained in:
Sollace 2023-10-19 23:45:14 +01:00
parent c3fee217d1
commit 84cb3de5e3
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -257,19 +257,22 @@ public class StormCloudEntity extends Entity implements MagicImmune {
private void pickRandomPoints(int count, Consumer<BlockPos> action) { private void pickRandomPoints(int count, Consumer<BlockPos> action) {
BlockPos.iterateRandomly(random, 3, getBlockPos(), getSizeInBlocks()).forEach(pos -> { BlockPos.iterateRandomly(random, 3, getBlockPos(), getSizeInBlocks()).forEach(pos -> {
action.accept(findSurfaceBelow(getWorld(), pos));
});
}
public static BlockPos findSurfaceBelow(World world, BlockPos pos) {
BlockPos.Mutable mutable = new BlockPos.Mutable(); BlockPos.Mutable mutable = new BlockPos.Mutable();
mutable.set(pos); mutable.set(pos);
while (getWorld().isInBuildLimit(mutable) && getWorld().isAir(mutable)) { while (world.isInBuildLimit(mutable) && world.isAir(mutable)) {
mutable.move(Direction.DOWN); mutable.move(Direction.DOWN);
} }
while (getWorld().isInBuildLimit(mutable) && !getWorld().isAir(mutable)) { while (world.isInBuildLimit(mutable) && !world.isAir(mutable)) {
mutable.move(Direction.UP); mutable.move(Direction.UP);
} }
mutable.move(Direction.DOWN); mutable.move(Direction.DOWN);
action.accept(pos); return mutable;
});
} }
private void spawnLightningStrike(BlockPos pos, boolean cosmetic, boolean infect) { private void spawnLightningStrike(BlockPos pos, boolean cosmetic, boolean infect) {