Posted May 18, 20169 yr Hi, How can I get the current user name of a player, which right click with an item in the hand? - Gaprosys
May 18, 20169 yr Call Entity#getName or EntityPlayer#getGameProfile and GameProfile#getName . 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.
May 18, 20169 yr Author Thanks for the reply. A second question, must I then use packets for the transfer of the name? - Gaprosys
May 18, 20169 yr What are you trying to achieve? 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.
May 18, 20169 yr I think he means just generally getting a player's name from the server or getting a player's name to another player. Would you use a packet for that?
May 18, 20169 yr Okay so basically some design stuff: There is server that saves/loads/holds ALL entities. There are some client that connect to server (dedicated or integrated SP) and ask for Entities that are in their range. Client only has one World (the one you are in) - Minecraft#theWorld, same for Minecraft#thePlayer which is your-client-side you. Now - the entities you see (in range) are "mirrors" of server ones so if you see them on client your client-side entities will most likely hold data same or close-to server's. So if you are asking about getting some player's name - if you see him, you can ask your client to return name: Entity#getName(). If you don't see an entity (on client) then you can't know anything about it (you don't have it, only server does). To get that data you MUST send separate custom packet with data you need and hold it somewhere on client. Now - the rule above is a little expanded for EntityPlayers - on client you don't always have all players that are on server (you only have those you see), BUT you do have their profiles which allow you to get some data about them, even if you don't see them.. That data can be pulled from.... (I don't remember, someone can finish my sentence). If you want to find it on your own - there is a tab feature in-game that shows you all logged in players - track down (in vanilla code) where that is rendered and check what it calls (I can't, no IDE). 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.