Item Colorable
-
Bonjour à tous ! Pour des raisons qui ne doivent pas êtres connus, je cherche a pouvoir coloriser une armure. J’ai tout de suite foncé dans la classe ItemArmor, récupéré 2-3 fonctions, mais mon Item ne veux pas se colorer dans la table de craft.
La classe :
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import assets.mgs.common.D_Tabs; import assets.mgs.common.Main; import assets.shirt.Data.TShirtMod; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class Marcel extends ItemArmor { public Marcel(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4) { super(par1, par2EnumArmorMaterial, par3, par4); this.setCreativeTab(TShirtMod.mar); this.setMaxDamage(0); this.setHasSubtypes(true); } public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) { if (stack.itemID == TShirtMod.Marcel.itemID) { return "shirt:textures/models/marcel.png"; } else { return "shirt:textures/models/marcel.png"; } } /** * Return the color for the specified armor ItemStack. */ public int getColor(ItemStack par1ItemStack) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) { return 10511680; } else { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); return nbttagcompound1 == null ? 10511680 : (nbttagcompound1.hasKey("color") ? nbttagcompound1.getInteger("color") : 10511680); } } public void func_82813_b(ItemStack par1ItemStack, int par2) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) { nbttagcompound = new NBTTagCompound(); par1ItemStack.setTagCompound(nbttagcompound); } NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); if (!nbttagcompound.hasKey("display")) { nbttagcompound.setCompoundTag("display", nbttagcompound1); } nbttagcompound1.setInteger("color", par2); } public void removeColor(ItemStack par1ItemStack) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound != null) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); if (nbttagcompound1.hasKey("color")) { nbttagcompound1.removeTag("color"); } } } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { itemIcon = par1IconRegister.registerIcon("shirt:marcel"); } public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { return true; } }
#Je pense ( donc je suis )(Je pense ( donc je suis ))
Que le probléme vient du fait que ce ne soit pas un item a MetaData ?
Merci d’avance de vos réponses.
-
La couleur de l’item est modifié lors du craft donc regarde la classe RecipesArmorDye et crée toi aussi ta classe implémenté avec IRecipe.
Après il ce peut qu’il faut aussi faire un render spécial si celui vanilla ne prend pas en compte tout les items. -
import java.util.ArrayList; import net.minecraft.block.BlockColored; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; public class RecipeArmorDye implements IRecipe { /** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) { ItemStack itemstack = null; ArrayList arraylist = new ArrayList(); for (int i = 0; i < par1InventoryCrafting.getSizeInventory(); ++i) { ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i); if (itemstack1 != null) { if (itemstack1.getItem() instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor)itemstack1.getItem(); if (itemarmor.getArmorMaterial() != TShirtMod.Misc || itemstack != null) { return false; } itemstack = itemstack1; } else { if (itemstack1.itemID != Item.dyePowder.itemID) { return false; } arraylist.add(itemstack1); } } } return itemstack != null && !arraylist.isEmpty(); } /** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) { ItemStack itemstack = null; int[] aint = new int[3]; int i = 0; int j = 0; ItemArmor itemarmor = null; int k; int l; float f; float f1; int i1; for (k = 0; k < par1InventoryCrafting.getSizeInventory(); ++k) { ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(k); if (itemstack1 != null) { if (itemstack1.getItem() instanceof ItemArmor) { itemarmor = (ItemArmor)itemstack1.getItem(); if (itemarmor.getArmorMaterial() != TShirtMod.Misc || itemstack != null) { return null; } itemstack = itemstack1.copy(); itemstack.stackSize = 1; if (itemarmor.hasColor(itemstack1)) { l = itemarmor.getColor(itemstack); f = (float)(l >> 16 & 255) / 255.0F; f1 = (float)(l >> 8 & 255) / 255.0F; float f2 = (float)(l & 255) / 255.0F; i = (int)((float)i + Math.max(f, Math.max(f1, f2)) * 255.0F); aint[0] = (int)((float)aint[0] + f * 255.0F); aint[1] = (int)((float)aint[1] + f1 * 255.0F); aint[2] = (int)((float)aint[2] + f2 * 255.0F); ++j; } } else { if (itemstack1.itemID != Item.dyePowder.itemID) { return null; } float[] afloat = EntitySheep.fleeceColorTable[BlockColored.getBlockFromDye(itemstack1.getItemDamage())]; int j1 = (int)(afloat[0] * 255.0F); int k1 = (int)(afloat[1] * 255.0F); i1 = (int)(afloat[2] * 255.0F); i += Math.max(j1, Math.max(k1, i1)); aint[0] += j1; aint[1] += k1; aint[2] += i1; ++j; } } } if (itemarmor == null) { return null; } else { k = aint[0] / j; int l1 = aint[1] / j; l = aint[2] / j; f = (float)i / (float)j; f1 = (float)Math.max(k, Math.max(l1, l)); k = (int)((float)k * f / f1); l1 = (int)((float)l1 * f / f1); l = (int)((float)l * f / f1); i1 = (k << 8) + l1; i1 = (i1 << 8) + l; itemarmor.func_82813_b(itemstack, i1); return itemstack; } } /** * Returns the size of the recipe area */ public int getRecipeSize() { return 10; } public ItemStack getRecipeOutput() { return null; } }
Elle ne change pas grand chose ( j’ai remplacé enumArmorMaterial.CLOTH par le material de mon armure)
Et, du coté de l’itemimport net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import assets.mgs.common.D_Tabs; import assets.mgs.common.Main; import assets.shirt.Data.TShirtMod; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class Marcel extends ItemArmor { private final EnumArmorMaterial material; public Marcel(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4) { super(par1, par2EnumArmorMaterial, par3, par4); this.setCreativeTab(TShirtMod.mar); this.setMaxDamage(0); this.setHasSubtypes(true); this.material = par2EnumArmorMaterial; } public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) { if (stack.itemID == TShirtMod.Marcel.itemID) { return "shirt:textures/models/marcel.png"; } else { return "shirt:textures/models/marcel.png"; } } /** * Return the color for the specified armor ItemStack. */ public int getColor(ItemStack par1ItemStack) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) { return 10511680; } else { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); return nbttagcompound1 == null ? 10511680 : (nbttagcompound1.hasKey("color") ? nbttagcompound1.getInteger("color") : 10511680); } } public void func_82813_b(ItemStack par1ItemStack, int par2) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) { nbttagcompound = new NBTTagCompound(); par1ItemStack.setTagCompound(nbttagcompound); } NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); if (!nbttagcompound.hasKey("display")) { nbttagcompound.setCompoundTag("display", nbttagcompound1); } nbttagcompound1.setInteger("color", par2); } public void removeColor(ItemStack par1ItemStack) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound != null) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); if (nbttagcompound1.hasKey("color")) { nbttagcompound1.removeTag("color"); } } } public boolean hasColor(ItemStack par1ItemStack) { return this.material != TShirtMod.Misc ? false : (!par1ItemStack.hasTagCompound() ? false : (!par1ItemStack.getTagCompound().hasKey("display") ? false : par1ItemStack.getTagCompound().getCompoundTag("display").hasKey("color"))); } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { itemIcon = par1IconRegister.registerIcon("shirt:marcel"); } public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { return true; } }
-
Il faut enregistrer le custom IRecipe :
GameRegistry.addRecipe(new RecipeArmorDye()); -
C’était donc aussi simple ‘-’ ?
Par contre, le render de l’armure n’est pas coloré
-
Ça c’est sûrement géré dans RenderPlayer et/ou dans RenderLiving.
Donc tu vas devoir utiliser RenderPlayerEvent. -
Je n’ai rien trouvé en rapport avec les armures colorés dan RenderPlayer et RenderLiving
:::package net.minecraft.client.renderer.entity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.scoreboard.Score; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; 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 static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; @SideOnly(Side.CLIENT) public class RenderPlayer extends RendererLivingEntity { private static final ResourceLocation steveTextures = new ResourceLocation("textures/entity/steve.png"); private ModelBiped modelBipedMain; private ModelBiped modelArmorChestplate; private ModelBiped modelArmor; public RenderPlayer() { super(new ModelBiped(0.0F), 0.5F); this.modelBipedMain = (ModelBiped)this.mainModel; this.modelArmorChestplate = new ModelBiped(1.0F); this.modelArmor = new ModelBiped(0.5F); } /** * Set the specified armor model as the player model. Args: player, armorSlot, partialTick */ protected int setArmorModel(AbstractClientPlayer par1AbstractClientPlayer, int par2, float par3) { ItemStack itemstack = par1AbstractClientPlayer.inventory.armorItemInSlot(3 - par2); RenderPlayerEvent.SetArmorModel event = new RenderPlayerEvent.SetArmorModel(par1AbstractClientPlayer, this, 3 - par2, par3, itemstack); MinecraftForge.EVENT_BUS.post(event); if (event.result != -1) { return event.result; } if (itemstack != null) { Item item = itemstack.getItem(); if (item instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor)item; this.bindTexture(RenderBiped.getArmorResource(par1AbstractClientPlayer, itemstack, par2, null)); ModelBiped modelbiped = par2 == 2 ? this.modelArmor : this.modelArmorChestplate; modelbiped.bipedHead.showModel = par2 == 0; modelbiped.bipedHeadwear.showModel = par2 == 0; modelbiped.bipedBody.showModel = par2 == 1 || par2 == 2; modelbiped.bipedRightArm.showModel = par2 == 1; modelbiped.bipedLeftArm.showModel = par2 == 1; modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3; modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3; modelbiped = ForgeHooksClient.getArmorModel(par1AbstractClientPlayer, itemstack, par2, modelbiped); this.setRenderPassModel(modelbiped); modelbiped.onGround = this.mainModel.onGround; modelbiped.isRiding = this.mainModel.isRiding; modelbiped.isChild = this.mainModel.isChild; float f1 = 1.0F; //Move outside if to allow for more then just CLOTH int j = itemarmor.getColor(itemstack); if (j != -1) { float f2 = (float)(j >> 16 & 255) / 255.0F; float f3 = (float)(j >> 8 & 255) / 255.0F; float f4 = (float)(j & 255) / 255.0F; GL11.glColor3f(f1 * f2, f1 * f3, f1 * f4); if (itemstack.isItemEnchanted()) { return 31; } return 16; } GL11.glColor3f(f1, f1, f1); if (itemstack.isItemEnchanted()) { return 15; } return 1; } } return -1; } protected void func_130220_b(AbstractClientPlayer par1AbstractClientPlayer, int par2, float par3) { ItemStack itemstack = par1AbstractClientPlayer.inventory.armorItemInSlot(3 - par2); if (itemstack != null) { Item item = itemstack.getItem(); if (item instanceof ItemArmor) { this.bindTexture(RenderBiped.getArmorResource(par1AbstractClientPlayer, itemstack, par2, "overlay")); float f1 = 1.0F; GL11.glColor3f(f1, f1, f1); } } } public void func_130009_a(AbstractClientPlayer par1AbstractClientPlayer, double par2, double par4, double par6, float par8, float par9) { if (MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Pre(par1AbstractClientPlayer, this, par9))) return; float f2 = 1.0F; GL11.glColor3f(f2, f2, f2); ItemStack itemstack = par1AbstractClientPlayer.inventory.getCurrentItem(); this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = itemstack != null ? 1 : 0; if (itemstack != null && par1AbstractClientPlayer.getItemInUseCount() > 0) { EnumAction enumaction = itemstack.getItemUseAction(); if (enumaction == EnumAction.block) { this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = 3; } else if (enumaction == EnumAction.bow) { this.modelArmorChestplate.aimedBow = this.modelArmor.aimedBow = this.modelBipedMain.aimedBow = true; } } this.modelArmorChestplate.isSneak = this.modelArmor.isSneak = this.modelBipedMain.isSneak = par1AbstractClientPlayer.isSneaking(); double d3 = par4 - (double)par1AbstractClientPlayer.yOffset; if (par1AbstractClientPlayer.isSneaking() && !(par1AbstractClientPlayer instanceof EntityPlayerSP)) { d3 -= 0.125D; } super.doRenderLiving(par1AbstractClientPlayer, par2, d3, par6, par8, par9); 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(par1AbstractClientPlayer, this, par9)); } protected ResourceLocation func_110817_a(AbstractClientPlayer par1AbstractClientPlayer) { return par1AbstractClientPlayer.getLocationSkin(); } /** * Method for adding special render rules */ protected void renderSpecials(AbstractClientPlayer par1AbstractClientPlayer, float par2) { RenderPlayerEvent.Specials.Pre event = new RenderPlayerEvent.Specials.Pre(par1AbstractClientPlayer, this, par2); if (MinecraftForge.EVENT_BUS.post(event)) { return; } float f1 = 1.0F; GL11.glColor3f(f1, f1, f1); super.renderEquippedItems(par1AbstractClientPlayer, par2); super.renderArrowsStuckInEntity(par1AbstractClientPlayer, par2); ItemStack itemstack = par1AbstractClientPlayer.inventory.armorItemInSlot(3); if (itemstack != null && event.renderHelmet) { GL11.glPushMatrix(); this.modelBipedMain.bipedHead.postRender(0.0625F); float f2; if (itemstack != null && itemstack.getItem() instanceof ItemBlock) { IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D)); if (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType())) { f2 = 0.625F; GL11.glTranslatef(0.0F, -0.25F, 0.0F); GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(f2, -f2, -f2); } this.renderManager.itemRenderer.renderItem(par1AbstractClientPlayer, itemstack, 0); } else if (itemstack.getItem().itemID == Item.skull.itemID) { f2 = 1.0625F; GL11.glScalef(f2, -f2, -f2); String s = ""; if (itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("SkullOwner")) { s = itemstack.getTagCompound().getString("SkullOwner"); } TileEntitySkullRenderer.skullRenderer.func_82393_a(-0.5F, 0.0F, -0.5F, 1, 180.0F, itemstack.getItemDamage(), s); } GL11.glPopMatrix(); } if (par1AbstractClientPlayer.getCommandSenderName().equals("deadmau5") && par1AbstractClientPlayer.getTextureSkin().isTextureUploaded()) { this.bindTexture(par1AbstractClientPlayer.getLocationSkin()); for (int i = 0; i < 2; ++i) { float f3 = par1AbstractClientPlayer.prevRotationYaw + (par1AbstractClientPlayer.rotationYaw - par1AbstractClientPlayer.prevRotationYaw) * par2 - (par1AbstractClientPlayer.prevRenderYawOffset + (par1AbstractClientPlayer.renderYawOffset - par1AbstractClientPlayer.prevRenderYawOffset) * par2); float f4 = par1AbstractClientPlayer.prevRotationPitch + (par1AbstractClientPlayer.rotationPitch - par1AbstractClientPlayer.prevRotationPitch) * par2; GL11.glPushMatrix(); GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); GL11.glRotatef(f4, 1.0F, 0.0F, 0.0F); GL11.glTranslatef(0.375F * (float)(i * 2 - 1), 0.0F, 0.0F); GL11.glTranslatef(0.0F, -0.375F, 0.0F); GL11.glRotatef(-f4, 1.0F, 0.0F, 0.0F); GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F); float f5 = 1.3333334F; GL11.glScalef(f5, f5, f5); this.modelBipedMain.renderEars(0.0625F); GL11.glPopMatrix(); } } boolean flag = par1AbstractClientPlayer.getTextureCape().isTextureUploaded(); boolean flag1 = !par1AbstractClientPlayer.isInvisible(); boolean flag2 = !par1AbstractClientPlayer.getHideCape(); flag = event.renderCape && flag; float f6; if (flag && flag1 && flag2) { this.bindTexture(par1AbstractClientPlayer.getLocationCape()); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.0F, 0.125F); double d0 = par1AbstractClientPlayer.field_71091_bM + (par1AbstractClientPlayer.field_71094_bP - par1AbstractClientPlayer.field_71091_bM) * (double)par2 - (par1AbstractClientPlayer.prevPosX + (par1AbstractClientPlayer.posX - par1AbstractClientPlayer.prevPosX) * (double)par2); double d1 = par1AbstractClientPlayer.field_71096_bN + (par1AbstractClientPlayer.field_71095_bQ - par1AbstractClientPlayer.field_71096_bN) * (double)par2 - (par1AbstractClientPlayer.prevPosY + (par1AbstractClientPlayer.posY - par1AbstractClientPlayer.prevPosY) * (double)par2); double d2 = par1AbstractClientPlayer.field_71097_bO + (par1AbstractClientPlayer.field_71085_bR - par1AbstractClientPlayer.field_71097_bO) * (double)par2 - (par1AbstractClientPlayer.prevPosZ + (par1AbstractClientPlayer.posZ - par1AbstractClientPlayer.prevPosZ) * (double)par2); f6 = par1AbstractClientPlayer.prevRenderYawOffset + (par1AbstractClientPlayer.renderYawOffset - par1AbstractClientPlayer.prevRenderYawOffset) * par2; double d3 = (double)MathHelper.sin(f6 * (float)Math.PI / 180.0F); double d4 = (double)(-MathHelper.cos(f6 * (float)Math.PI / 180.0F)); float f7 = (float)d1 * 10.0F; if (f7 < -6.0F) { f7 = -6.0F; } if (f7 > 32.0F) { f7 = 32.0F; } float f8 = (float)(d0 * d3 + d2 * d4) * 100.0F; float f9 = (float)(d0 * d4 - d2 * d3) * 100.0F; if (f8 < 0.0F) { f8 = 0.0F; } float f10 = par1AbstractClientPlayer.prevCameraYaw + (par1AbstractClientPlayer.cameraYaw - par1AbstractClientPlayer.prevCameraYaw) * par2; f7 += MathHelper.sin((par1AbstractClientPlayer.prevDistanceWalkedModified + (par1AbstractClientPlayer.distanceWalkedModified - par1AbstractClientPlayer.prevDistanceWalkedModified) * par2) * 6.0F) * 32.0F * f10; if (par1AbstractClientPlayer.isSneaking()) { f7 += 25.0F; } GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); this.modelBipedMain.renderCloak(0.0625F); GL11.glPopMatrix(); } ItemStack itemstack1 = par1AbstractClientPlayer.inventory.getCurrentItem(); if (itemstack1 != null && event.renderItem) { GL11.glPushMatrix(); this.modelBipedMain.bipedRightArm.postRender(0.0625F); GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F); if (par1AbstractClientPlayer.fishEntity != null) { itemstack1 = new ItemStack(Item.stick); } EnumAction enumaction = null; if (par1AbstractClientPlayer.getItemInUseCount() > 0) { enumaction = itemstack1.getItemUseAction(); } float f11; IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack1, EQUIPPED); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack1, BLOCK_3D)); boolean isBlock = itemstack1.itemID < Block.blocksList.length && itemstack1.getItemSpriteNumber() == 0; if (is3D || (isBlock && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack1.itemID].getRenderType()))) { f11 = 0.5F; GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); f11 *= 0.75F; GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(-f11, -f11, f11); } else if (itemstack1.itemID == Item.bow.itemID) { f11 = 0.625F; GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(f11, -f11, f11); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); } else if (Item.itemsList[itemstack1.itemID].isFull3D()) { f11 = 0.625F; if (Item.itemsList[itemstack1.itemID].shouldRotateAroundWhenRendering()) { GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -0.125F, 0.0F); } if (par1AbstractClientPlayer.getItemInUseCount() > 0 && enumaction == EnumAction.block) { GL11.glTranslatef(0.05F, 0.0F, -0.1F); GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-10.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(-60.0F, 0.0F, 0.0F, 1.0F); } GL11.glTranslatef(0.0F, 0.1875F, 0.0F); GL11.glScalef(f11, -f11, f11); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); } else { f11 = 0.375F; GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); GL11.glScalef(f11, f11, f11); GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); } float f12; float f13; int j; if (itemstack1.getItem().requiresMultipleRenderPasses()) { for (j = 0; j < itemstack1.getItem().getRenderPasses(itemstack1.getItemDamage()); ++j) { int k = itemstack1.getItem().getColorFromItemStack(itemstack1, j); f13 = (float)(k >> 16 & 255) / 255.0F; f12 = (float)(k >> 8 & 255) / 255.0F; f6 = (float)(k & 255) / 255.0F; GL11.glColor4f(f13, f12, f6, 1.0F); this.renderManager.itemRenderer.renderItem(par1AbstractClientPlayer, itemstack1, j); } } else { j = itemstack1.getItem().getColorFromItemStack(itemstack1, 0); float f14 = (float)(j >> 16 & 255) / 255.0F; f13 = (float)(j >> 8 & 255) / 255.0F; f12 = (float)(j & 255) / 255.0F; GL11.glColor4f(f14, f13, f12, 1.0F); this.renderManager.itemRenderer.renderItem(par1AbstractClientPlayer, itemstack1, 0); } GL11.glPopMatrix(); } MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Specials.Post(par1AbstractClientPlayer, this, par2)); } protected void renderPlayerScale(AbstractClientPlayer par1AbstractClientPlayer, float par2) { float f1 = 0.9375F; GL11.glScalef(f1, f1, f1); } protected void func_96450_a(AbstractClientPlayer par1AbstractClientPlayer, double par2, double par4, double par6, String par8Str, float par9, double par10) { if (par10 < 100.0D) { Scoreboard scoreboard = par1AbstractClientPlayer.getWorldScoreboard(); ScoreObjective scoreobjective = scoreboard.func_96539_a(2); if (scoreobjective != null) { Score score = scoreboard.func_96529_a(par1AbstractClientPlayer.getEntityName(), scoreobjective); if (par1AbstractClientPlayer.isPlayerSleeping()) { this.renderLivingLabel(par1AbstractClientPlayer, score.getScorePoints() + " " + scoreobjective.getDisplayName(), par2, par4 - 1.5D, par6, 64); } else { this.renderLivingLabel(par1AbstractClientPlayer, score.getScorePoints() + " " + scoreobjective.getDisplayName(), par2, par4, par6, 64); } par4 += (double)((float)this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * par9); } } super.func_96449_a(par1AbstractClientPlayer, par2, par4, par6, par8Str, par9, par10); } public void renderFirstPersonArm(EntityPlayer par1EntityPlayer) { float f = 1.0F; GL11.glColor3f(f, f, f); this.modelBipedMain.onGround = 0.0F; this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); this.modelBipedMain.bipedRightArm.render(0.0625F); } /** * Renders player with sleeping offset if sleeping */ protected void renderPlayerSleep(AbstractClientPlayer par1AbstractClientPlayer, double par2, double par4, double par6) { if (par1AbstractClientPlayer.isEntityAlive() && par1AbstractClientPlayer.isPlayerSleeping()) { super.renderLivingAt(par1AbstractClientPlayer, par2 + (double)par1AbstractClientPlayer.field_71079_bU, par4 + (double)par1AbstractClientPlayer.field_71082_cx, par6 + (double)par1AbstractClientPlayer.field_71089_bV); } else { super.renderLivingAt(par1AbstractClientPlayer, par2, par4, par6); } } /** * Rotates the player if the player is sleeping. This method is called in rotateCorpse. */ protected void rotatePlayer(AbstractClientPlayer par1AbstractClientPlayer, float par2, float par3, float par4) { if (par1AbstractClientPlayer.isEntityAlive() && par1AbstractClientPlayer.isPlayerSleeping()) { GL11.glRotatef(par1AbstractClientPlayer.getBedOrientationInDegrees(), 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.getDeathMaxRotation(par1AbstractClientPlayer), 0.0F, 0.0F, 1.0F); GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F); } else { super.rotateCorpse(par1AbstractClientPlayer, par2, par3, par4); } } protected void func_96449_a(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, String par8Str, float par9, double par10) { this.func_96450_a((AbstractClientPlayer)par1EntityLivingBase, par2, par4, par6, par8Str, par9, par10); } /** * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args: * entityLiving, partialTickTime */ protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) { this.renderPlayerScale((AbstractClientPlayer)par1EntityLivingBase, par2); } protected void func_82408_c(EntityLivingBase par1EntityLivingBase, int par2, float par3) { this.func_130220_b((AbstractClientPlayer)par1EntityLivingBase, par2, par3); } /** * Queries whether should render the specified pass or not. */ protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { return this.setArmorModel((AbstractClientPlayer)par1EntityLivingBase, par2, par3); } protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) { this.renderSpecials((AbstractClientPlayer)par1EntityLivingBase, par2); } protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { this.rotatePlayer((AbstractClientPlayer)par1EntityLivingBase, par2, par3, par4); } /** * Sets a simple glTranslate on a LivingEntity. */ protected void renderLivingAt(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6) { this.renderPlayerSleep((AbstractClientPlayer)par1EntityLivingBase, par2, par4, par6); } public void doRenderLiving(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, float par8, float par9) { this.func_130009_a((AbstractClientPlayer)par1EntityLivingBase, par2, par4, par6, par8, par9); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity par1Entity) { return this.func_110817_a((AbstractClientPlayer)par1Entity); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" dorender(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { this.func_130009_a((AbstractClientPlayer)par1Entity, par2, par4, par6, par8, par9); } } ``````java package net.minecraft.client.renderer.entity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.common.MinecraftForge; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) public abstract class RendererLivingEntity extends Render { private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); protected ModelBase mainModel; /** 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 RendererLivingEntity(ModelBase par1ModelBase, float par2) { this.mainModel = par1ModelBase; this.shadowSize = par2; } /** * Sets the model to be used in the current render pass (the first render pass is done after the primary model is * rendered) Args: model */ public void setRenderPassModel(ModelBase par1ModelBase) { this.renderPassModel = par1ModelBase; } /** * Returns a rotation angle that is inbetween two other rotation angles. par1 and par2 are the angles between which * to interpolate, par3 is probably a float between 0.0 and 1.0 that tells us where "between" the two angles we are. * Example: par1 = 30, par2 = 50, par3 = 0.5, then return = 40 */ private float interpolateRotation(float par1, float par2, float par3) { float f3; for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F) { ; } while (f3 >= 180.0F) { f3 -= 360.0F; } return par1 + par3 * f3; } public void doRenderLiving(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, float par8, float par9) { if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(par1EntityLivingBase, this))) return; GL11.glPushMatrix(); GL11.glDisable(GL11.GL_CULL_FACE); this.mainModel.onGround = this.renderSwingProgress(par1EntityLivingBase, par9); if (this.renderPassModel != null) { this.renderPassModel.onGround = this.mainModel.onGround; } this.mainModel.isRiding = par1EntityLivingBase.isRiding(); if (this.renderPassModel != null) { this.renderPassModel.isRiding = this.mainModel.isRiding; } this.mainModel.isChild = par1EntityLivingBase.isChild(); if (this.renderPassModel != null) { this.renderPassModel.isChild = this.mainModel.isChild; } try { float f2 = this.interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9); float f3 = this.interpolateRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par9); float f4; if (par1EntityLivingBase.isRiding() && par1EntityLivingBase.ridingEntity instanceof EntityLivingBase) { EntityLivingBase entitylivingbase1 = (EntityLivingBase)par1EntityLivingBase.ridingEntity; f2 = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, par9); f4 = MathHelper.wrapAngleTo180_float(f3 - f2); if (f4 < -85.0F) { f4 = -85.0F; } if (f4 >= 85.0F) { f4 = 85.0F; } f2 = f3 - f4; if (f4 * f4 > 2500.0F) { f2 += f4 * 0.2F; } } float f5 = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9; this.renderLivingAt(par1EntityLivingBase, par2, par4, par6); f4 = this.handleRotationFloat(par1EntityLivingBase, par9); this.rotateCorpse(par1EntityLivingBase, f4, f2, par9); float f6 = 0.0625F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(-1.0F, -1.0F, 1.0F); this.preRenderCallback(par1EntityLivingBase, par9); GL11.glTranslatef(0.0F, -24.0F * f6 - 0.0078125F, 0.0F); float f7 = par1EntityLivingBase.prevLimbSwingAmount + (par1EntityLivingBase.limbSwingAmount - par1EntityLivingBase.prevLimbSwingAmount) * par9; float f8 = par1EntityLivingBase.limbSwing - par1EntityLivingBase.limbSwingAmount * (1.0F - par9); if (par1EntityLivingBase.isChild()) { f8 *= 3.0F; } if (f7 > 1.0F) { f7 = 1.0F; } GL11.glEnable(GL11.GL_ALPHA_TEST); this.mainModel.setLivingAnimations(par1EntityLivingBase, f8, f7, par9); this.renderModel(par1EntityLivingBase, f8, f7, f4, f3 - f2, f5, f6); float f9; int i; float f10; float f11; for (int j = 0; j < 4; ++j) { i = this.shouldRenderPass(par1EntityLivingBase, j, par9); if (i > 0) { this.renderPassModel.setLivingAnimations(par1EntityLivingBase, f8, f7, par9); this.renderPassModel.render(par1EntityLivingBase, f8, f7, f4, f3 - f2, f5, f6); if ((i & 240) == 16) { this.func_82408_c(par1EntityLivingBase, j, par9); this.renderPassModel.render(par1EntityLivingBase, f8, f7, f4, f3 - f2, f5, f6); } if ((i & 15) == 15) { f9 = (float)par1EntityLivingBase.ticksExisted + par9; this.bindTexture(RES_ITEM_GLINT); GL11.glEnable(GL11.GL_BLEND); f10 = 0.5F; GL11.glColor4f(f10, f10, f10, 1.0F); GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDepthMask(false); for (int k = 0; k < 2; ++k) { GL11.glDisable(GL11.GL_LIGHTING); f11 = 0.76F; GL11.glColor4f(0.5F * f11, 0.25F * f11, 0.8F * f11, 1.0F); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); float f12 = f9 * (0.001F + (float)k * 0.003F) * 20.0F; float f13 = 0.33333334F; GL11.glScalef(f13, f13, f13); GL11.glRotatef(30.0F - (float)k * 60.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, f12, 0.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); this.renderPassModel.render(par1EntityLivingBase, f8, f7, f4, f3 - f2, f5, f6); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glDepthMask(true); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); } } GL11.glDepthMask(true); this.renderEquippedItems(par1EntityLivingBase, par9); float f14 = par1EntityLivingBase.getBrightness(par9); i = this.getColorMultiplier(par1EntityLivingBase, f14, par9); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); if ((i >> 24 & 255) > 0 || par1EntityLivingBase.hurtTime > 0 || par1EntityLivingBase.deathTime > 0) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthFunc(GL11.GL_EQUAL); if (par1EntityLivingBase.hurtTime > 0 || par1EntityLivingBase.deathTime > 0) { GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F); this.mainModel.render(par1EntityLivingBase, f8, f7, f4, f3 - f2, f5, f6); for (int l = 0; l < 4; ++l) { if (this.inheritRenderPass(par1EntityLivingBase, l, par9) >= 0) { GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F); this.renderPassModel.render(par1EntityLivingBase, f8, f7, f4, f3 - f2, f5, f6); } } } if ((i >> 24 & 255) > 0) { f9 = (float)(i >> 16 & 255) / 255.0F; f10 = (float)(i >> 8 & 255) / 255.0F; float f15 = (float)(i & 255) / 255.0F; f11 = (float)(i >> 24 & 255) / 255.0F; GL11.glColor4f(f9, f10, f15, f11); this.mainModel.render(par1EntityLivingBase, f8, f7, f4, f3 - f2, f5, f6); for (int i1 = 0; i1 < 4; ++i1) { if (this.inheritRenderPass(par1EntityLivingBase, i1, par9) >= 0) { GL11.glColor4f(f9, f10, f15, f11); this.renderPassModel.render(par1EntityLivingBase, f8, f7, f4, f3 - f2, f5, f6); } } } GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); } catch (Exception exception) { exception.printStackTrace(); } OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glEnable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPopMatrix(); this.passSpecialRender(par1EntityLivingBase, par2, par4, par6); MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(par1EntityLivingBase, this)); } /** * Renders the model in RenderLiving */ protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7) { this.bindEntityTexture(par1EntityLivingBase); if (!par1EntityLivingBase.isInvisible()) { this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7); } else if (!par1EntityLivingBase.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) { GL11.glPushMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7); GL11.glDisable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glPopMatrix(); GL11.glDepthMask(true); } else { this.mainModel.setRotationAngles(par2, par3, par4, par5, par6, par7, par1EntityLivingBase); } } /** * Sets a simple glTranslate on a LivingEntity. */ protected void renderLivingAt(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6) { GL11.glTranslatef((float)par2, (float)par4, (float)par6); } protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { GL11.glRotatef(180.0F - par3, 0.0F, 1.0F, 0.0F); if (par1EntityLivingBase.deathTime > 0) { float f3 = ((float)par1EntityLivingBase.deathTime + par4 - 1.0F) / 20.0F * 1.6F; f3 = MathHelper.sqrt_float(f3); if (f3 > 1.0F) { f3 = 1.0F; } GL11.glRotatef(f3 * this.getDeathMaxRotation(par1EntityLivingBase), 0.0F, 0.0F, 1.0F); } else { String s = EnumChatFormatting.func_110646_a(par1EntityLivingBase.getEntityName()); if ((s.equals("Dinnerbone") || s.equals("Grumm")) && (!(par1EntityLivingBase instanceof EntityPlayer) || !((EntityPlayer)par1EntityLivingBase).getHideCape())) { GL11.glTranslatef(0.0F, par1EntityLivingBase.height + 0.1F, 0.0F); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); } } } protected float renderSwingProgress(EntityLivingBase par1EntityLivingBase, float par2) { return par1EntityLivingBase.getSwingProgress(par2); } /** * Defines what float the third param in setRotationAngles of ModelBase is */ protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2) { return (float)par1EntityLivingBase.ticksExisted + par2; } protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) {} /** * renders arrows the Entity has been attacked with, attached to it */ protected void renderArrowsStuckInEntity(EntityLivingBase par1EntityLivingBase, float par2) { int i = par1EntityLivingBase.getArrowCountInEntity(); if (i > 0) { EntityArrow entityarrow = new EntityArrow(par1EntityLivingBase.worldObj, par1EntityLivingBase.posX, par1EntityLivingBase.posY, par1EntityLivingBase.posZ); Random random = new Random((long)par1EntityLivingBase.entityId); RenderHelper.disableStandardItemLighting(); for (int j = 0; j < i; ++j) { GL11.glPushMatrix(); ModelRenderer modelrenderer = this.mainModel.getRandomModelBox(random); ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size())); modelrenderer.postRender(0.0625F); float f1 = random.nextFloat(); float f2 = random.nextFloat(); float f3 = random.nextFloat(); float f4 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f1) / 16.0F; float f5 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f2) / 16.0F; float f6 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f3) / 16.0F; GL11.glTranslatef(f4, f5, f6); f1 = f1 * 2.0F - 1.0F; f2 = f2 * 2.0F - 1.0F; f3 = f3 * 2.0F - 1.0F; f1 *= -1.0F; f2 *= -1.0F; f3 *= -1.0F; float f7 = MathHelper.sqrt_float(f1 * f1 + f3 * f3); entityarrow.prevRotationYaw = entityarrow.rotationYaw = (float)(Math.atan2((double)f1, (double)f3) * 180.0D / Math.PI); entityarrow.prevRotationPitch = entityarrow.rotationPitch = (float)(Math.atan2((double)f2, (double)f7) * 180.0D / Math.PI); double d0 = 0.0D; double d1 = 0.0D; double d2 = 0.0D; float f8 = 0.0F; this.renderManager.renderEntityWithPosYaw(entityarrow, d0, d1, d2, f8, par2); GL11.glPopMatrix(); } RenderHelper.enableStandardItemLighting(); } } protected int inheritRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { return this.shouldRenderPass(par1EntityLivingBase, par2, par3); } /** * Queries whether should render the specified pass or not. */ protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { return -1; } protected void func_82408_c(EntityLivingBase par1EntityLivingBase, int par2, float par3) {} protected float getDeathMaxRotation(EntityLivingBase par1EntityLivingBase) { return 90.0F; } /** * Returns an ARGB int color back. Args: entityLiving, lightBrightness, partialTickTime */ protected int getColorMultiplier(EntityLivingBase par1EntityLivingBase, float par2, float par3) { return 0; } /** * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args: * entityLiving, partialTickTime */ protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) {} /** * Passes the specialRender and renders it */ protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6) { if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Specials.Pre(par1EntityLivingBase, this))) return; if (this.func_110813_b(par1EntityLivingBase)) { float f = 1.6F; float f1 = 0.016666668F * f; double d3 = par1EntityLivingBase.getDistanceSqToEntity(this.renderManager.livingPlayer); float f2 = par1EntityLivingBase.isSneaking() ? NAME_TAG_RANGE_SNEAK : NAME_TAG_RANGE; if (d3 < (double)(f2 * f2)) { String s = par1EntityLivingBase.getTranslatedEntityName(); if (par1EntityLivingBase.isSneaking()) { FontRenderer fontrenderer = this.getFontRendererFromRenderManager(); GL11.glPushMatrix(); GL11.glTranslatef((float)par2 + 0.0F, (float)par4 + par1EntityLivingBase.height + 0.5F, (float)par6); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-f1, -f1, f1); GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef(0.0F, 0.25F / f1, 0.0F); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int i = fontrenderer.getStringWidth(s) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex((double)(-i - 1), -1.0D, 0.0D); tessellator.addVertex((double)(-i - 1), 8.0D, 0.0D); tessellator.addVertex((double)(i + 1), 8.0D, 0.0D); tessellator.addVertex((double)(i + 1), -1.0D, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, 553648127); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } else { this.func_96449_a(par1EntityLivingBase, par2, par4, par6, s, f1, d3); } } } MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Specials.Post(par1EntityLivingBase, this)); } protected boolean func_110813_b(EntityLivingBase par1EntityLivingBase) { return Minecraft.isGuiEnabled() && par1EntityLivingBase != this.renderManager.livingPlayer && !par1EntityLivingBase.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer) && par1EntityLivingBase.riddenByEntity == null; } protected void func_96449_a(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, String par8Str, float par9, double par10) { if (par1EntityLivingBase.isPlayerSleeping()) { this.renderLivingLabel(par1EntityLivingBase, par8Str, par2, par4 - 1.5D, par6, 64); } else { this.renderLivingLabel(par1EntityLivingBase, par8Str, par2, par4, par6, 64); } } /** * Draws the debug or playername text above a living */ protected void renderLivingLabel(EntityLivingBase par1EntityLivingBase, String par2Str, double par3, double par5, double par7, int par9) { double d3 = par1EntityLivingBase.getDistanceSqToEntity(this.renderManager.livingPlayer); if (d3 <= (double)(par9 * par9)) { FontRenderer fontrenderer = this.getFontRendererFromRenderManager(); float f = 1.6F; float f1 = 0.016666668F * f; GL11.glPushMatrix(); GL11.glTranslatef((float)par3 + 0.0F, (float)par5 + par1EntityLivingBase.height + 0.5F, (float)par7); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-f1, -f1, f1); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; byte b0 = 0; if (par2Str.equals("deadmau5")) { b0 = -10; } GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int j = fontrenderer.getStringWidth(par2Str) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex((double)(-j - 1), (double)(-1 + b0), 0.0D); tessellator.addVertex((double)(-j - 1), (double)(8 + b0), 0.0D); tessellator.addVertex((double)(j + 1), (double)(8 + b0), 0.0D); tessellator.addVertex((double)(j + 1), (double)(-1 + b0), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); fontrenderer.drawString(par2Str, -fontrenderer.getStringWidth(par2Str) / 2, b0, 553648127); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); fontrenderer.drawString(par2Str, -fontrenderer.getStringWidth(par2Str) / 2, b0, -1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" dorender(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { this.doRenderLiving((EntityLivingBase)par1Entity, par2, par4, par6, par8, par9); } }
:::</t></t>
-
Et ça :
protected int setArmorModel(AbstractClientPlayer par1AbstractClientPlayer, int par2, float par3) { ItemStack itemstack = par1AbstractClientPlayer.inventory.armorItemInSlot(3 - par2); RenderPlayerEvent.SetArmorModel event = new RenderPlayerEvent.SetArmorModel(par1AbstractClientPlayer, this, 3 - par2, par3, itemstack); MinecraftForge.EVENT_BUS.post(event); if (event.result != -1) { return event.result; } if (itemstack != null) { Item item = itemstack.getItem(); if (item instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor)item; this.bindTexture(RenderBiped.getArmorResource(par1AbstractClientPlayer, itemstack, par2, null)); ModelBiped modelbiped = par2 == 2 ? this.modelArmor : this.modelArmorChestplate; modelbiped.bipedHead.showModel = par2 == 0; modelbiped.bipedHeadwear.showModel = par2 == 0; modelbiped.bipedBody.showModel = par2 == 1 || par2 == 2; modelbiped.bipedRightArm.showModel = par2 == 1; modelbiped.bipedLeftArm.showModel = par2 == 1; modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3; modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3; modelbiped = ForgeHooksClient.getArmorModel(par1AbstractClientPlayer, itemstack, par2, modelbiped); this.setRenderPassModel(modelbiped); modelbiped.onGround = this.mainModel.onGround; modelbiped.isRiding = this.mainModel.isRiding; modelbiped.isChild = this.mainModel.isChild; float f1 = 1.0F; //Move outside if to allow for more then just CLOTH int j = itemarmor.getColor(itemstack); if (j != -1) { float f2 = (float)(j >> 16 & 255) / 255.0F; float f3 = (float)(j >> 8 & 255) / 255.0F; float f4 = (float)(j & 255) / 255.0F; GL11.glColor3f(f1 * f2, f1 * f3, f1 * f4); if (itemstack.isItemEnchanted()) { return 31; } return 16; } GL11.glColor3f(f1, f1, f1); if (itemstack.isItemEnchanted()) { return 15; } return 1; } } return -1; }
Mais quand on regarde le code, il semblerait qu’il utilise déjà la fonction dans l’armure, donc normalement ça devrait fonctionner sans ajouter quelques choses …
Donc je ne sais pas -
Arf, je suis pas doué
Je vais continuer de chercher.