Merge pull request #1126 from Cojomax99/fog_customization
World fog color and density can now be controlled through an event
This commit is contained in:
commit
a08357a845
2 changed files with 90 additions and 0 deletions
|
@ -165,3 +165,31 @@
|
|||
float f1 = this.field_78531_r.field_71441_e.func_72867_j(p_78474_1_);
|
||||
|
||||
if (f1 > 0.0F)
|
||||
@@ -1774,6 +1810,13 @@
|
||||
this.field_78533_p = f7;
|
||||
}
|
||||
|
||||
+ net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(this, entitylivingbase, block, p_78466_1_, this.field_78518_n, this.field_78519_o, this.field_78533_p);
|
||||
+ MinecraftForge.EVENT_BUS.post(event);
|
||||
+
|
||||
+ this.field_78518_n = event.red;
|
||||
+ this.field_78533_p = event.blue;
|
||||
+ this.field_78519_o = event.green;
|
||||
+
|
||||
GL11.glClearColor(this.field_78518_n, this.field_78519_o, this.field_78533_p, 0.0F);
|
||||
}
|
||||
|
||||
@@ -1809,6 +1852,13 @@
|
||||
Block block = ActiveRenderInfo.func_151460_a(this.field_78531_r.field_71441_e, entitylivingbase, p_78468_2_);
|
||||
float f1;
|
||||
|
||||
+ net.minecraftforge.client.event.EntityViewRenderEvent.FogDensity event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogDensity(this, entitylivingbase, block, 0.1F, p_78468_2_);
|
||||
+
|
||||
+ if (MinecraftForge.EVENT_BUS.post(event))
|
||||
+ {
|
||||
+ GL11.glFogf(GL11.GL_FOG_DENSITY, event.density);
|
||||
+ }
|
||||
+ else
|
||||
if (entitylivingbase.func_70644_a(Potion.field_76440_q))
|
||||
{
|
||||
f1 = 5.0F;
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Event that hooks into EntityRenderer, allowing any feature to customize visual attributes of
|
||||
* fog the player sees.
|
||||
*/
|
||||
public abstract class EntityViewRenderEvent extends Event
|
||||
{
|
||||
public final EntityRenderer renderer;
|
||||
public final EntityLivingBase entity;
|
||||
public final Block block;
|
||||
public final double renderPartialTicks;
|
||||
|
||||
public EntityViewRenderEvent(EntityRenderer renderer, EntityLivingBase entity, Block block, double renderPartialTicks)
|
||||
{
|
||||
this.renderer = renderer;
|
||||
this.entity = entity;
|
||||
this.block = block;
|
||||
this.renderPartialTicks = renderPartialTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event that allows any feature to customize the fog density the player sees.
|
||||
* NOTE: In order to make this event have an effect, you must cancel the event
|
||||
*/
|
||||
@Cancelable
|
||||
public static class FogDensity extends EntityViewRenderEvent
|
||||
{
|
||||
public float density;
|
||||
|
||||
public FogDensity(EntityRenderer renderer, EntityLivingBase entity, Block block, double renderPartialTicks, float density)
|
||||
{
|
||||
super(renderer, entity, block, renderPartialTicks);
|
||||
this.density = density;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event that allows any feature to customize the color of fog the player sees.
|
||||
* NOTE: Any change made to one of the color variables will affect the result seen in-game.
|
||||
*/
|
||||
public static class FogColors extends EntityViewRenderEvent
|
||||
{
|
||||
public float red;
|
||||
public float green;
|
||||
public float blue;
|
||||
|
||||
public FogColors(EntityRenderer renderer, EntityLivingBase entity, Block block, double renderPartialTicks, float red, float green, float blue)
|
||||
{
|
||||
super(renderer, entity, block, renderPartialTicks);
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue