Jump to content

Recommended Posts

Posted

Hello, I am working on a mod that is adding several new types of custom and visually attractive storage options. One such block I am working on is an armor stand. I have no trouble rending a custom model w/ custom texture, setting up a TileEntity with a TileEntitySpecialRenderer than passing along my ItemStack of my armor pieces to my renderer, but then I am not sure how exactly to get the armor to render. I am thinking I need to bring in the ModelBiped and initilize a new ModelBiped(); then get the armor texture from my itemstack(s) and use ForgeHooksClient.bindTexture to apply the texture. Am I correct in my approach to this problem? The main issue I am having with this approach is I am not sure how to properly get the texture from the itemstack. I tried  using  String helmTexture = ForgeHooksClient.getArmorTexture(helmStack, armorHelm.getTextureFile()); but I only seem to get back the item texture and not the actual armor texture I can apply to a ModelBiped. I pulled the itemstack for my helmStack from the TileEntity and did a ItemArmor armorHelm = (ItemArmor)helmItem;. I've made it render just the item by doing a EntityItem helmItem = new EntityItem(null, i, j, k, helmStack); and then a itemRenderer.doRenderItem(helmItem, 0, 0, 0, 0, 0); but that is not exactly what I want.

 

I had a good look at the RenderPlayer class, but I haven't had any success in accomplishing my goal. I would really like it if I could make this armor stand work with most / any mod that adds armor's which I think is making this a little more difficult to pull the texture.

 

Any help / suggestions would be most appreciated. Thanks!

Posted

Okay, so I am still trying to figure this one out. I've got it setup now so that if a piece of armor is present is one of the 4 slots on my armor stand then that piece of armor renders. Basically I am using the vanilla code to get the armor texture path from the vanilla armor then just rendering that texture onto a custom ModelBiped class that I extended. It works fine for vanilla armor, though it doesn't display enchanted armor (or at least the enchantment/glowing effect). I'm using this to get my string for the texture path.

 

Item helmItem = helmStack.getItem();
ItemArmor armorHelm = (ItemArmor)helmItem;
int aType = armorHelm.armorType;
String helmTexture = ForgeHooksClient.getArmorTexture(helmStack, "/armor/" + armorFilenamePrefix[armorHelm.renderIndex] + "_" + (aType != 2 ? 1 : 2) + ".png");

 

Then I just use ForgeHooksClient.bindTexture to place the texture on my model. But of course this only works for vanilla textures and trying to put mod stuff on there in many cases caused crashes (not that I expected this to work, but I had to try, for science.)

 

I pretty much just need some way to get the texture path for the armor from an ItemStack. I know there must be code in vanilla somewhere that does this for rendering the armor on the player, but I can't seem to find where this code could be. I am also wondering about the enchantment effect and how I might apply that.

 

If anyone has any tips that might help me get this texture path I would really appreciate it.  Thanks.

Posted

ok, so it seems I just didn't do enough testing with ForgeHooksClient.getArmorTexture(itemStack, defaultString) and I have learned that any armor item that implements the interface IArmorTextureProvider does actually return the texture path I am looking for. I had tested with vanilla and IC2 and both of them would only return the defaultString. Mods like thaumcraft, twilight forest, railcraft, minechem, and foresty setup the IArmorTextureProvider interface( I assume) and return the correct texture path I am looking for. I think I was closer to my solution than I thought this whole time.  It seems like it would be easy enough to test for vanilla armor and IC2 armor and just hardcode in the IC2 armor texture locations so I think that is the route I am going to take.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.