Jump to content

Recommended Posts

Posted

I'm having some trouble retrieving the player on the client side, as when the server sends a packet containing the only player's UUID, the client can't find that player.

 

Why would this be?

 

Here is the offending line:

EntityPlayer player = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(playerID);

 

playerID comes from a packet, which comes from the server. The server simply retrieves the requesting player's UUID using getPersistantID().

Posted

If you are simply trying to identify an online player on the client use the entityID (player.getEntityId()) and World#getEntityByID.

Somehow, that entity does not exist when I try to look it up on the server.

 

Let me explain what I'm trying to do:

When the user mouses over the wand in their inventory, a tooltip displays how much mana they have. The client sends a packet to the server to request the player's mana. The server then looks up the player (tried both EntityID and UUID) and their mana, then sends the player's identifier and mana back to the client, so that they can display it in the tooltip.

 

Is there a better way of doing this, or am I just doing it wrong?

 

(I'll post a whole ton of code if you need me to.)

Posted

Is there ever more than one player in a physical or logical client? If a server sends any mana value to a client, then by implication it is the mana of the player there. Just be careful to send the correct mana value for each world access.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

A better way would be to just sync the data to the client preemptively.

Send the packet telling the client about their mana in PlayerLoggedInEvent and whenever the mana changes. Then the client just always knows.

Thanks, this is much easier! Got it working now, thank you.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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