@Mixin(BackgroundRenderer.class)
public class FoggyDimMixin {
@Unique
private static final float NIGHT_FOG_END = 52f;
@Unique
private static float fogEnd = NIGHT_FOG_END;
@Inject(method = "applyFog",at = @At(value = "TAIL"))
private static void applyFog(Camera camera, BackgroundRenderer.FogType fogType, float viewDistance, boolean thickFog, float tickDelta, CallbackInfo ci){
Entity entity = camera.getFocusedEntity();
ClientWorld world = (ClientWorld) entity.getWorld();
if (world.getRegistryKey() != FoggyDimension.FOGGYFOREST_KEY) {
return;
}
world.calculateAmbientDarkness();
float darkness = MathHelper.clamp(Math.round(world.getAmbientDarkness() / 11.0f),0f,1f);
fogEnd = MathUtils.lerp(fogEnd,MathUtils.lerp(viewDistance,NIGHT_FOG_END,darkness),tickDelta * 0.01f);
if (fogType == BackgroundRenderer.FogType.FOG_TERRAIN) {
RenderSystem.setShaderFogStart(0f);
RenderSystem.setShaderFogEnd(fogEnd);
RenderSystem.setShaderFogShape(FogShape.SPHERE);
} // вся магия с туманом
}
}