Posted August 16, 201411 yr Basically I started this thread over here: http://www.minecraftforge.net/forum/index.php/topic,22260.0.html Basically what I'd like to do is intercept usernames and change them. Clientsided ONLY. The mod is not going to be installed on the server. If you read towards the few replies in the end of the thread you'll understand what problems this causes. I'd like an explanation of how this can be solved as I really have no idea. Using reflection on entityplayer didn't work. Maybe there is another event than NameEvent that you can tie into to change the display names? I have no idea.
August 16, 201411 yr PlayerEvent.NameFormat seems like exactly what you're looking for but you seem against that in the previous thread from what I've read. I don't actually think reflection would help you at all here (not with displayname) because NameFormat gets fired every time getDisplayName or refreshDisplayName is called, I believe, which is exactly the same as changing displayname through reflection. This should affect scoreboards etc (though only on your client, other people on the server will see the normal username) If it doesn't, what you can try to do is to intercept every time a GUI that contains the name is opened (Player list when you press TAB, chat, scoreboard, etc.) and then replace it with your own GUIScreen that extends the type you're trying to intercept, with your own code in the places you need it, though this seems like a whole lot of extra work and could potentially break compatibility with any other mods trying to do the same thing. BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
August 16, 201411 yr Author PlayerEvent.NameFormat seems like exactly what you're looking for but you seem against that in the previous thread from what I've read. I don't actually think reflection would help you at all here (not with displayname) because NameFormat gets fired every time getDisplayName or refreshDisplayName is called, I believe, which is exactly the same as changing displayname through reflection. This should affect scoreboards etc (though only on your client, other people on the server will see the normal username) If it doesn't, what you can try to do is to intercept every time a GUI that contains the name is opened (Player list when you press TAB, chat, scoreboard, etc.) and then replace it with your own GUIScreen that extends the type you're trying to intercept, with your own code in the places you need it, though this seems like a whole lot of extra work and could potentially break compatibility with any other mods trying to do the same thing. I'd love to use nameformat, but it only fires on the server? If you read the thread my code works properly, but if I try it out on a multiplayer server my events just refuse to fire.
August 16, 201411 yr I tested it, it seems that's true. I'm doing some testing now to try and find a way to do this, I'll tell you if I find anything. So far I've tried reflection on the Minecraft.getMinecraft player, and reflection on the GameProfile too. No results yet. BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
August 16, 201411 yr Author I tested it, it seems that's true. I'm doing some testing now to try and find a way to do this, I'll tell you if I find anything. So far I've tried reflection on the Minecraft.getMinecraft player, and reflection on the GameProfile too. No results yet. Thank you! If you figure it out it would be nice if you also include the code as that makes it much easier for me to understand. Having some code to reference when reading how someone did it is always helpful.
August 16, 201411 yr I have not had much luck yet. I'm sure there's an easy solution but I can't find it, and I'm too tired to keep checking. I suggest you set up some break-points in places you think might have to do with how certain of the GUIs get the name and trace it to a point you can easily change. BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
August 16, 201411 yr Author I have not had much luck yet. I'm sure there's an easy solution but I can't find it, and I'm too tired to keep checking. I suggest you set up some break-points in places you think might have to do with how certain of the GUIs get the name and trace it to a point you can easily change. I'll have a look into intercepting every GUI call... But those are many places. Anyway, I doubt I'll even be done with it today since I don't have much time left. Friends coming over and stuff. And having someone else look at it is probably a good idea too.
August 17, 201411 yr You could give FMLNetworkEvent.ClientCustomPacketEvent a go. I haven't looked into it, but I'd assume chat messages, and the score board would update using packets. This will allow you to control both the packet that was received, and change the reply so that you might even get away with other clients seeing it the way you want to (as the server will get your information, and relay it to all other clients). Edit: Nevermind, that's only for custom packets. I misread, sorry. BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
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.