50 lines
1.9 KiB
Java
50 lines
1.9 KiB
Java
/*
|
|
* 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 BlindnessFogEnvironment
|
|
extends MobEffectFogEnvironment {
|
|
@Override
|
|
public Holder<MobEffect> getMobEffect() {
|
|
return MobEffects.BLINDNESS;
|
|
}
|
|
|
|
@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 = effect.isInfiniteDuration() ? 5.0f : Mth.lerp(Math.min(1.0f, (float)effect.getDuration() / 20.0f), renderDistance, 5.0f);
|
|
fog.environmentalStart = distance * 0.25f;
|
|
fog.environmentalEnd = distance;
|
|
fog.skyEnd = distance * 0.8f;
|
|
fog.cloudEnd = distance * 0.8f;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public float getModifiedDarkness(LivingEntity entity, float darkness, float partialTickTime) {
|
|
MobEffectInstance instance = entity.getEffect(this.getMobEffect());
|
|
if (instance != null) {
|
|
darkness = instance.endsWithin(19) ? Math.max((float)instance.getDuration() / 20.0f, darkness) : 1.0f;
|
|
}
|
|
return darkness;
|
|
}
|
|
}
|
|
|