Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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/

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.