New hook to allow Items to provide there own armor models. Closes #487

This commit is contained in:
LexManos 2013-04-04 19:10:07 -07:00 committed by Christian
parent 0034a0c6c2
commit 2ee07bb250
4 changed files with 56 additions and 17 deletions

View file

@ -21,6 +21,7 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderEngine; import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.client.renderer.RenderGlobal;
@ -259,4 +260,10 @@ public class ForgeHooksClient
{ {
renderPass = pass; renderPass = pass;
} }
public static ModelBiped getArmorModel(EntityLiving entityLiving, ItemStack itemStack, int slotID, ModelBiped _default)
{
ModelBiped modelbiped = itemStack.getItem().getArmorModel(entityLiving, itemStack, slotID);
return modelbiped == null ? _default : modelbiped;
}
} }

View file

@ -25,7 +25,15 @@
ModelBiped modelbiped = par2 == 2 ? this.field_82425_h : this.field_82423_g; ModelBiped modelbiped = par2 == 2 ? this.field_82425_h : this.field_82423_g;
modelbiped.bipedHead.showModel = par2 == 0; modelbiped.bipedHead.showModel = par2 == 0;
modelbiped.bipedHeadwear.showModel = par2 == 0; modelbiped.bipedHeadwear.showModel = par2 == 0;
@@ -87,9 +93,10 @@ @@ -68,6 +74,7 @@
modelbiped.bipedLeftArm.showModel = par2 == 1;
modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3;
modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3;
+ modelbiped = ForgeHooksClient.getArmorModel(par1EntityLiving, itemstack, par2, modelbiped);
this.setRenderPassModel(modelbiped);
if (modelbiped != null)
@@ -87,9 +94,10 @@
float f1 = 1.0F; float f1 = 1.0F;
@ -39,7 +47,7 @@
float f2 = (float)(j >> 16 & 255) / 255.0F; float f2 = (float)(j >> 16 & 255) / 255.0F;
float f3 = (float)(j >> 8 & 255) / 255.0F; float f3 = (float)(j >> 8 & 255) / 255.0F;
float f4 = (float)(j & 255) / 255.0F; float f4 = (float)(j & 255) / 255.0F;
@@ -128,7 +135,7 @@ @@ -128,7 +136,7 @@
if (item instanceof ItemArmor) if (item instanceof ItemArmor)
{ {
ItemArmor itemarmor = (ItemArmor)item; ItemArmor itemarmor = (ItemArmor)item;
@ -48,7 +56,7 @@
float f1 = 1.0F; float f1 = 1.0F;
GL11.glColor3f(f1, f1, f1); GL11.glColor3f(f1, f1, f1);
} }
@@ -174,9 +181,12 @@ @@ -174,9 +182,12 @@
GL11.glPushMatrix(); GL11.glPushMatrix();
this.modelBipedMain.bipedHead.postRender(0.0625F); this.modelBipedMain.bipedHead.postRender(0.0625F);
@ -64,7 +72,7 @@
{ {
f2 = 0.625F; f2 = 0.625F;
GL11.glTranslatef(0.0F, -0.25F, 0.0F); GL11.glTranslatef(0.0F, -0.25F, 0.0F);
@@ -218,7 +228,10 @@ @@ -218,7 +229,10 @@
this.modelBipedMain.bipedRightArm.postRender(0.0625F); this.modelBipedMain.bipedRightArm.postRender(0.0625F);
GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F); GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);
@ -76,7 +84,7 @@
{ {
f2 = 0.5F; f2 = 0.5F;
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
@@ -265,7 +278,10 @@ @@ -265,7 +279,10 @@
if (itemstack.getItem().requiresMultipleRenderPasses()) if (itemstack.getItem().requiresMultipleRenderPasses())
{ {

View file

@ -32,7 +32,15 @@
ModelBiped modelbiped = par2 == 2 ? this.modelArmor : this.modelArmorChestplate; ModelBiped modelbiped = par2 == 2 ? this.modelArmor : this.modelArmorChestplate;
modelbiped.bipedHead.showModel = par2 == 0; modelbiped.bipedHead.showModel = par2 == 0;
modelbiped.bipedHeadwear.showModel = par2 == 0; modelbiped.bipedHeadwear.showModel = par2 == 0;
@@ -84,9 +92,10 @@ @@ -65,6 +73,7 @@
modelbiped.bipedLeftArm.showModel = par2 == 1;
modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3;
modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3;
+ modelbiped = ForgeHooksClient.getArmorModel(par1EntityPlayer, itemstack, par2, modelbiped);
this.setRenderPassModel(modelbiped);
if (modelbiped != null)
@@ -84,9 +93,10 @@
float f1 = 1.0F; float f1 = 1.0F;
@ -46,7 +54,7 @@
float f2 = (float)(j >> 16 & 255) / 255.0F; float f2 = (float)(j >> 16 & 255) / 255.0F;
float f3 = (float)(j >> 8 & 255) / 255.0F; float f3 = (float)(j >> 8 & 255) / 255.0F;
float f4 = (float)(j & 255) / 255.0F; float f4 = (float)(j & 255) / 255.0F;
@@ -125,7 +134,7 @@ @@ -125,7 +135,7 @@
if (item instanceof ItemArmor) if (item instanceof ItemArmor)
{ {
ItemArmor itemarmor = (ItemArmor)item; ItemArmor itemarmor = (ItemArmor)item;
@ -55,7 +63,7 @@
float f1 = 1.0F; float f1 = 1.0F;
GL11.glColor3f(f1, f1, f1); GL11.glColor3f(f1, f1, f1);
} }
@@ -184,9 +193,12 @@ @@ -184,9 +194,12 @@
this.modelBipedMain.bipedHead.postRender(0.0625F); this.modelBipedMain.bipedHead.postRender(0.0625F);
float f2; float f2;
@ -71,7 +79,7 @@
{ {
f2 = 0.625F; f2 = 0.625F;
GL11.glTranslatef(0.0F, -0.25F, 0.0F); GL11.glTranslatef(0.0F, -0.25F, 0.0F);
@@ -304,7 +316,10 @@ @@ -304,7 +317,10 @@
enumaction = itemstack1.getItemUseAction(); enumaction = itemstack1.getItemUseAction();
} }
@ -83,7 +91,7 @@
{ {
f3 = 0.5F; f3 = 0.5F;
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
@@ -361,7 +376,7 @@ @@ -361,7 +377,7 @@
if (itemstack1.getItem().requiresMultipleRenderPasses()) if (itemstack1.getItem().requiresMultipleRenderPasses())
{ {

View file

@ -1,14 +1,15 @@
--- ../src_base/minecraft/net/minecraft/item/Item.java --- ../src_base/minecraft/net/minecraft/item/Item.java
+++ ../src_work/minecraft/net/minecraft/item/Item.java +++ ../src_work/minecraft/net/minecraft/item/Item.java
@@ -7,6 +7,7 @@ @@ -7,6 +7,8 @@
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
+import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@@ -14,6 +15,7 @@ @@ -14,6 +16,7 @@
import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityPainting; import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -16,7 +17,7 @@
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionHelper; import net.minecraft.potion.PotionHelper;
import net.minecraft.stats.StatList; import net.minecraft.stats.StatList;
@@ -23,7 +25,10 @@ @@ -23,7 +26,10 @@
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import net.minecraft.util.StringTranslate; import net.minecraft.util.StringTranslate;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
@ -27,7 +28,7 @@
public class Item public class Item
{ {
@@ -238,13 +243,16 @@ @@ -238,13 +244,16 @@
/** Icon index in the icons table. */ /** Icon index in the icons table. */
protected Icon iconIndex; protected Icon iconIndex;
@ -45,7 +46,7 @@
} }
itemsList[256 + par1] = this; itemsList[256 + par1] = this;
@@ -640,6 +648,10 @@ @@ -640,6 +649,10 @@
float f7 = f4 * f5; float f7 = f4 * f5;
float f8 = f3 * f5; float f8 = f3 * f5;
double d3 = 5.0D; double d3 = 5.0D;
@ -56,7 +57,7 @@
Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3); Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3);
return par1World.rayTraceBlocks_do_do(vec3, vec31, par3, !par3); return par1World.rayTraceBlocks_do_do(vec3, vec31, par3, !par3);
} }
@@ -720,4 +732,380 @@ @@ -720,4 +733,395 @@
{ {
StatList.initStats(); StatList.initStats();
} }
@ -435,5 +436,20 @@
+ public FontRenderer getFontRenderer(ItemStack stack) + public FontRenderer getFontRenderer(ItemStack stack)
+ { + {
+ return null; + return null;
+ } + }
+
+ /**
+ * Override this method to have an item handle its own armor rendering.
+ *
+ * @param entityLiving The entity wearing the armor
+ * @param itemStack The itemStack to render the model of
+ * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet
+ *
+ * @return A ModelBiped to render instead of the default
+ */
+ @SideOnly(Side.CLIENT)
+ public ModelBiped getArmorModel(EntityLiving entityLiving, ItemStack itemStack, int armorSlot)
+ {
+ return null;
+ }
} }