Jump to content

Recommended Posts

Posted

Hey,

I started coding with forge some days ago and now I'm wondering how I can change the name of the Client on the Clientside?

So everyone can see the real name of the player but he just sees for example "Notch" and not "MisterQuatsch".

I know that need to change it in the Tablist, Chat, Scoreboard and maybe when his name is on Items, Tablist and so on.

So is it possible and when yes how?

 

Thanks for any help :D

 

~MisterQuatsch

Posted
PlayerEvent.NameFormat

is fired when a player's display name is retrieved for the first time (or refreshed by calling

EntityPlayer#refreshDisplayName

). You can use this to change the player's display name.

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.

Posted

Ok I found it out and if anyone ever need this here is how you can do it.

1. Go into net.minecraft.client.gui.FontRenderer.java

2. Find this function "func_175065_a" or the "drawString" function.

3. Add this code before the "GlStateManager.enableAlpha();"

if ((Minecraft.getMinecraft().getNetHandler() != null) && (SomeThing == true))
        {
        if (p_175065_1_.contains(Minecraft.getMinecraft().session.getUsername())) {
          p_175065_1_ =  p_175065_1_.replace(Minecraft.getMinecraft().session.getUsername(), "NewDisplayNameForTheClient");
        }
      }

4. Incase you have a empty name or nothing is in the Chat when you write something add this below:

		
if (p_175065_1_.contains(Minecraft.getMinecraft().session.getUsername())) {
p_175065_1_ = p_175065_1_.replace(Minecraft.getMinecraft().session.getUsername(), Minecraft.getMinecraft().session.getUsername());
}

5. So the complete Code would be:

if ((Minecraft.getMinecraft().getNetHandler() != null) && (SomeThing == true))
        {
        if (p_175065_1_.contains(Minecraft.getMinecraft().session.getUsername())) {
          p_175065_1_ =  p_175065_1_.replace(Minecraft.getMinecraft().session.getUsername(), "NewDisplayNameForTheClient");
        }
      }
if (p_175065_1_.contains(Minecraft.getMinecraft().session.getUsername())) {
p_175065_1_ = p_175065_1_.replace(Minecraft.getMinecraft().session.getUsername(), Minecraft.getMinecraft().session.getUsername());
}

 

~ MisterQuatsch

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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