Jump to content

Changing Client-side Player Nametags


Recommended Posts

Hello everyone! I am very new to developing with Forge (I am used to Bukkit/Spigot), and I was hoping someone could shed some light on how to change a player's nametag based on how much health they have. For instance:

public void onNameTag(AsyncPlayerReceiveNameTagEvent event) {

if (event.getPlayer().getHealth == 20.0f) {

event.setTag(player.getName() + " 20HP");


//other stuff



I want this to work on both servers, and local worlds. I don't believe I have to send packets, because I only want this to appear client-side. In theory, it should set the nametag above every player,who has full health, to display their original name + "20HP". I want to thank anyone who responds to this in advance.

Link to comment
Share on other sites

PlayerEvent.NameFormat is only event that gives you power over this feature.


If you want more complex displays you will need RenderWorldLastEvent and render tags on your own.


Note to you:

As you are Bukkit/Spigot guy - you need to see that Forge is Modding platform, while others are "plugins". Big difference is the fact that forge ships tools that allow you to do almost anything, but has no ver-specific-like-bukkit-ones. If you want to have more fun with "plugins" rather that real modding I suggest SpongeAPI (edit) for Forge.



Diesieben was faster. :x

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

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.

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.


  • Create New...

Important Information

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