Posted April 8, 201411 yr I'm trying to get my armor to render correctly, and I'm running into what's probably a basic problem. The method I'm using to get the texture, which I think is all right, is: public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){ if(stack.getItem() == Heart.heartstoneChestplate) { return "tutorial:textures/models/armor/heartstone_1.png"; } else return null; } The problem comes when I actually try to call this method, from my main mod file: heartstoneChestplate = new ItemArmor(HEARTSTONE, proxy.addArmor("heartstone"), 1) .getArmorTexture(new ItemStack(this.heartstoneChestplate), null, 1, "heartstone"); ...Which underlines the whole definition in red and invites me to change heartstoneChestplate to a string rather than an item. The problem seems to be tied to the "new ItemStack" part. Am I calling ItemStack incorrectly? Is new the wrong keyword to use here? Thanks for your help!
April 8, 201411 yr No, the core problem is initializing an object with itself in the definition. You are not supposed to call that method anyway, it is a forge hook.
April 9, 201411 yr Author I hang my head in shame; in hindsight, yeah, trying to create an ItemStack of the object before the object was initialized was probably not the best idea. But I have no idea what to do instead.
April 9, 201411 yr I hang my head in shame; in hindsight, yeah, trying to create an ItemStack of the object before the object was initialized was probably not the best idea. But I have no idea what to do instead. Create a new class which extends ItemArmor, override the method and put your code in there. Example: https://github.com/SanAndreasP/EnderStuffPlus/blob/master/java/sanandreasp/mods/EnderStuffPlus/item/ItemNiobArmor.java#L26-L36 Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
April 9, 201411 yr Author Thank you very much. There is nothing like seeing a working example! I have it working, and I understand Java better now to boot. (Anyone who stumbles on this thread later: stack.itemID, which is used in the linked example to identify the armor we're looking at, no longer works. We now test this with stack.getItem() == Yourmod.exampleItem.)
April 10, 201411 yr Thank you very much. There is nothing like seeing a working example! I have it working, and I understand Java better now to boot. (Anyone who stumbles on this thread later: stack.itemID, which is used in the linked example to identify the armor we're looking at, no longer works. We now test this with stack.getItem() == Yourmod.exampleItem.) Glad I could help. By the way, I'm currently refractoring the mod, so there's a cleaned up version here: https://github.com/SanAndreasP/EnderStuffPlus/blob/code-cleanup/java/sanandreasp/mods/EnderStuffPlus/item/ItemNiobArmor.java#L29-L39 Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
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.