Skip to content

Commit

Permalink
Changed canSeeSky checks to use motion blocking heightmap instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Forstride committed Jan 7, 2024
1 parent e25c3f7 commit 72d0001
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import net.minecraft.world.level.block.CampfireBlock;
import net.minecraft.world.level.block.CopperBulbBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap;
import toughasnails.api.enchantment.TANEnchantments;
import toughasnails.api.player.ITANPlayer;
import toughasnails.api.potion.TANEffects;
import toughasnails.api.temperature.*;
import toughasnails.api.temperature.IProximityBlockModifier.Type;
import toughasnails.block.entity.ThermoregulatorBlockEntity;
import toughasnails.core.ToughAsNails;
import toughasnails.init.ModConfig;
import toughasnails.init.ModTags;

Expand Down Expand Up @@ -145,7 +145,7 @@ private static TemperatureLevel getBiomeTemperatureLevel(Level level, BlockPos p
Holder<Biome> biome = level.getBiome(pos);
float biomeTemperature = biome.value().getBaseTemperature();

if (!level.dimensionType().natural() || (pos.getY() > ModConfig.temperature.environmentalModifierAltitude || level.canSeeSky(pos)))
if (!level.dimensionType().natural() || (pos.getY() > ModConfig.temperature.environmentalModifierAltitude || pos.getY() >= level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos).below().getY()))
{
if (biome.is(ModTags.Biomes.ICY_BIOMES)) return TemperatureLevel.ICY;
else if (biome.is(ModTags.Biomes.COLD_BIOMES)) return TemperatureLevel.COLD;
Expand Down Expand Up @@ -191,7 +191,7 @@ private static TemperatureLevel nightModifier(Level level, BlockPos pos, Tempera
boolean isNight = time >= 0.25F && time <= 0.75F;

// Drop the temperature during the night
if (level.dimensionType().natural() && isNight && (pos.getY() > ModConfig.temperature.environmentalModifierAltitude || level.canSeeSky(pos)))
if (level.dimensionType().natural() && isNight && (pos.getY() > ModConfig.temperature.environmentalModifierAltitude || pos.getY() >= level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos).below().getY()))
{
if (current == TemperatureLevel.HOT)
current = current.increment(ModConfig.temperature.nightHotTemperatureChange);
Expand Down Expand Up @@ -347,7 +347,7 @@ protected static TemperatureLevel internalModifier(Player player, TemperatureLev

private static boolean isExposedToRain(Level level, BlockPos pos)
{
return level.isRaining() && level.canSeeSky(pos);
return level.isRaining() && pos.getY() >= level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos).below().getY();
}

private static boolean coldEnoughToSnow(Level level, Holder<Biome> biome, BlockPos pos)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.core.Holder;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraftforge.fml.ModList;
import sereneseasons.api.season.Season;
import sereneseasons.api.season.SeasonHelper;
Expand Down Expand Up @@ -39,7 +40,7 @@ private static TemperatureLevel seasonModifier(Level level, BlockPos pos, Temper
Holder<Biome> biome = level.getBiome(pos);

// Only adjust if above the environmental modifier altitude
if (level.dimensionType().natural() && pos.getY() <= ModConfig.temperature.environmentalModifierAltitude && !level.canSeeSky(pos))
if (level.dimensionType().natural() && pos.getY() <= ModConfig.temperature.environmentalModifierAltitude && pos.getY() < level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos).below().getY())
return current;

// Check if biome uses seasonal effects
Expand Down

0 comments on commit 72d0001

Please sign in to comment.