/* * Decompiled with CFR 0.152. */ package net.minecraft.client.renderer.fog.environment; import net.minecraft.client.Camera; import net.minecraft.client.DeltaTracker; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.fog.FogData; import net.minecraft.client.renderer.fog.environment.MobEffectFogEnvironment; import net.minecraft.core.Holder; import net.minecraft.util.Mth; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; public class DarknessFogEnvironment extends MobEffectFogEnvironment { @Override public Holder getMobEffect() { return MobEffects.DARKNESS; } @Override public void setupFog(FogData fog, Camera camera, ClientLevel level, float renderDistance, DeltaTracker deltaTracker) { LivingEntity livingEntity; MobEffectInstance effect; Entity entity = camera.entity(); if (entity instanceof LivingEntity && (effect = (livingEntity = (LivingEntity)entity).getEffect(this.getMobEffect())) != null) { float distance = Mth.lerp(effect.getBlendFactor(livingEntity, deltaTracker.getGameTimeDeltaPartialTick(false)), renderDistance, 15.0f); fog.environmentalStart = distance * 0.75f; fog.environmentalEnd = distance; fog.skyEnd = distance; fog.cloudEnd = distance; } } @Override public float getModifiedDarkness(LivingEntity entity, float darkness, float partialTickTime) { MobEffectInstance instance = entity.getEffect(this.getMobEffect()); return instance != null ? Math.max(instance.getBlendFactor(entity, partialTickTime), darkness) : darkness; } }