Jump to content

[Solved] Change name for Client


MisterQuatsch

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

But would this also be a possible with just the Vanilla MCP?

No, not in a good way.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Editing base-classes is not supported. Use the

PlayerEvent.NameFormat

event.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

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.