Jump to content

Recommended Posts

Posted

Okay. I've been working with Forge for a number of weeks now, slowly losing my sanity through exposure to the eldritch abominations in Minecraft's internal workings. For the most part, things are going pretty well, but I've finally hit a problem that several days of Googling and JavaDoc surfing and even reverse engineering has not yet solved.

 

My mod requires, client-side, some information that's only available server side. There are two classes of information it requires: static information, such as an entity's real persistent ID (not the "persistent" ID the client already has, which isn't even consistent over a single play session); and dynamic information, such as whether a Zombie Pigman is currently angry, or a Villager is currently playing.

 

For the static information, I have a simple protocol in place where the client requests the information the first time it's needed. That will not, however, work for the dynamic information. What I need is to perform my own synchronization in parallel with the normal entity sync process. This will require hooking into something so that I know which clients are currently interested in which entities. Unfortunately, aside from a vague idea that this will involve the

EntityTracker

class, I have no idea how to proceed.

 

Heck, I can't even figure out the best way to communicate about a specific entity. I haven't found a

getEntityById

-type method method anywhere but in

World

, and I can't seem to communicate a specific

World

---I tried going by dimension ID, but

DimensionManager.getWorld(...)

always seems to return

null

on the client in proper multiplayer (but not fake multiplayer, i.e. singleplayer?), despite the fact that the

Entity

instances somehow know what dimension they belong in... sigh.

 

Any help is appreciated greatly.

Posted

For the static entity data i think there is an interface called something like IEntityAdditionalSpawnData you may want to check out. 

 

For dynamic entity data  you should use a custom packet to sync.  The key is to pass the entity id as an integer in the message payload.  I send a sync from server to client that works like this:  you send the packet from the entity class whenever a custom field you want to sync changes.  you get the entity ID by simply using the getEntityID() method and write that int into message payload. Then on client side when you receive the packet read that int and use

Entity foundEntity = getEntityByID(entityID, theWorld);

 

That id should work to identify the right entity on client based on ID sent by server in the sync packet.

 

Hope that helps.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Hi

 

For the synchronisation of Entity information, try a search on DataWatcher.  They are used to synchronise  (for example) entity health on the server to the client.  They are automatically sent when they change.  Vanilla reserves some of them for its own use, but there are others which are free for your small bits of information.  The hardest bit is to figure out which ones are unused by vanilla.

 

-TGG

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.

Announcements



×
×
  • Create New...

Important Information

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