Jump to content

Recommended Posts

Posted

My item, which is multiple items in one ID, doesn't show all of the other items in the creative tab. I am updating from 1.6.4. Also, I am able to craft the items in-game, so I know they are registering.

Here is my code:

 

 

package f1repl4ce.unlogic.items;

import java.util.List;

import net.minecraft.item.Item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;

public class Component extends Item{
public static final String[] itemNames = new String[] {"unlogicGem", "fireCore", "iceCore", "antiGold", "redGem", "blueGem"};
public static final String[] item_a = new String[] {"unlogicGem", "fireCore", "iceCore", "antiGold", "redGem", "blueGem"};
@SideOnly(Side.CLIENT)
private IIcon[] item_b;
public Component(int par1) {
	super();
        this.setHasSubtypes(true);
        this.setMaxDamage(0);
}
int itemcount = 6;
public String getUnlocalizedName(ItemStack par1ItemStack)
{
         int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, itemcount-1);
         return super.getUnlocalizedName() + "." + itemNames[i];
}
@SideOnly(Side.CLIENT)
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
         for (int j = 0; j < itemcount; ++j)
         {
                 par3List.add(new ItemStack(this, 1, j));
         }
}
@Override
public void registerIcons(IIconRegister par1IconRegister)
{
         this.item_b = new IIcon[item_a.length];
        
         for (int i = 0; i < item_a.length; ++i)
         {
                 this.item_b[i] = par1IconRegister.registerIcon("unlogic:" + item_a[i]);
         }
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
        switch(damage) {
        
        default: return item_b[damage];
        }
}
}

 

 

Let me know if anything is missing and I will add it to the post.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Posted

@SideOnly(Side.CLIENT)
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
         for (int j = 0; j < itemcount; ++j)
         {
                 par3List.add(new ItemStack(this, 1, j));
         }
}

Let me know if anything is missing and I will add it to the post.

<cough> @Override <cough>

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

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