Jump to content

Replacement for deprecated method return net.minecraft.util.text.translation.I18n.translateToLocal


TheRPGAdventurer

Recommended Posts

	@Override
	public String getName() {
		// return custom name if set
		if (hasCustomName()) {
			return getCustomNameTag();
		}

		// return default breed name otherwise
		String entName = EntityList.getEntityString(this);
		String breedName = getBreedType().getName().toLowerCase();
		return net.minecraft.util.text.translation.I18n.translateToLocal("entity." + entName + "." + breedName + ".name");
		
	}

I used it for my dragon mob here, I once accidentally used the client version but it crashed the game on servers

Link to comment
Share on other sites

5 minutes ago, TheRPGAdventurer said:

thats exactly what i used and crashed the game on servers, i called it client version

 

17 hours ago, V0idWa1k3r said:

Obviously don't do translations on a server since languages are a thing of the client.

 

There is no "server version" because the server isn't aware of translations being a thing. Translation only happens on the client.

Link to comment
Share on other sites

1 hour ago, V0idWa1k3r said:

There is no "server version" because the server isn't aware of translations being a thing. Translation only happens on the client.

 

There are still some Vanilla methods like Entity#getName that perform translation but aren't client-only. These use the deprecated net.minecraft.util.text.translation.I18n and I don't think there's any real alternative.

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

5 minutes ago, Choonster said:

These use the deprecated net.minecraft.util.text.translation.I18n and I don't think there's any real alternative.

While that is true from what I can tell the server itself currently only keeps the english translation(or at least it exists within the server's jar, whether it actually collects the translation or not is something to debug). In general I assume that the best course of action is to not do translations on the server at all, since the deprecated I18n even at best would only perform the english translation. Return the unlocalized name for the client to translate on the server and perform the translation on the client. There is no need to use the deprecated class here, a proxy would suffice. It just seems like a logical way of approaching things to me.

Link to comment
Share on other sites

but i still use it for my dragons to classify each breed and return its name, would the dragons despawn without

return net.minecraft.util.text.translation.I18n.translateToLocal("entity." + entName + "." + breedName + ".name");
		

 

My lang file

 

entity.DragonMount.ice.name=Snow Dragon
entity.DragonMount.end.name=Ender Dragon
entity.DragonMount.aether.name=Sky Dragon
entity.DragonMount.forest.name=Forest Dragon
entity.DragonMount.sylphid.name=Water Dragon
entity.DragonMount.nether.name=Nether Dragon
entity.DragonMount.fire.name=Fire Dragon
entity.DragonMount.skeleton.name=Skeleton Dragon
entity.DragonMount.wither.name=Wither Dragon
entity.DragonMount.enchant.name=Enchantment Dragon
entity.DragonMount.sunlight.name=Sunlight Dragon
entity.DragonMount.storm.name=Storm Dragon
entity.DragonMount.zombie.name=Zombie Dragon

 

entity name is DragonMount

Edited by TheRPGAdventurer
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.