How to change player names?

Started by Silky_Chillz on Mon, 08/06/2018 - 22:49

Topic category: Help with MCreator modding

Last seen on 17:21, 8. Aug 2018
Joined Nov 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
How to change player names?
Mon, 08/06/2018 - 22:49

Hey, I was wondering if there was a way to change a players name? Like if your real Minecraft username is one thing, you could make it look different in chat?

Last seen on 23:58, 10. Nov 2018
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
There is an event…
Tue, 08/07/2018 - 00:54

There is an event PlayerEvent.NameFormat that you can use to this. First you have to have a working and registered event handler class (I have definitely described how to do so many times here on MCreator forum, so you can try to find these posts, however long story short - all you have to do is making a blank GUI overlay element - as it is already a working event handler).

So in the event handler just subscribe to the PlayerEvent.NameFormat event (again - take a look on the old posts or the GUI overlay element).

The event has many fields, including username and displayname. Username is the original name and displayname is the name that will be used for rendering. Depending on your needs just change the value displayname to whatever you want. Before version 1.9 you could do so directly, but as from 1.9 many fields in event classes have become private, you will maybe need to use some setter (and possible also getter) method.