Blindness render
This commit is contained in:
parent
254ebca012
commit
8dfb71478a
3 changed files with 66 additions and 40 deletions
|
@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
|
||||||
import net.minecraft.client.render.BackgroundRenderer;
|
import net.minecraft.client.render.BackgroundRenderer;
|
||||||
import net.minecraft.client.render.Camera;
|
import net.minecraft.client.render.Camera;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
@ -31,10 +30,6 @@ public class BackgroundRendererMixin {
|
||||||
private static float fogDensity;
|
private static float fogDensity;
|
||||||
private static float lerp;
|
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
|
@Shadow
|
||||||
private static float red;
|
private static float red;
|
||||||
@Shadow
|
@Shadow
|
||||||
|
@ -56,7 +51,6 @@ public class BackgroundRendererMixin {
|
||||||
skip = effect != null && effect.getDuration() > 0;
|
skip = effect != null && effect.getDuration() > 0;
|
||||||
}
|
}
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
//RenderSystem.clearColor(SKY_RED, SKY_GREEN, SKY_BLUE, 0);
|
|
||||||
red *= 4;
|
red *= 4;
|
||||||
green *= 4;
|
green *= 4;
|
||||||
blue *= 4;
|
blue *= 4;
|
||||||
|
@ -70,8 +64,8 @@ public class BackgroundRendererMixin {
|
||||||
|
|
||||||
@Inject(method = "applyFog", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "applyFog", at = @At("HEAD"), cancellable = true)
|
||||||
private static void fogDensity(Camera camera, BackgroundRenderer.FogType fogType, float viewDistance, boolean thickFog, CallbackInfo info) {
|
private static void fogDensity(Camera camera, BackgroundRenderer.FogType fogType, float viewDistance, boolean thickFog, CallbackInfo info) {
|
||||||
ClientPlayerEntity clientPlayerEntity = (ClientPlayerEntity) camera.getFocusedEntity();
|
Entity entity = camera.getFocusedEntity();
|
||||||
Biome biome = clientPlayerEntity.world.getBiome(clientPlayerEntity.getBlockPos());
|
Biome biome = entity.world.getBiome(entity.getBlockPos());
|
||||||
FluidState fluidState = camera.getSubmergedFluidState();
|
FluidState fluidState = camera.getSubmergedFluidState();
|
||||||
if (biome.getCategory() == Category.THEEND && fluidState.isEmpty()) {
|
if (biome.getCategory() == Category.THEEND && fluidState.isEmpty()) {
|
||||||
EndBiome endBiome = BiomeRegistry.getFromBiome(biome);
|
EndBiome endBiome = BiomeRegistry.getFromBiome(biome);
|
||||||
|
@ -88,8 +82,33 @@ public class BackgroundRendererMixin {
|
||||||
|
|
||||||
float fog = MathHelper.lerp(lerp, lastFogDensity, fogDensity);
|
float fog = MathHelper.lerp(lerp, lastFogDensity, fogDensity);
|
||||||
BackgroundInfo.fog = fog;
|
BackgroundInfo.fog = fog;
|
||||||
RenderSystem.fogStart(viewDistance * 0.75F / fog);
|
float start = viewDistance * 0.75F / fog;
|
||||||
RenderSystem.fogEnd(viewDistance / 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.fogMode(GlStateManager.FogMode.LINEAR);
|
||||||
RenderSystem.setupNvFogDistance();
|
RenderSystem.setupNvFogDistance();
|
||||||
info.cancel();
|
info.cancel();
|
||||||
|
|
|
@ -86,23 +86,27 @@ public class WorldRendererMixin {
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.enableTexture();
|
||||||
|
|
||||||
matrices.push();
|
float blindA = 1F - BackgroundInfo.blindness;
|
||||||
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();
|
|
||||||
|
|
||||||
matrices.push();
|
if (blindA > 0) {
|
||||||
matrices.multiply(new Quaternion(0, -time, 0, true));
|
matrices.push();
|
||||||
textureManager.bindTexture(NEBULA_1);
|
matrices.multiply(new Quaternion(0, time, 0, true));
|
||||||
renderBuffer(matrices, nebulas1, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F);
|
textureManager.bindTexture(HORIZON);
|
||||||
matrices.pop();
|
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 * 2, 0, true));
|
matrices.push();
|
||||||
textureManager.bindTexture(NEBULA_2);
|
matrices.multiply(new Quaternion(0, -time, 0, true));
|
||||||
renderBuffer(matrices, nebulas2, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F);
|
textureManager.bindTexture(NEBULA_1);
|
||||||
matrices.pop();
|
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);
|
float a = (BackgroundInfo.fog - 1F);
|
||||||
if (a > 0) {
|
if (a > 0) {
|
||||||
|
@ -113,20 +117,22 @@ public class WorldRendererMixin {
|
||||||
|
|
||||||
RenderSystem.disableTexture();
|
RenderSystem.disableTexture();
|
||||||
|
|
||||||
matrices.push();
|
if (blindA > 0) {
|
||||||
matrices.multiply(new Quaternion(axis1, time * 3, true));
|
matrices.push();
|
||||||
renderBuffer(matrices, stars1, VertexFormats.POSITION, 1, 1, 1, 0.6F);
|
matrices.multiply(new Quaternion(axis1, time * 3, true));
|
||||||
matrices.pop();
|
renderBuffer(matrices, stars1, VertexFormats.POSITION, 1, 1, 1, 0.6F * blindA);
|
||||||
|
matrices.pop();
|
||||||
matrices.push();
|
|
||||||
matrices.multiply(new Quaternion(axis2, time * 2, true));
|
matrices.push();
|
||||||
renderBuffer(matrices, stars2, VertexFormats.POSITION, 0.95F, 0.64F, 0.93F, 0.6F);
|
matrices.multiply(new Quaternion(axis2, time * 2, true));
|
||||||
matrices.pop();
|
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));
|
matrices.push();
|
||||||
renderBuffer(matrices, stars3, VertexFormats.POSITION, 0.77F, 0.31F, 0.73F, 0.6F);
|
matrices.multiply(new Quaternion(axis3, time, true));
|
||||||
matrices.pop();
|
renderBuffer(matrices, stars3, VertexFormats.POSITION, 0.77F, 0.31F, 0.73F, 0.6F * blindA);
|
||||||
|
matrices.pop();
|
||||||
|
}
|
||||||
|
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.enableTexture();
|
||||||
RenderSystem.depthMask(true);
|
RenderSystem.depthMask(true);
|
||||||
|
|
|
@ -5,4 +5,5 @@ public class BackgroundInfo {
|
||||||
public static float green;
|
public static float green;
|
||||||
public static float blue;
|
public static float blue;
|
||||||
public static float fog = 1;
|
public static float fog = 1;
|
||||||
|
public static float blindness;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue