Posted May 1, 201510 yr 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?
May 1, 201510 yr 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.
May 1, 201510 yr 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.
May 1, 201510 yr Author Thanks for all the help! I should be able to figure it out now, but if not, I'll report back.
May 1, 201510 yr 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?
May 1, 201510 yr 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.
May 2, 201510 yr For my defence - this is pure vanilla code from 1.8, you think I wouldn't use for each? 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.