From 869a8d464ce6610db56ffe7cf73a1367d87a9e10 Mon Sep 17 00:00:00 2001 From: makamys Date: Mon, 10 May 2021 10:59:47 +0200 Subject: Setup fog distance using Forge event Fixes incompatibility with BOP --- src/main/java/makamys/lodmod/LODMod.java | 12 ++++++++++++ .../makamys/lodmod/mixin/MixinEntityRenderer.java | 19 ------------------- 2 files changed, 12 insertions(+), 19 deletions(-) (limited to 'src/main/java/makamys') diff --git a/src/main/java/makamys/lodmod/LODMod.java b/src/main/java/makamys/lodmod/LODMod.java index 87d6b1e..d388ea7 100644 --- a/src/main/java/makamys/lodmod/LODMod.java +++ b/src/main/java/makamys/lodmod/LODMod.java @@ -4,6 +4,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.potion.Potion; +import net.minecraftforge.client.event.EntityViewRenderEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.common.MinecraftForge; @@ -11,6 +13,7 @@ import net.minecraftforge.event.world.WorldEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; @@ -88,4 +91,13 @@ public class LODMod } } } + + @SubscribeEvent + public void onRenderFog(EntityViewRenderEvent.RenderFogEvent event) { + if(isActive()) { + if(event.fogMode >= 0 && !Minecraft.getMinecraft().theWorld.provider.doesXZShowFog((int)event.entity.posX, (int)event.entity.posZ)) { + GL11.glFogf(GL11.GL_FOG_START, event.farPlaneDistance * 0.2f); + } + } + } } diff --git a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java index 7f19e24..7a30512 100644 --- a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java +++ b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java @@ -1,19 +1,14 @@ package makamys.lodmod.mixin; -import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import makamys.lodmod.LODMod; -import makamys.lodmod.renderer.LODRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.potion.Potion; @Mixin(EntityRenderer.class) abstract class MixinEntityRenderer { @@ -36,18 +31,4 @@ abstract class MixinEntityRenderer { Minecraft.getMinecraft().entityRenderer.disableLightmap((double)alpha); } } - - @Redirect(method = "setupFog", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V")) - private void afterSetupFog(int pname, float param, int mode, float alpha) { - if(LODMod.isActive()) { - EntityLivingBase var3 = Minecraft.getMinecraft().renderViewEntity; - if(pname == GL11.GL_FOG_START && mode != 999 && mode != -1 && !var3.isPotionActive(Potion.blindness) && !Minecraft.getMinecraft().theWorld.provider.doesXZShowFog((int)var3.posX, (int)var3.posZ)) { - GL11.glFogf(pname, farPlaneDistance * 0.2f); - } else { - GL11.glFogf(pname, param); - } - } else { - GL11.glFogf(pname, param); - } - } } -- cgit