Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted
	@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

2 hours ago, TheRPGAdventurer said:

but it crashed the game on servers

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

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.

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.

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.

  • Author

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

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.