Jump to content

[1.12.2] can't get localized display name to appear


JoeStrout

Recommended Posts

We're stumped on getting this to work, despite considerable googling and experimentation.  Here's the item declaration:

 

    @EventHandler
    public void preinit(FMLPreInitializationEvent event) {
    		System.out.println("PRE-INITIALIZATION");
    		testItem = (Item)(new Item());
    		testItem.setRegistryName("stroutmod1_testitem1");
    		testItem.setUnlocalizedName(testItem.getRegistryName().toString());
    		testItem.setCreativeTab(CreativeTabs.MISC);
    		System.out.println("Registered item: " + testItem.getRegistryName());
    		ForgeRegistries.ITEMS.register(testItem);    		
    }

 

Note the println there showing us the registry name; when we launch, it shows "stroutmod1:stroutmod1_testitem1".

 

Now we have a en_US.lang file at stroutmod1/src/main/resources/assets/stroutmod1/lang/en_US.lang.  It's UTF-8 with no BOM, and contains:

item.stroutmod1:stroutmod1_testitem1.name=Test Item

 

Yet when we run the game, the item shows up as "item.stroutmod1:stroutmod1_testitem1.name" rather than "Test Item".

 

Any idea what we're missing?

Link to comment
Share on other sites

41 minutes ago, JoeStrout said:

ForgeRegistries.ITEMS.register(testItem);

Never register things like this.
ForgeRegistries#<REGISTRY> are solely for querying & iterating over.
If you want to register an object, use the RegistryEvent's.

 

I believe that lang-file(en_US) have to be lower-case only(en_us) in 1.11+. @Choonster goes over why here.

 

  • Like 1

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

48 minutes ago, Matryoshika said:

Never register things like this.
ForgeRegistries#<REGISTRY> are solely for querying & iterating over.
If you want to register an object, use the RegistryEvent's

Oops, looks like we must have found some old docs/samples.  I'll look into this right away.

 

50 minutes ago, Matryoshika said:

I believe that lang-file(en_US) have to be lower-case only(en_us) in 1.11+.

That's it!  Renaming the file to en_us.lang did the trick.

 

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