Created
February 18, 2013 03:14
-
-
Save mDiyo/4974919 to your computer and use it in GitHub Desktop.
Armor Model Interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.minecraftforge.common; | |
import net.minecraft.client.model.ModelBiped; | |
/** | |
* This interface has to be implemented by an instance of ItemArmor. | |
* It allows for the application of a custom model file to the player skin | |
* when the armor is worn. | |
*/ | |
public interface IArmorModelProvider | |
{ | |
/** | |
* This interface returns an instance of a model to render. | |
* Logic such as which parts to show are up to the implementation. | |
*/ | |
public ModelBiped provideArmorModel(int armorSlot); | |
} | |
/** | |
* Set the specified armor model as the player model. Args: player, armorSlot, partialTick | |
*/ | |
protected int setArmorModel(EntityPlayer par1EntityPlayer, int par2, float par3) | |
{ | |
ItemStack var4 = par1EntityPlayer.inventory.armorItemInSlot(3 - par2); | |
if (var4 != null) | |
{ | |
Item var5 = var4.getItem(); | |
if (var5 instanceof ItemArmor) | |
{ | |
ItemArmor var6 = (ItemArmor)var5; | |
this.loadTexture(ForgeHooksClient.getArmorTexture(var4, "/armor/" + armorFilenamePrefix[var6.renderIndex] + "_" + (par2 == 2 ? 2 : 1) + ".png")); | |
ModelBiped var7; | |
if (var5 instanceof IArmorModelProvider) | |
{ | |
var7 = ((IArmorModelProvider) var5).provideArmorModel(par2); | |
} | |
else | |
{ | |
var7 = par2 == 2 ? this.modelArmor : this.modelArmorChestplate; | |
var7.bipedHead.showModel = par2 == 0; | |
var7.bipedHeadwear.showModel = par2 == 0; | |
var7.bipedBody.showModel = par2 == 1 || par2 == 2; | |
var7.bipedRightArm.showModel = par2 == 1; | |
var7.bipedLeftArm.showModel = par2 == 1; | |
var7.bipedRightLeg.showModel = par2 == 2 || par2 == 3; | |
var7.bipedLeftLeg.showModel = par2 == 2 || par2 == 3; | |
} | |
this.setRenderPassModel(var7); | |
if (var7 != null) | |
{ | |
var7.onGround = this.mainModel.onGround; | |
} | |
if (var7 != null) | |
{ | |
var7.isRiding = this.mainModel.isRiding; | |
} | |
if (var7 != null) | |
{ | |
var7.isChild = this.mainModel.isChild; | |
} | |
float var8 = 1.0F; | |
if (var6.getArmorMaterial() == EnumArmorMaterial.CLOTH) | |
{ | |
int var9 = var6.getColor(var4); | |
float var10 = (float)(var9 >> 16 & 255) / 255.0F; | |
float var11 = (float)(var9 >> 8 & 255) / 255.0F; | |
float var12 = (float)(var9 & 255) / 255.0F; | |
GL11.glColor3f(var8 * var10, var8 * var11, var8 * var12); | |
if (var4.isItemEnchanted()) | |
{ | |
return 31; | |
} | |
return 16; | |
} | |
GL11.glColor3f(var8, var8, var8); | |
if (var4.isItemEnchanted()) | |
{ | |
return 15; | |
} | |
return 1; | |
} | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment