Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi,

How can I get the current user name of a player, which right click with an item in the hand?

ย 

- Gaprosys

  • Author

Thanks for the reply. A second question, must I then use packets for the transfer of the name?

ย 

- Gaprosys

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?

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.