Fog rendering fixes
This commit is contained in:
parent
3cb78dd5a5
commit
c947af1211
3 changed files with 62 additions and 68 deletions
|
@ -27,9 +27,7 @@ public class CustomBackgroundRenderer {
|
||||||
private static float fogEnd = 192;
|
private static float fogEnd = 192;
|
||||||
|
|
||||||
public static boolean applyFogDensity(Camera camera, FogRenderer.FogMode fogMode, float viewDistance, boolean thickFog) {
|
public static boolean applyFogDensity(Camera camera, FogRenderer.FogMode fogMode, float viewDistance, boolean thickFog) {
|
||||||
FogType fogType = camera.getFluidInCamera();
|
if (fogMode != FogMode.FOG_SKY && fogMode != FogMode.FOG_TERRAIN) {
|
||||||
|
|
||||||
if (fogType == FogType.WATER || fogType == FogType.LAVA || fogMode != FogMode.FOG_SKY) {
|
|
||||||
BackgroundInfo.fogDensity = 1;
|
BackgroundInfo.fogDensity = 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +47,7 @@ public class CustomBackgroundRenderer {
|
||||||
fogEnd = Math.min(viewDistance, 192.0F) * 0.5F / fog;
|
fogEnd = Math.min(viewDistance, 192.0F) * 0.5F / fog;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fogStart = viewDistance * 0.75F / fog;
|
fogStart = 0;//viewDistance * 0.75F / fog;
|
||||||
fogEnd = viewDistance / fog;
|
fogEnd = viewDistance / fog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,63 +1,59 @@
|
||||||
package ru.bclib.mixin.client;
|
package ru.bclib.mixin.client;
|
||||||
|
|
||||||
import net.minecraft.client.Camera;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.renderer.FogRenderer;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.level.material.FogType;
|
import net.minecraft.world.level.Level;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import net.minecraft.world.level.material.FogType;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import ru.bclib.client.render.CustomBackgroundRenderer;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import ru.bclib.util.BackgroundInfo;
|
import ru.bclib.client.render.CustomBackgroundRenderer;
|
||||||
|
import ru.bclib.util.BackgroundInfo;
|
||||||
@Mixin(FogRenderer.class)
|
|
||||||
public class BackgroundRendererMixin {
|
@Mixin(FogRenderer.class)
|
||||||
private static final MutableBlockPos BCLIB_LAST_POS = new MutableBlockPos(0, -100, 0);
|
public class FogRendererMixin {
|
||||||
private static final MutableBlockPos BCLIB_MUT_POS = new MutableBlockPos();
|
@Shadow
|
||||||
private static final float[] BCLIB_FOG_DENSITY = new float[8];
|
private static float fogRed;
|
||||||
//private static boolean isEnd;
|
@Shadow
|
||||||
|
private static float fogGreen;
|
||||||
@Shadow
|
@Shadow
|
||||||
private static float fogRed;
|
private static float fogBlue;
|
||||||
@Shadow
|
|
||||||
private static float fogGreen;
|
@Inject(method = "setupColor", at = @At("RETURN"))
|
||||||
@Shadow
|
private static void bclib_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, CallbackInfo info) {
|
||||||
private static float fogBlue;
|
FogType fogType = camera.getFluidInCamera();
|
||||||
|
if (fogType != FogType.WATER && world.dimension().equals(Level.END)) {
|
||||||
@Inject(method = "setupColor", at = @At("RETURN"))
|
Entity entity = camera.getEntity();
|
||||||
private static void bclib_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, CallbackInfo info) {
|
boolean skip = false;
|
||||||
FogType fogType = camera.getFluidInCamera();
|
if (entity instanceof LivingEntity) {
|
||||||
if (fogType != FogType.WATER && world.dimension().equals(Level.END)) {
|
MobEffectInstance effect = ((LivingEntity) entity).getEffect(MobEffects.NIGHT_VISION);
|
||||||
Entity entity = camera.getEntity();
|
skip = effect != null && effect.getDuration() > 0;
|
||||||
boolean skip = false;
|
}
|
||||||
if (entity instanceof LivingEntity) {
|
if (!skip) {
|
||||||
MobEffectInstance effect = ((LivingEntity) entity).getEffect(MobEffects.NIGHT_VISION);
|
fogRed *= 4;
|
||||||
skip = effect != null && effect.getDuration() > 0;
|
fogGreen *= 4;
|
||||||
}
|
fogBlue *= 4;
|
||||||
if (!skip) {
|
}
|
||||||
fogRed *= 4;
|
}
|
||||||
fogGreen *= 4;
|
|
||||||
fogBlue *= 4;
|
BackgroundInfo.fogColorRed = fogRed;
|
||||||
}
|
BackgroundInfo.fogColorGreen = fogGreen;
|
||||||
}
|
BackgroundInfo.fogColorBlue = fogBlue;
|
||||||
|
}
|
||||||
BackgroundInfo.fogColorRed = fogRed;
|
|
||||||
BackgroundInfo.fogColorGreen = fogGreen;
|
@Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
|
||||||
BackgroundInfo.fogColorBlue = fogBlue;
|
private static void bclib_fogDensity(Camera camera, FogRenderer.FogMode fogMode, float viewDistance, boolean thickFog, CallbackInfo info) {
|
||||||
}
|
if (CustomBackgroundRenderer.applyFogDensity(camera, fogMode, viewDistance, thickFog)) {
|
||||||
|
info.cancel();
|
||||||
@Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
|
}
|
||||||
private static void bclib_fogDensity(Camera camera, FogRenderer.FogMode fogMode, float viewDistance, boolean thickFog, CallbackInfo info) {
|
}
|
||||||
if (CustomBackgroundRenderer.applyFogDensity(camera, fogMode, viewDistance, thickFog)) {
|
}
|
||||||
info.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,11 +6,11 @@
|
||||||
"client": [
|
"client": [
|
||||||
"SimpleReloadableResourceManagerMixin",
|
"SimpleReloadableResourceManagerMixin",
|
||||||
"EnchantingTableBlockMixin",
|
"EnchantingTableBlockMixin",
|
||||||
"BackgroundRendererMixin",
|
|
||||||
"ClientRecipeBookMixin",
|
"ClientRecipeBookMixin",
|
||||||
"ModelManagerMixin",
|
"ModelManagerMixin",
|
||||||
"TextureAtlasMixin",
|
"TextureAtlasMixin",
|
||||||
"AnvilScreenMixin",
|
"AnvilScreenMixin",
|
||||||
|
"FogRendererMixin",
|
||||||
"ModelBakeryMixin",
|
"ModelBakeryMixin",
|
||||||
"WorldPresetMixin",
|
"WorldPresetMixin",
|
||||||
"MinecraftMixin",
|
"MinecraftMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue