Jump to content

[1.8] Changing the player name plate results in the nameplate not being centered


Lucavon

Recommended Posts

Hey everyone!

I'm Lucavon (I'm new here), and I joined the forums to seek help for one problem I have:

I editen the FontRenderer class to replace a player's name with something else using this code:

 

            p_180455_1_ = p_180455_1_.replaceAll("Lucavon" , "test");

 

. The problem is: The name plate of my test player is not centered above their head like it usually is, it goes to the right by far more than it is supposed to (if I make the new name longer than the old one). How do I re-calculate the plate position for the new, longer name?

I am currently only modifying default MC classes generated by the MCP, however I will use forge for the rest of my project, but for this thing I'd like to stay "forge-undependent".

Thanks for your help!

 

-Lucavon

Link to comment
Share on other sites

Modifying Minecraft base files is not supported here.

 

You can change the player name in Forge, so if you want help with that, post here with the issue.

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

Alright, I have just installed forge and eclipse and all that, now my question is:

Is there a simple way to replace a string, no matter where it appears, may it be in in chat, in a book, in the tab list, on the score board etc with another string?

Thanks,

 

-Lucavon

Link to comment
Share on other sites

But what does NameFormat have to do with a String rendered on the for example scoreboard? Is there a way to "modify" the FontRenderer with Forge to change a text COMPLETELY without typing like 100 lines? What I am doing is a little experiement, therefore I do not want to really work that hard on it.... by modifying the base files I just had to type one line and everything that contained "Lucavon" for example was changed to "Test", the only issue being the background of the player name tag. I don't know how to use the NameFormat thingy like at all, I do not even know where I would insert that...

Link to comment
Share on other sites

Well...

 

1. NameFormat is a forge event that is fired whenever game generates name for given EntityPlayer. Once generated name is being cached and reused and can be re-generated using simple:

player.refreshDisplayName();

Event basically allows you to return any string you like.

Do note that minecraft consists of server and client side and NameFormat is sided event - meaning you would have to call it (#refreshDisplayName) on both sides to update both threads.

 

How to? Learn how to use Forge Events. (google)

 

2. If you need to replace some x string with something else you can utilize lang system that allows you to link strings to lang files. Whenever you use lang reference it will be replaced by lang string.

 

3. If you need to replace string whenever it is being rendered in game, no matter if it is generic, from-lang, or modified by NameFormat event you will indeed have to alter FontRenderer by replacing it with you extending class. FontRenderer is located in Minecraft.class as  "fontRendererObj" and can be replaced and render different-than-actual-input strings.

 

4. If you need to replace strings on data-level (meaning not-just-rendering) - it is literally impossible in vanilla/forge.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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