From 2affeae979c4e763b763bb39cf8970108aafa887 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 27 Jul 2014 15:20:42 +1000 Subject: [PATCH] Added an event for fog rendering --- .../client/renderer/EntityRenderer.java.patch | 8 ++++++++ .../client/event/EntityViewRenderEvent.java | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch index 4455ef186..5f225cb14 100644 --- a/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -193,3 +193,11 @@ if (entitylivingbase.func_70644_a(Potion.field_76440_q)) { f1 = 5.0F; +@@ -1930,6 +1980,7 @@ + GL11.glFogf(GL11.GL_FOG_START, f1 * 0.05F); + GL11.glFogf(GL11.GL_FOG_END, Math.min(f1, 192.0F) * 0.5F); + } ++ MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.EntityViewRenderEvent.RenderFogEvent(this, entitylivingbase, block, p_78468_2_, p_78468_1_, f1)); + } + + GL11.glEnable(GL11.GL_COLOR_MATERIAL); diff --git a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java index 425ef3824..1121cdda9 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java @@ -5,6 +5,7 @@ import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.entity.EntityLivingBase; import cpw.mods.fml.common.eventhandler.Cancelable; import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.Event.Result; /** * Event that hooks into EntityRenderer, allowing any feature to customize visual attributes of @@ -40,6 +41,23 @@ public abstract class EntityViewRenderEvent extends Event this.density = density; } } + + /** + * Event that allows any feature to customize the rendering of fog. + */ + @HasResult + public static class RenderFogEvent extends EntityViewRenderEvent + { + public final int fogMode; + public final float farPlaneDistance; + + public RenderFogEvent(EntityRenderer renderer, EntityLivingBase entity, Block block, double renderPartialTicks, int fogMode, float farPlaneDistance) + { + super(renderer, entity, block, renderPartialTicks); + this.fogMode = fogMode; + this.farPlaneDistance = farPlaneDistance; + } + } /** * Event that allows any feature to customize the color of fog the player sees.