diff options
author | makamys <makamys@outlook.com> | 2021-05-23 04:33:47 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-23 04:33:47 +0200 |
commit | 79cd910660eb3caa9e181772372e920a3b92c7ee (patch) | |
tree | 18c6732e2204806276a1911c86482af94224afe8 /src/main/java/makamys/lodmod | |
parent | f4a4f95cc14f4f8888ee6dc26fbbe529c588ff9d (diff) | |
download | Neodymium-79cd910660eb3caa9e181772372e920a3b92c7ee.tar.gz Neodymium-79cd910660eb3caa9e181772372e920a3b92c7ee.tar.bz2 Neodymium-79cd910660eb3caa9e181772372e920a3b92c7ee.zip |
Override fog of other mods
Diffstat (limited to 'src/main/java/makamys/lodmod')
-rw-r--r-- | src/main/java/makamys/lodmod/LODMod.java | 13 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java | 14 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODRenderer.java | 2 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/main/java/makamys/lodmod/LODMod.java b/src/main/java/makamys/lodmod/LODMod.java index 1ca08f5..91f965f 100644 --- a/src/main/java/makamys/lodmod/LODMod.java +++ b/src/main/java/makamys/lodmod/LODMod.java @@ -4,7 +4,6 @@ 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; @@ -17,7 +16,6 @@ import java.io.File; 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; @@ -45,6 +43,8 @@ public class LODMod private File configFile; + public static boolean fogEventWasPosted; + @EventHandler public void preInit(FMLPreInitializationEvent event) { @@ -131,14 +131,11 @@ 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); - GL11.glFogf(GL11.GL_FOG_END, event.farPlaneDistance); - } - } + fogEventWasPosted = true; } + } diff --git a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java index eb3341a..dda56a4 100644 --- a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java +++ b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java @@ -1,14 +1,17 @@ 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 net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.entity.EntityLivingBase; @Mixin(EntityRenderer.class) abstract class MixinEntityRenderer { @@ -22,4 +25,15 @@ abstract class MixinEntityRenderer { farPlaneDistance *= LODMod.renderer.getFarPlaneDistanceMultiplier(); } } + + @Inject(method = "setupFog", at = @At(value = "RETURN")) + private void afterSetupFog(int mode, float alpha, CallbackInfo ci) { + if(LODMod.isActive()) { + EntityLivingBase entity = Minecraft.getMinecraft().renderViewEntity; + if(LODMod.fogEventWasPosted && mode >= 0 && !Minecraft.getMinecraft().theWorld.provider.doesXZShowFog((int)entity.posX, (int)entity.posZ)) { + GL11.glFogf(GL11.GL_FOG_START, farPlaneDistance * 0.2f); + GL11.glFogf(GL11.GL_FOG_END, farPlaneDistance); + } + } + } } diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 129bf70..d4217b7 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -101,6 +101,8 @@ public class LODRenderer { public void preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[] sortedWorldRenderers) { if(renderPass != 0) return; + LODMod.fogEventWasPosted = false; + Minecraft.getMinecraft().entityRenderer.enableLightmap((double)alpha); if(hasInited) { |