Jump to content

[1.7.2] [SOLVED] Item Subtypes not Appearing in Creative Tab


TehSeph

Recommended Posts

Can I first start off by saying jumping code from 1.5.2 straight to 1.7.2/1.7.10... not fun. Basically re-writing the entire thing.

Anyway, after several hours of searching for a solution I've decided to make a post here.

 

I have an item (a few items, actually) that is subtyped via metadata and using /give works and appears to be coded and localized correctly.

However, when viewing the tab in the creative menu only the first subtype is shown and can be spawned.

 

alktoNS.png

(Yes, the dust/ingot textures are from TherrmalExpansion. These are only temp. textures.)

 

ItemMod.java

package com.tehseph.sephsmod.item;

import com.tehseph.sephsmod.core.Globals;
import com.tehseph.sephsmod.core.ModCreativeTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class ItemMod extends Item {

public ItemMod() {

	super();
	this.setCreativeTab(ModCreativeTab.tabSephsMod);
	this.setMaxStackSize(1);
	this.setNoRepair();

}

@Override
public String getUnlocalizedName() {
	return String.format("item.%s:%s", Globals.MODID.toLowerCase(), getUnwrappedName());
}

@Override
public String getUnlocalizedName(ItemStack itemStack) {
	return String.format("item.%s:%s", Globals.MODID.toLowerCase(), getUnwrappedName());
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
	itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}

protected String getUnwrappedName() {
	return super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1);
}
}

 

ItemModMeta.java

package com.tehseph.sephsmod.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 java.util.List;

public class ItemModMeta extends ItemMod {

protected String[] metaNames;
protected IIcon[] metaIcons;

public ItemModMeta() {

	super();
	this.setHasSubtypes(true);

}

@Override
public String getUnlocalizedName(ItemStack itemStack) {
	return (super.getUnlocalizedName() + "_" + this.metaNames[itemStack.getItemDamage()]);
}

@SideOnly(Side.CLIENT)
public String getUnlocalizedName(int metadata) {
	return (super.getUnlocalizedName() + "_" + this.metaNames[metadata]);
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int metadata) {
	return this.metaIcons[metadata];
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
	itemIcon = iconRegister.registerIcon(this.getUnlocalizedName(0).substring(this.getUnlocalizedName(0).indexOf(".") + 1));
	for (int i = 0; i < metaIcons.length; i++) {
		metaIcons[i] = iconRegister.registerIcon(this.getUnlocalizedName(i).substring(this.getUnlocalizedName(i).indexOf(".") + 1));
	}
}

@SideOnly(Side.CLIENT)
public void getSubItems(int itemID, CreativeTabs cTab, List itemList) {
	for (int i = 0; i < this.metaNames.length; ++i) {
		itemList.add(new ItemStack(this, 1, i));
	}
}

}

 

ItemOreDusts.java

package com.tehseph.sephsmod.item;

import net.minecraft.util.IIcon;

public class ItemOreDusts extends ItemModMeta {

private String[] dustNames = {"Copper", "Gold", "Iron", "Tin" };

public ItemOreDusts() {

	super();
	this.metaNames = this.dustNames;
	this.metaIcons = new IIcon[this.dustNames.length];
	this.setUnlocalizedName("oreDusts");

}

}

 

ModItems.java

package com.tehseph.sephsmod.core;

import com.tehseph.sephsmod.item.*;
import cpw.mods.fml.common.registry.GameRegistry;

@GameRegistry.ObjectHolder(Globals.MODID)
public class ModItems {

public static final ItemMod grindstone = new ItemGrindstone();
public static final ItemMod infernalStone = new ItemInfernalStone();
public static final ItemMod oreDusts = new ItemOreDusts();
public static final ItemMod oreIngots = new ItemOreIngots();

public static void init() {

	GameRegistry.registerItem(grindstone, "grindstone");
	GameRegistry.registerItem(infernalStone, "infernalStone");

	GameRegistry.registerItem(oreDusts, "oreDusts");
	GameRegistry.registerCustomItemStack("dustCopper", new ItemStack(oreDusts, 1, 0));
	GameRegistry.registerCustomItemStack("dustGold", new ItemStack(oreDusts, 1, 1));
	GameRegistry.registerCustomItemStack("dustIron", new ItemStack(oreDusts, 1, 2));
	GameRegistry.registerCustomItemStack("dustTin", new ItemStack(oreDusts, 1, 3));

	GameRegistry.registerItem(oreIngots, "oreIngots");
	GameRegistry.registerCustomItemStack("ingotCopper", new ItemStack(oreIngots, 1, 0));
	GameRegistry.registerCustomItemStack("ingotTin", new ItemStack(oreIngots, 1, 1));

}

}

Link to comment
Share on other sites

Bump~

 

I've updated to 1.7.10-10.13.0.1180 and the problem still persists. I'm betting it's something super simple that I'm just missing because my code is virtually the same as it was back in 1.5.2, just with the new localization methods and no LanguageRegistry which I'm thinking might be the cause. Back in 1.5.2 I had to assign different unlocalized names for each different itemstack.

 

(a few other things might have been tweaked too, but nothing else I would think would cause this.)

Link to comment
Share on other sites

Your

getSubItems

method does not override anything. The signature changed because there are no ItemIDs anymore. Always use @Override if you intend to override, it would have told you this error.

Yep. That did it. I knew it would be something easy. Stupid me. :P

Not sure why I didn't think to override it nor missed the itemID integer. Thank you very much. :)

Link to comment
Share on other sites

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.