Jump to content

Unlocalized name and Registry Name


Delupara

Recommended Posts

Registry name is the internal 'code' name that the item can be pulled from the registry with. And should be the name used for all internal references to the item.

Unlocalized name is the key in the language files for looking up the localized information. NOTHING MORE.

 

There is a big stupid population of modders who copy paste old crappy tutorials from 4 years ago that hack around and try to use the unloacalized name for internal stuff, this is wrong and if you do it you should be ashamed.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Registry name is the internal 'code' name that the item can be pulled from the registry with. And should be the name used for all internal references to the item.

Unlocalized name is the key in the language files for looking up the localized information. NOTHING MORE.

 

There is a big stupid population of modders who copy paste old crappy tutorials from 4 years ago that hack around and try to use the unloacalized name for internal stuff, this is wrong and if you do it you should be ashamed.

 

I might cause a major facepalm here but, When would you usually pull said registry name.

 

I make reference to my items by calling a static item variable in preinit like this:

 

public static Item ModItem = new Item().setUnlocalizedname("blahblah")

 

I've used those variables in all my classes using them and nothing nefarious happened.

When they say your code doesn't follow convention but ur edgy so u dont care

d-d-d-dab on them haterz

 

Link to comment
Share on other sites

Yup, that is fine - if you have direct reference that is.

 

Registry name on the other hand can be used by other mods which don't. It is probably also used in internal stuff (but I am not the one to talk about this).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

static items in prinit is not static -.-

However methods like setUnlocalizedName, setRegistryName, etc.. follow a programming design called chaining.

Its when a method returns the object it's working on.

So you can do something like:

Item my_item = new MyItem().setUnlocalizeName().setRegistryName();

 

Side note, you shouldnt start your fields with upper case names, that's typically reserved for Class names.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

It is currently considered good practice to use the registry name to set the unlocalized name:

 

Item my_item = new MyItem().setRegistryName("myitem");

my_item.setUnlocalizeName(my_item.getRegistryName());

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

static items in prinit is not static -.-

However methods like setUnlocalizedName, setRegistryName, etc.. follow a programming design called chaining.

Its when a method returns the object it's working on.

So you can do something like:

Item my_item = new MyItem().setUnlocalizeName().setRegistryName();

 

Side note, you shouldnt start your fields with upper case names, that's typically reserved for Class names.

 

I've programmed in java for around 3 years, I'm pretty sure with method chaining is.

 

did I said preinit()? my bad, that would be pretty pointless since variable are block inclusive, they dont exist beyond methods.

 

I meant to say that I have them in a separate extended item class. my bad. Regardless that doesn't answer my question much, using that variable isn't really using the registry name. So what or when would you use the registry name (You did answer most of it, this is just for curiosity's sake)

When they say your code doesn't follow convention but ur edgy so u dont care

d-d-d-dab on them haterz

 

Link to comment
Share on other sites

So what or when would you use the registry name (You did answer most of it, this is just for curiosity's sake)

 

Everything.

Registry name is how the block/item is keyed into the block or item registry

Registry name is how the block/item's renderer is keyed into the rendering registry

Registry name is used to set the unlocalized name

Registry name never changes

Registry name is used to reference textures

Registry name is models

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I have not been setting my unlocalizedName to the registry name. In an Item or Block class I do a method like:

public Example(String name){
	ResourceLocation location = new ResourceLocation("modid" + ":" + name);
	this.setRegistryName(location);
	this.setUnlocalizedName(name);
}

 

What that does is make it so I can name my Items, for example  item.example.name=Example (and not modid:item.example.name=Example), in my language file and the resource location is set and I can set up my models and textures in the correct locations on my end in my resources.

 

Link to comment
Share on other sites

setRegistryName take in a NAME not a resource location.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

setRegistryName take in a NAME not a resource location.

 

No.... In the interface IForgeRegistryEntry$Impl you set the registry name and it looks like....

 

public final T setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); }
public final T setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); }

 

Link to comment
Share on other sites

IForgeRegistryEntry.Impl#setRegistryName(String)

automatically prefixes the specified name with your mod ID, you don't need to add that manually.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.