Jump to content

Meta data items registering with the same name


jordan30001

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • before I updated my pack I made for paintings++ mod, i noticed and saw that only modded paintings and vanilla ones move one block each time I re-enter my world! is there something wrong? what the hell is even going on? why is there a ghost living in my house?! the modded paintings even phase through blocks which is super weird!! help! here is my painting mod list: Paintings++ Dark paintings Macaw's paintings Joy of painting Immersive paintings My custom paintings++ resource pack
    • Error: java.lang.NullPointerException: Cannot invoke "me.codexadrian.tempad.TempadClientConfig.renderBlur()" because the return value of "me.codexadrian.tempad.TempadClient.getClientConfig()" is null I keep having this error while trying to launch a modpack through the forge modloader, any suggestions? https://docs.google.com/document/d/1CRKUoSiu2e_mDvDTVYpIA5wqD3w-BsCycxBu1_vQ4OA/edit?usp=sharing Crash Report ^^^^
    • I'm trying to start a server with the latest installer, but running the run.bat file doesn't generate new files. It shows the following in the cmd prompt.
    • One of my players is suddenly unable to join a locally hosted MC Eternal server. We have been playing on this server for about 2-3 weeks now. I have tried erasing his player files and his reputation file, and now it just coughs up this and kicks him out: [User Authenticator #5/INFO] [minecraft/NetHandlerLoginServer]: UUID of player EthosTheGod is 7692d8db-02c3-424f-a4ab-0e4e259b106b [20:25:36] [User Authenticator #4/INFO] [minecraft/NetHandlerLoginServer]: UUID of player EthosTheGod is 7692d8db-02c3-424f-a4ab-0e4e259b106b [20:29:35] [Server thread/WARN] [minecraft/MinecraftServer]: Can't keep up! Did the system time change, or is the server overloaded? Running 575849ms behind, skipping 11516 tick(s) [20:29:35] [Server thread/INFO] [minecraft/NetHandlerLoginServer]: com.mojang.authlib.GameProfile@4a6c63f1[id=7692d8db-02c3-424f-a4ab-0e4e259b106b,name=EthosTheGod,properties={textures=[com.mojang.authlib.properties.Property@241ea89e]},legacy=false] (/IP.ADDRESS) lost connection: Disconnected [20:29:35] [Server thread/INFO] [minecraft/NetHandlerLoginServer]: com.mojang.authlib.GameProfile@6ab6c661[id=7692d8db-02c3-424f-a4ab-0e4e259b106b,name=EthosTheGod,properties={textures=[com.mojang.authlib.properties.Property@7f19aae3]},legacy=false] (/IP.ADDRESS) lost connection: Disconnected It just says "connection timed out" on his end. Any ideas?
    • I'm trying to migrate my mod from 1.20 to 1.21. Some packages in the forge api were changed so my mod did have some classes not working. I've changed everything i needed but still is getting me the following error error: cannot access Registry DeferredRegister.create(ForgeRegistries.BLOCKS, FarmMod.MOD_ID); ^ class file for net.minecraft.core.Registry not found The piece of code that is wrong is   public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, FarmMod.MOD_ID); And here are my imports   import com.lucas.farmmod.FarmMod; import com.lucas.farmmod.block.custom.BaseIrrigatorBlock; import com.lucas.farmmod.item.ModItems; import com.lucas.farmmod.item.custom.BaseIrrigatorBlockItem; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; The class DeferredRegister is throwing the error in the print below     I've tried running rebuilding my project in every way possible, tried refreshing my dependencies but nothing works. What can i do?
  • Topics

×
×
  • Create New...

Important Information

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