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.

Featured Replies

Posted

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:

@SubscribeEvent
public void render(RenderPlayerEvent.Pre event) {
	String s;
        if(settings.enabled) {
	        //event.entityPlayer.getUniqueID
	        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!

Guest
This topic is now closed to further replies.

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.