Jump to content

Recommended Posts

Posted

Here is my loop in my preInit()

 

for(int i = 0; i < ItemGems.getIconLength(); i++)
	{
		LanguageRegistry.addName(new ItemStack(Main.gemItems, 1, i), ItemGems.getIconFileName(i, true));
	}

 

ItemGems.getIconLength()

public static int getIconLength()
    {
    	return iconLength;//always returns 13
    }

ItemGems.getIconFileName()

public static String getIconFileName(int index)
    {
	return getIconFileName(index, false);
}
    
    public static String getIconFileName(int index, boolean getSplitName)
    {
    	String i = 
			index == 12 ? "Topaz" :
			index == 11 ? "Smoked Topaz" :
			index == 10 ? "Ruby" :
			index == 9 ? "Pad Paradsha" :
			index == 8 ? "Mint Alabaster" :
			index == 7 ? "Indicolite" :
			index == 6 ? "Hyasinth" :
			index == 5 ? "Garnet" :
			index == 4 ? "Fire Opal" :
			index == 3 ? "Carribean Blue Opal" :
			index == 2 ? "Blue Sapphire" :
			index == 1 ? "Black Jet" :
			index == 0 ?  "Black Diamond" :
			"you broke somthing";
    	if(getSplitName == false && i != "you broke somthing") i = i.replaceAll(" ", "");
	return i;
    }

 

getSplitName when false returns the behind the scenes name and true returns the item name the user will see

 

for some reason it will always name the item Topaz.

 

first of all I thought it was my ternary statement but if this was the case the icons themselves would not register.

 

also it cant be the true/false removing white-space because the items would still be named differently they would just be named with their white-space removed.

Posted

ok so i added a overide function for getLocalizedName

 

@Override
    public String getLocalizedName(ItemStack par1ItemStack)
    {
    	return getIconFileName(par1ItemStack.getItemDamage(), true);
    }

 

but stepping trough teh debugger the override i have made gets thrown out the window when Item.getItemDisplayName() calls it by using this thus it is registered as ""

public String getItemDisplayName(ItemStack par1ItemStack)
    {
        return ("" + StringTranslate.getInstance().translateNamedKey(this.getLocalizedName(par1ItemStack))).trim();
    }

 

I have tried a few methods but they have all failed so I am wondering how i would set a unlocalisedName for all of my sub items.

 

or better yet a page with an explanation on how it works so that if i run into the problem again i know why its doing what it is doing

 

note: typing this on my phone there may be bad spellings

Posted
public String getItemDisplayName(ItemStack is)
{
	switch (is.getItemDamage())
	{
		case 0: return "Topaz";
		case 1: return "Smoked Topaz";
		case 2: return "Ruby";
		case 3: return "Pad Paradsha";
                //Etc Etc. I know they aren't in the right order, but oh well. You get the point.
	}
	return "Unknown Gem Item";
}

The enders are everywhere. You can't escape...

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.