From 16d18663d7b76c5b4cdea816b9f1528aed72a12d Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Tue, 26 Dec 2023 01:11:34 +0000 Subject: [PATCH] Fix minor issue with can-see-sky based filtering --- .../dev/lukebemish/tempest/impl/data/WeatherSpawnProvider.java | 3 ++- .../dev/lukebemish/tempest/impl/mixin/LivingEntityMixin.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/dev/lukebemish/tempest/impl/data/WeatherSpawnProvider.java b/common/src/main/java/dev/lukebemish/tempest/impl/data/WeatherSpawnProvider.java index fd43332..49330c6 100644 --- a/common/src/main/java/dev/lukebemish/tempest/impl/data/WeatherSpawnProvider.java +++ b/common/src/main/java/dev/lukebemish/tempest/impl/data/WeatherSpawnProvider.java @@ -16,6 +16,7 @@ import net.minecraft.util.random.WeightedRandomList; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.levelgen.Heightmap; import java.util.ArrayList; import java.util.EnumMap; @@ -30,7 +31,7 @@ public record WeatherSpawnProvider(WeatherStatus.Kind kind, List extendList(WeightedRandomList original, ServerLevel level, BlockPos pos, MobCategory mobCategory) { - if (level.canSeeSky(pos)) { + if (level.canSeeSky(pos) && level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos).getY() <= pos.getY()) { var kind = WeatherStatus.atPosition(level, pos).kind(); if (kind == WeatherStatus.Kind.CLEAR) { return original; diff --git a/common/src/main/java/dev/lukebemish/tempest/impl/mixin/LivingEntityMixin.java b/common/src/main/java/dev/lukebemish/tempest/impl/mixin/LivingEntityMixin.java index 181a54a..ba6719c 100644 --- a/common/src/main/java/dev/lukebemish/tempest/impl/mixin/LivingEntityMixin.java +++ b/common/src/main/java/dev/lukebemish/tempest/impl/mixin/LivingEntityMixin.java @@ -13,6 +13,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -73,7 +74,7 @@ public abstract class LivingEntityMixin extends Entity { private void tempest$baseTick(CallbackInfo ci) { if (this.isAlive()) { var pos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); - if (level().canSeeSky(pos)){ + if (level().canSeeSky(pos) && level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos).getY() <= pos.getY()){ var weatherData = Services.PLATFORM.getChunkData(this.level().getChunkAt(pos)); var status = weatherData.getWeatherStatusWindAware(pos); if (!this.level().isClientSide()) {