UntouchedWagons Posted October 12, 2014 Posted October 12, 2014 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? Quote I like trains.
shieldbug1 Posted October 12, 2014 Posted October 12, 2014 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() : ""; } Quote BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
Recommended Posts
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.