Jump to content

[1.7.10]Player lookup from UUID returns null


nosrick

Recommended Posts

World.func_152378_a(UUID) is supposed to return an EntityPlayer, but when I try to call it with a saved player ID (at world load, using NBT tags), it returns null. Does anyone know what I'm doing wrong?

1) Check that player is already logged in

2) Check that you're doing it in correct world (each dimension has different worlds)

Link to comment
Share on other sites

How do I go about doing those things?

1) Do your thing after player logged in: if you can, do this when player joins the world...

2) Save dimension id where player was, and then get world via

World world = MinecraftServer.getServer().worldServerForDimension(dimId);

Link to comment
Share on other sites

I'm not sure I can, since the loading occurs in the entity class. Is there a way for me to check when the player logs in, inside of that class?

 

Just did the dimension saving thing; it made no difference, still returns null.

Link to comment
Share on other sites

Oh, right! Now I get it. Thanks for clearing that up.

 

I pretty much copied the way EntityAIFollowOwner does it, except I don't use data watchers because I am not familiar with them.

 

A UUID is used in the Entity, because it is passed in from the egg it hatches from.

 

An EntityPlayer is used in the AI, because otherwise I'd be calling worldObj.func_152378_a(UUID) all the time to get one for the information required to move towards it.

Link to comment
Share on other sites

Has anyone got any idea why this might be happening?

 

Should I try switching the Entity to inherit from EntityTameable, and use the vanilla EntityAIFollowOwner?

If I did, how would I set the owner the moment the egg hatched, rather than when it was fed a certain item?

Link to comment
Share on other sites

I have a question about the players UUID. How are they actually saved, Ive been looking at the Yggdrasil class with Ernio and we both got stumped by how/where the players uuid is actually being saved. I want to create a dynamic link between an entity and the player and so far I havent had any luck with this.

Link to comment
Share on other sites

I have a question about the players UUID. How are they actually saved, Ive been looking at the Yggdrasil class with Ernio and we both got stumped by how/where the players uuid is actually being saved. I want to create a dynamic link between an entity and the player and so far I havent had any luck with this.

How:

uuid.toString returns string form uuid. UUID.fromString returns uuid from string. I hope you know how to save string, right?

 

Where:

EntityTameable.getOwner returns owner from watchable string (representing uuid) with id 17, that is saved and loaded like all data watchers....

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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