diff --git a/client/net/minecraftforge/client/event/RenderLivingEvent.java b/client/net/minecraftforge/client/event/RenderLivingEvent.java new file mode 100644 index 000000000..8f42ed2cd --- /dev/null +++ b/client/net/minecraftforge/client/event/RenderLivingEvent.java @@ -0,0 +1,35 @@ +package net.minecraftforge.client.event; + +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.event.Cancelable; +import net.minecraftforge.event.Event; + +public abstract class RenderLivingEvent extends Event +{ + public final EntityLiving entity; + public final RenderLiving renderer; + + public RenderLivingEvent(EntityLiving entity, RenderLiving renderer) + { + this.entity = entity; + this.renderer = renderer; + } + + public abstract static class Specials extends RenderLivingEvent + { + public Specials(EntityLiving entity, RenderLiving renderer){ super(entity, renderer); } + + @Cancelable + public static class Pre extends Specials + { + public Pre(EntityLiving entity, RenderLiving renderer){ super(entity, renderer); } + } + public static class Post extends Specials + { + public Post(EntityLiving entity, RenderLiving renderer){ super(entity, renderer); } + } + } +} diff --git a/client/net/minecraftforge/client/event/RenderPlayerEvent.java b/client/net/minecraftforge/client/event/RenderPlayerEvent.java new file mode 100644 index 000000000..e3355d647 --- /dev/null +++ b/client/net/minecraftforge/client/event/RenderPlayerEvent.java @@ -0,0 +1,72 @@ +package net.minecraftforge.client.event; + +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.Cancelable; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public abstract class RenderPlayerEvent extends PlayerEvent +{ + public final RenderPlayer renderer; + + public RenderPlayerEvent(EntityPlayer player, RenderPlayer renderer) + { + super(player); + this.renderer = renderer; + } + + @Cancelable + public static class Pre extends RenderPlayerEvent + { + public Pre(EntityPlayer player, RenderPlayer renderer){ super(player, renderer); } + } + + public static class Post extends RenderPlayerEvent + { + public Post(EntityPlayer player, RenderPlayer renderer){ super(player, renderer); } + } + + public abstract static class Specials extends RenderPlayerEvent + { + public final float partialTicks; + public Specials(EntityPlayer player, RenderPlayer renderer, float partialTicks) + { + super(player, renderer); + this.partialTicks = partialTicks; + } + + @Cancelable + public static class Pre extends Specials + { + public boolean renderHelmet = true; + public boolean renderCape = true; + public boolean renderItem = true; + public Pre(EntityPlayer player, RenderPlayer renderer, float partialTicks){ super(player, renderer, partialTicks); } + } + + public static class Post extends Specials + { + public Post(EntityPlayer player, RenderPlayer renderer, float partialTicks){ super(player, renderer, partialTicks); } + } + } + + public static class SetArmorModel extends RenderPlayerEvent + { + /** + * Setting this to any value besides -1 will result in the function being + * Immediately exited with the return value specified. + */ + public int result = -1; + public final int slot; + public final float partialTick; + public final ItemStack stack; + public SetArmorModel(EntityPlayer player, RenderPlayer renderer, int slot, float partialTick, ItemStack stack) + { + super(player, renderer); + this.slot = slot; + this.partialTick = partialTick; + this.stack = stack; + } + } +} \ No newline at end of file diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderLiving.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderLiving.java.patch new file mode 100644 index 000000000..e0c91b751 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderLiving.java.patch @@ -0,0 +1,44 @@ +--- ../src_base/minecraft/net/minecraft/client/renderer/entity/RenderLiving.java ++++ ../src_work/minecraft/net/minecraft/client/renderer/entity/RenderLiving.java +@@ -15,6 +15,9 @@ + import net.minecraft.entity.EntityLiving; + import net.minecraft.entity.projectile.EntityArrow; + import net.minecraft.util.MathHelper; ++import net.minecraftforge.client.event.RenderLivingEvent; ++import net.minecraftforge.common.MinecraftForge; ++ + import org.lwjgl.opengl.GL11; + import org.lwjgl.opengl.GL12; + +@@ -25,6 +28,8 @@ + + /** The model to be used during the render passes. */ + protected ModelBase renderPassModel; ++ public static float NAME_TAG_RANGE = 64.0f; ++ public static float NAME_TAG_RANGE_SNEAK = 32.0f; + + public RenderLiving(ModelBase par1ModelBase, float par2) + { +@@ -413,12 +418,13 @@ + */ + protected void passSpecialRender(EntityLiving par1EntityLiving, double par2, double par4, double par6) + { ++ if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Specials.Pre(par1EntityLiving, this))) return; + if (Minecraft.isGuiEnabled() && par1EntityLiving != this.renderManager.livingPlayer && !par1EntityLiving.func_98034_c(Minecraft.getMinecraft().thePlayer) && (par1EntityLiving.func_94059_bO() || par1EntityLiving.func_94056_bM() && par1EntityLiving == this.renderManager.field_96451_i)) + { + float f = 1.6F; + float f1 = 0.016666668F * f; + double d3 = par1EntityLiving.getDistanceSqToEntity(this.renderManager.livingPlayer); +- float f2 = par1EntityLiving.isSneaking() ? 32.0F : 64.0F; ++ float f2 = par1EntityLiving.isSneaking() ? NAME_TAG_RANGE_SNEAK : NAME_TAG_RANGE; + + if (d3 < (double)(f2 * f2)) + { +@@ -462,6 +468,7 @@ + } + } + } ++ MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Specials.Post(par1EntityLiving, this)); + } + + protected void func_96449_a(EntityLiving par1EntityLiving, double par2, double par4, double par6, String par8Str, float par9, double par10) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java.patch index da9da352d..724baf72e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java.patch @@ -1,12 +1,15 @@ --- ../src_base/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java +++ ../src_work/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java -@@ -19,7 +19,13 @@ +@@ -19,7 +19,16 @@ import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.MathHelper; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; ++import net.minecraftforge.client.event.RenderPlayerEvent; ++import net.minecraftforge.common.MinecraftForge; ++ import org.lwjgl.opengl.GL11; +import net.minecraft.item.ItemBlock; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; @@ -14,16 +17,32 @@ @SideOnly(Side.CLIENT) public class RenderPlayer extends RenderLiving -@@ -28,6 +34,8 @@ +@@ -28,6 +37,10 @@ private ModelBiped modelArmorChestplate; private ModelBiped modelArmor; public static String[] armorFilenamePrefix = new String[] {"cloth", "chain", "iron", "diamond", "gold"}; ++ @Deprecated //Old dead code, tags are now in RenderLiving + public static float NAME_TAG_RANGE = 64.0f; ++ @Deprecated //Old dead code, tags are now in RenderLiving + public static float NAME_TAG_RANGE_SNEAK = 32.0f; public RenderPlayer() { -@@ -56,7 +64,7 @@ +@@ -49,6 +62,13 @@ + { + ItemStack itemstack = par1EntityPlayer.inventory.armorItemInSlot(3 - par2); + ++ RenderPlayerEvent.SetArmorModel event = new RenderPlayerEvent.SetArmorModel(par1EntityPlayer, this, 3 - par2, par3, itemstack); ++ MinecraftForge.EVENT_BUS.post(event); ++ if (event.result != -1) ++ { ++ return event.result; ++ } ++ + if (itemstack != null) + { + Item item = itemstack.getItem(); +@@ -56,7 +76,7 @@ if (item instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor)item; @@ -32,7 +51,7 @@ ModelBiped modelbiped = par2 == 2 ? this.modelArmor : this.modelArmorChestplate; modelbiped.bipedHead.showModel = par2 == 0; modelbiped.bipedHeadwear.showModel = par2 == 0; -@@ -65,6 +73,7 @@ +@@ -65,6 +85,7 @@ modelbiped.bipedLeftArm.showModel = par2 == 1; modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3; modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3; @@ -40,7 +59,7 @@ this.setRenderPassModel(modelbiped); if (modelbiped != null) -@@ -84,9 +93,10 @@ +@@ -84,9 +105,10 @@ float f1 = 1.0F; @@ -54,7 +73,7 @@ float f2 = (float)(j >> 16 & 255) / 255.0F; float f3 = (float)(j >> 8 & 255) / 255.0F; float f4 = (float)(j & 255) / 255.0F; -@@ -125,7 +135,7 @@ +@@ -125,7 +147,7 @@ if (item instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor)item; @@ -63,7 +82,42 @@ float f1 = 1.0F; GL11.glColor3f(f1, f1, f1); } -@@ -184,9 +194,12 @@ +@@ -134,6 +156,7 @@ + + public void renderPlayer(EntityPlayer par1EntityPlayer, double par2, double par4, double par6, float par8, float par9) + { ++ if (MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Pre(par1EntityPlayer, this))) return; + float f2 = 1.0F; + GL11.glColor3f(f2, f2, f2); + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); +@@ -165,6 +188,7 @@ + this.modelArmorChestplate.aimedBow = this.modelArmor.aimedBow = this.modelBipedMain.aimedBow = false; + this.modelArmorChestplate.isSneak = this.modelArmor.isSneak = this.modelBipedMain.isSneak = false; + this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = 0; ++ MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Post(par1EntityPlayer, this)); + } + + /** +@@ -172,21 +196,30 @@ + */ + protected void renderSpecials(EntityPlayer par1EntityPlayer, float par2) + { ++ RenderPlayerEvent.Specials.Pre event = new RenderPlayerEvent.Specials.Pre(par1EntityPlayer, this, par2); ++ if (MinecraftForge.EVENT_BUS.post(event)) ++ { ++ return; ++ } ++ + float f1 = 1.0F; + GL11.glColor3f(f1, f1, f1); + super.renderEquippedItems(par1EntityPlayer, par2); + super.renderArrowsStuckInEntity(par1EntityPlayer, par2); + ItemStack itemstack = par1EntityPlayer.inventory.armorItemInSlot(3); + +- if (itemstack != null) ++ if (itemstack != null && event.renderHelmet) + { + GL11.glPushMatrix(); this.modelBipedMain.bipedHead.postRender(0.0625F); float f2; @@ -79,7 +133,25 @@ { f2 = 0.625F; GL11.glTranslatef(0.0F, -0.25F, 0.0F); -@@ -304,7 +317,11 @@ +@@ -238,7 +271,7 @@ + + float f6; + +- if (this.loadDownloadableImageTexture(par1EntityPlayer.cloakUrl, (String)null) && !par1EntityPlayer.isInvisible() && !par1EntityPlayer.getHideCape()) ++ if (event.renderCape && this.loadDownloadableImageTexture(par1EntityPlayer.cloakUrl, (String)null) && !par1EntityPlayer.isInvisible() && !par1EntityPlayer.getHideCape()) + { + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); +@@ -286,7 +319,7 @@ + + ItemStack itemstack1 = par1EntityPlayer.inventory.getCurrentItem(); + +- if (itemstack1 != null) ++ if (itemstack1 != null && event.renderItem) + { + GL11.glPushMatrix(); + this.modelBipedMain.bipedRightArm.postRender(0.0625F); +@@ -304,7 +337,11 @@ enumaction = itemstack1.getItemUseAction(); } @@ -92,7 +164,7 @@ { f3 = 0.5F; GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); -@@ -361,7 +378,7 @@ +@@ -361,7 +398,7 @@ if (itemstack1.getItem().requiresMultipleRenderPasses()) { @@ -101,3 +173,11 @@ { int k = itemstack1.getItem().getColorFromItemStack(itemstack1, j); f12 = (float)(k >> 16 & 255) / 255.0F; +@@ -383,6 +420,7 @@ + + GL11.glPopMatrix(); + } ++ MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Specials.Post(par1EntityPlayer, this, par2)); + } + + protected void renderPlayerScale(EntityPlayer par1EntityPlayer, float par2)