Posted July 22, 201510 yr 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"); }else{ //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.
July 22, 201510 yr 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. EDIT Diesieben was faster. 1.7.10 is no longer supported by forge, you are on your own.
July 22, 201510 yr Author I appreciate all of your responses, I will try using PlayerEvent.NameFormat.
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.