Skip to content

Commit

Permalink
Fix minor issue with can-see-sky based filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Dec 26, 2023
1 parent 3c3156f commit 16d1866
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,7 +31,7 @@ public record WeatherSpawnProvider(WeatherStatus.Kind kind, List<MobSpawnSetting
).apply(i, WeatherSpawnProvider::new));

public static WeightedRandomList<MobSpawnSettings.SpawnerData> extendList(WeightedRandomList<MobSpawnSettings.SpawnerData> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 16d1866

Please sign in to comment.