Jump to content

When Minecraft/Forge loads mods' language assets, how does it prevent clashing?


UntouchedWagons

Recommended Posts

In the Item class' getItemStackDisplayName method it calls StatCollector's translateToLocal method but there's no reference to the mod that the item is from. So if two mods add an item with the same unlocalized name, how does Minecraft know which item.the_thing.name to use? Also, is it possible to get the display name of an item using only the mod id and the unlocalized name?

I like trains.

Link to comment
Share on other sites

I'm not sure about your first question but I know I do this to make sure to prevent unlocalised name clashes:

public static void nameItem(Item item, String name)
{
    item.setUnlocalizedName(Reference.MOD_ID + "." + name);
    item.setTextureName(Reference.MOD_ID + ":" + name);
}

 

Same things for blocks too. So instead of item.something.name it's item.modid.something.name, and then I never have to worry about it.

 

 

Now, for your next question I haven't tried it, but I'd assume you can do:

if(GameData.getItemRegistry().contains(unlocalisedName))
{
    Item item = GameData.getItemRegistry().getObject(unlocalisedName);
    ItemStack stack = item != null ? new ItemStack(item) : null;
    String displayName = stack != null ? stack.getDisplayName() : "";
}

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

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.