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.

[1.7.10][SOLVED]Is it possible to get the player who placed a block?

Featured Replies

Posted

For my tamagotchi mod, I need to assign a player as an owner of a 'gotchi. I've got a tile entity representing the egg, which hatches into an entity, at which point it should start following a player around.

 

So, is it possible to get the player who placed the egg down? If not, what might be a good way of assigning an owner to a new 'gotchi?

Above, and note: you can get player.getUUID() to save player to TileEntity's NBT (one UUID = one player).

To retrieve: MinecraftServer#getEntityFromUuid(UUID uuid) // I think there is player-specific method, yet I don't remember

 

Note: UUIDs are only working on server side.

 

EDIT

Yup, there is: World#getPlayerEntityByUUID(UUID uuid) - but it works per-world.

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

Note: UUIDs are only working on server side.

 

And only on servers not in offline mode.

(Development dedicated server defaults to offline).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Thanks for all the help! I should be able to figure it out now, but if not, I'll report back.

  • Author

Above, and note: you can get player.getUUID() to save player to TileEntity's NBT (one UUID = one player).

To retrieve: MinecraftServer#getEntityFromUuid(UUID uuid) // I think there is player-specific method, yet I don't remember

 

Note: UUIDs are only working on server side.

 

EDIT

Yup, there is: World#getPlayerEntityByUUID(UUID uuid) - but it works per-world.

 

I can only find World#getPlayerEntityByName(). Is it perhaps a 1.8 feature, or am I missing something?

Might be, you could implement it on your own.

 

public EntityPlayer getPlayerEntityByUUID(UUID uuid)
    {
        for (int i = 0; i < this.playerEntities.size(); ++i)
        {
            EntityPlayer entityplayer = (EntityPlayer)this.playerEntities.get(i);

            if (uuid.equals(entityplayer.getUniqueID()))
            {
                return entityplayer;
            }
        }

        return null;
    }

 

playerEntities is public (in 1.8 ).

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

For my defence - this is pure vanilla code from 1.8, you think I wouldn't use for each? :D

Just showing what might not be in 1.7.10.

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.