diff --git a/src/main/java/ru/betterend/mixin/client/BackgroundRendererMixin.java b/src/main/java/ru/betterend/mixin/client/BackgroundRendererMixin.java index 7f08a136..0ea8882b 100644 --- a/src/main/java/ru/betterend/mixin/client/BackgroundRendererMixin.java +++ b/src/main/java/ru/betterend/mixin/client/BackgroundRendererMixin.java @@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.BackgroundRenderer; import net.minecraft.client.render.Camera; import net.minecraft.client.world.ClientWorld; @@ -31,10 +30,6 @@ public class BackgroundRendererMixin { private static float fogDensity; private static float lerp; - //private static final float SKY_RED = 21F / 255F; - //private static final float SKY_GREEN = 16F / 255F; - //private static final float SKY_BLUE = 20F / 255F; - @Shadow private static float red; @Shadow @@ -56,7 +51,6 @@ public class BackgroundRendererMixin { skip = effect != null && effect.getDuration() > 0; } if (!skip) { - //RenderSystem.clearColor(SKY_RED, SKY_GREEN, SKY_BLUE, 0); red *= 4; green *= 4; blue *= 4; @@ -70,8 +64,8 @@ public class BackgroundRendererMixin { @Inject(method = "applyFog", at = @At("HEAD"), cancellable = true) private static void fogDensity(Camera camera, BackgroundRenderer.FogType fogType, float viewDistance, boolean thickFog, CallbackInfo info) { - ClientPlayerEntity clientPlayerEntity = (ClientPlayerEntity) camera.getFocusedEntity(); - Biome biome = clientPlayerEntity.world.getBiome(clientPlayerEntity.getBlockPos()); + Entity entity = camera.getFocusedEntity(); + Biome biome = entity.world.getBiome(entity.getBlockPos()); FluidState fluidState = camera.getSubmergedFluidState(); if (biome.getCategory() == Category.THEEND && fluidState.isEmpty()) { EndBiome endBiome = BiomeRegistry.getFromBiome(biome); @@ -88,8 +82,33 @@ public class BackgroundRendererMixin { float fog = MathHelper.lerp(lerp, lastFogDensity, fogDensity); BackgroundInfo.fog = fog; - RenderSystem.fogStart(viewDistance * 0.75F / fog); - RenderSystem.fogEnd(viewDistance / fog); + float start = viewDistance * 0.75F / fog; + float end = viewDistance / fog; + + if (entity instanceof LivingEntity) { + LivingEntity le = (LivingEntity) entity; + StatusEffectInstance effect = le.getStatusEffect(StatusEffects.BLINDNESS); + if (effect != null) { + int duration = effect.getDuration(); + if (duration > 20) { + start = 0; + end *= 0.03F; + BackgroundInfo.blindness = 1; + } + else { + float delta = (float) duration / 20F; + BackgroundInfo.blindness = delta; + start = MathHelper.lerp(delta, start, 0); + end = MathHelper.lerp(delta, end, end * 0.03F); + } + } + else { + BackgroundInfo.blindness = 0; + } + } + + RenderSystem.fogStart(start); + RenderSystem.fogEnd(end); RenderSystem.fogMode(GlStateManager.FogMode.LINEAR); RenderSystem.setupNvFogDistance(); info.cancel(); diff --git a/src/main/java/ru/betterend/mixin/client/WorldRendererMixin.java b/src/main/java/ru/betterend/mixin/client/WorldRendererMixin.java index e5cb8c5d..86f8a97e 100644 --- a/src/main/java/ru/betterend/mixin/client/WorldRendererMixin.java +++ b/src/main/java/ru/betterend/mixin/client/WorldRendererMixin.java @@ -86,23 +86,27 @@ public class WorldRendererMixin { RenderSystem.enableBlend(); RenderSystem.enableTexture(); - matrices.push(); - matrices.multiply(new Quaternion(0, time, 0, true)); - textureManager.bindTexture(HORIZON); - renderBuffer(matrices, horizon, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.7F); - matrices.pop(); + float blindA = 1F - BackgroundInfo.blindness; - matrices.push(); - matrices.multiply(new Quaternion(0, -time, 0, true)); - textureManager.bindTexture(NEBULA_1); - renderBuffer(matrices, nebulas1, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F); - matrices.pop(); - - matrices.push(); - matrices.multiply(new Quaternion(0, time * 2, 0, true)); - textureManager.bindTexture(NEBULA_2); - renderBuffer(matrices, nebulas2, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F); - matrices.pop(); + if (blindA > 0) { + matrices.push(); + matrices.multiply(new Quaternion(0, time, 0, true)); + textureManager.bindTexture(HORIZON); + renderBuffer(matrices, horizon, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.7F * blindA); + matrices.pop(); + + matrices.push(); + matrices.multiply(new Quaternion(0, -time, 0, true)); + textureManager.bindTexture(NEBULA_1); + renderBuffer(matrices, nebulas1, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F * blindA); + matrices.pop(); + + matrices.push(); + matrices.multiply(new Quaternion(0, time * 2, 0, true)); + textureManager.bindTexture(NEBULA_2); + renderBuffer(matrices, nebulas2, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F * blindA); + matrices.pop(); + } float a = (BackgroundInfo.fog - 1F); if (a > 0) { @@ -113,20 +117,22 @@ public class WorldRendererMixin { RenderSystem.disableTexture(); - matrices.push(); - matrices.multiply(new Quaternion(axis1, time * 3, true)); - renderBuffer(matrices, stars1, VertexFormats.POSITION, 1, 1, 1, 0.6F); - matrices.pop(); - - matrices.push(); - matrices.multiply(new Quaternion(axis2, time * 2, true)); - renderBuffer(matrices, stars2, VertexFormats.POSITION, 0.95F, 0.64F, 0.93F, 0.6F); - matrices.pop(); - - matrices.push(); - matrices.multiply(new Quaternion(axis3, time, true)); - renderBuffer(matrices, stars3, VertexFormats.POSITION, 0.77F, 0.31F, 0.73F, 0.6F); - matrices.pop(); + if (blindA > 0) { + matrices.push(); + matrices.multiply(new Quaternion(axis1, time * 3, true)); + renderBuffer(matrices, stars1, VertexFormats.POSITION, 1, 1, 1, 0.6F * blindA); + matrices.pop(); + + matrices.push(); + matrices.multiply(new Quaternion(axis2, time * 2, true)); + renderBuffer(matrices, stars2, VertexFormats.POSITION, 0.95F, 0.64F, 0.93F, 0.6F * blindA); + matrices.pop(); + + matrices.push(); + matrices.multiply(new Quaternion(axis3, time, true)); + renderBuffer(matrices, stars3, VertexFormats.POSITION, 0.77F, 0.31F, 0.73F, 0.6F * blindA); + matrices.pop(); + } RenderSystem.enableTexture(); RenderSystem.depthMask(true); diff --git a/src/main/java/ru/betterend/util/BackgroundInfo.java b/src/main/java/ru/betterend/util/BackgroundInfo.java index 24ab2ada..4ced89f2 100644 --- a/src/main/java/ru/betterend/util/BackgroundInfo.java +++ b/src/main/java/ru/betterend/util/BackgroundInfo.java @@ -5,4 +5,5 @@ public class BackgroundInfo { public static float green; public static float blue; public static float fog = 1; + public static float blindness; }