Posted June 8, 20196 yr I have a capability attached to an entity. It's saved to nbt when you exit the world. When I next load the world I want that capability to be synced to the client (after it has loaded the data back from the serialised nbt). I have tried sending a packet to the client using the EntityJoinWorldEvent, however, at this point the capability hasn't been attached to the entity on client, so the packet is useless. At what point can I send a packet to sync the client and server? Is this the correct way to sync the two on the world load? Edited June 8, 20196 yr by harison513
June 8, 20196 yr Author 37 minutes ago, diesieben07 said: To keep entity data up to date on the client you must sync in the following places: PlayerEvent.StartTracking when PlayerEvent.StartTracking#getTarget is your entity (or has your capability in this case). Send the packet to PlayerEvent.StartTracking#getEntityPlayer. EntityJoinWorldEvent when EntityJoinWorldEvent#getEntity is your entity (or has your capability in this case). Send the packet to all players tracking the entity (EntityTracker#getTrackingPlayers or use PacketDistributor.TRACKING_ENTITY when using NetworkRegistry.newSimpleChannel). Whenever the data changes send the packet to all players tracking the entity (see above). Didn't know PlayerEvent.StartTracking existed so thanks, that has solved my problem.
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.