Jump to content

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


Recommended Posts

Posted

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

Posted

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/

Posted

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

Posted

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...

Posted

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.

  Quote

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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Alright, here is the log file https://mclo.gs/5eCwafV
    • Please read the FAQ (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/) and post log files as described there, using a site such as https://mclo.gs/ and post the link here.  
    • I tried updating the mods in my modpack which caused incompatibilities so i have tried to revert them back to their older versions i was using before. In the logs it doesnt show me any clear incompatibilities except for tfmg & entity texture features, but when i try to remove those it still doesn't work. I have tried removing the forge-client.toml file which was a suggestion i found on  a few other posts. This is the log file i get. [inline log removed] Any help would be appreciated. Thanks in advance
    • I don't use KubeJS, never even heard of it. But after doing what "Ugdhar" suggested earlier in this post with the "config/Mekanism/generator-storage.toml", I tried going into an individual save's serverconfig folder, and just deleting everything except the parcool folder (I have that mod installed.) Then, a bit of loading and temporary freezing later, seems to have worked. Even when quitting to menu and loading back in, or also when quitting to menu, exiting to desktop, and re-launching MC, choose a save and loading it.
    • [Mekanism] Broken tags in Mekanism recipes detected, please check server logs for details. You will be missing some recipes and machines may not accept expected inputs. Do you use KubeJS? It is some kind of bug with it and not fixed A workaround is setting "allowAsyncStreams" to false in the KubeJS common config file https://github.com/KubeJS-Mods/KubeJS/issues/1016   For the rest of your issues, keep deleting these files - now it is the jei-server.toml file If the file is not in config, check the worldsave serverconfig folder These files usually break after updating mods, game crashes or force closing the game    
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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