Posted March 18, 201312 yr Hi, I'm trying to give my items a texture, all the items is metadata items and I can't get it to work. Please help me. Here is my code: package com.xeto.miseriacraft.item; import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; public class ItemOreDrops extends Item { protected Icon[] icon = new Icon[3]; private final static String[] subNames = { "lapun", "miseria", "soul" }; public ItemOreDrops(int par1) { super(par1); setHasSubtypes(true); setMaxDamage(0); setCreativeTab(CreativeTabs.tabMaterials); setUnlocalizedName("miseriaitem"); } @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int par1) { int j = MathHelper.clamp_int(par1, 0, 3); return icon[j]; } public String getUnlocalizedName(ItemStack par1ItemStack) { return getUnlocalizedName() + "." + subNames[par1ItemStack.getItemDamage()]; } @SuppressWarnings({ "rawtypes", "unchecked" }) @SideOnly(Side.CLIENT) public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { for (int j = 0; j < 3; ++j) { par3List.add(new ItemStack(par1, 1, j)); } } public void func_94332_a(IconRegister iconRegister) { for (int i = 0; i < 3; i++) { icon = iconRegister.func_94245_a("miseriacraft:" + subNames); } } }
March 18, 201312 yr Author Still looking for someone who could help me, I've got the textures set up in the folders that it is supposed to be int. With other words in /mods/modname/textures/items/.
March 18, 201312 yr "cant get it to work" is a little vauge but heres what i'd do. in your constructor add a meta data , that way you can create each subitem in your mod file separately. from there of course save the meta and when the register icon comes up register the default item icon var directly to the item you want by iconIndex = iconRegister.func_94245_a("miseriacraft:" + subNames[meta]); package com.xeto.miseriacraft.item; import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; public class ItemOreDrops extends Item { protected Icon[] icon = new Icon[3]; // remove compleatly , useless especialy how your using it. icon[meta] = registered maybe , but then your registering 3 files for each item int meta = 0; private final static String[] subNames = { "lapun", "miseria", "soul" }; public ItemOreDrops(int par1,int meta) { super(par1); setHasSubtypes(true); setMaxDamage(0); setCreativeTab(CreativeTabs.tabMaterials); setUnlocalizedName("miseriaitem"); this.meta = meta; } @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int par1) { // i'd try catch with a catch returning icon 0 and a system.out msg int j = MathHelper.clamp_int(par1, 0, 3); return icon[j]; } public String getUnlocalizedName(ItemStack par1ItemStack) { return getUnlocalizedName() + "." + subNames[meta]; } @SuppressWarnings({ "rawtypes", "unchecked" }) @SideOnly(Side.CLIENT) public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { // could add them manualy just like each of the 3 items in the mod file // or if your incrementing though them at some point where you will set it to a higher meta it'd be better to set that by number by meta = (meta + 1) % 3 for (int j = 0; j < 3; ++j) { par3List.add(new ItemStack(par1, 1, j)); } } public void func_94332_a(IconRegister iconRegister) { for (int i = 0; i < 3; i++) { // icon = iconRegister.func_94245_a("miseriacraft:" + subNames); no , just no. your setting an Icon to the icon array, not the icon array's index iconIndex = iconRegister.func_94245_a("miseriacraft:" + subNames[meta]); } } [code] note , i havent tested this or even checked syntax, could be errors in the changes
March 18, 201312 yr the Item class doesnt have a meta constructor , but u can add one to your item w/o using it in the main item class and that texture issue could be from the comment i added by where u set the icon array as the icon itself ( added to my above post some )
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.