Jump to content

[1.8.9] Rendering Text ONLY on the Client's Player's head.


Recommended Posts

Hello! I am making a mod that displays a custom message above everyone's head. I would like to have the option to only render it on the client's player's head (only on the head of the player using the mod). Here is the function:

public void render(RenderPlayerEvent.Pre event) {
	String s;
        if(settings.enabled) {
	        if(!event.entityPlayer.isSneaking() && (s = settings.hmsg) != null) {
	        //if(!event.entityPlayer.isSneaking() && event.entityPlayer.getUniqueID().toString() == minecraft.getSession().getProfile().getId().toString()) {
	            double offset = 0.3;
	            Scoreboard scoreboard = event.entityPlayer.getWorldScoreboard();
	            ScoreObjective scoreObjective = scoreboard.getObjectiveInDisplaySlot(2);
	            if(scoreObjective != null) {
	                offset *= 2;
	            renderName(event.renderer, s, event.entityPlayer, event.x, event.y+offset, event.z);

This function renders the string "s" over every player's head. I need a way to make it render only on the user's head. As you might've been able to tell from the comment under the 2nd 'if' statement, I tried comparing the event player (player it is trying to render on) UUID to the Client's session UUID (the UUID of the user). Using this method renders the text on nobody's head. Maybe I am comparing UUIDs the wrong way? I would preferably also like to switch between rendering on everyone's head and only the user's head using a boolean "onEveryone" I have already declared in the configuration file. Thank you!

Link to comment
Share on other sites

This topic is now closed to further replies.


  • Create New...

Important Information

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