Skip to content

Instantly share code, notes, and snippets.

@williewillus
Last active April 20, 2019 20:46
Show Gist options
  • Save williewillus/7945c4959b1142ece9828706b527c5a4 to your computer and use it in GitHub Desktop.
Save williewillus/7945c4959b1142ece9828706b527c5a4 to your computer and use it in GitHub Desktop.
1.9.4 te syncing

1.9.4 TE Syncing

Only accurate for 1922+

When the chunk/block data is sent (client receiving chunks from server):

  • getUpdateTag() called serverside to get compound to sync
  • handleUpdateTag() called to handle it clientside
  • what vanilla does
    • Writes ALL data into this tag by calling writeToNBT
    • Reads it all back out using readFromNBT
  • Mods:
    • Put whatever you want to be initially synced with the chunk, it comes back to you in handleUpdateTag()
  • Caveat: whatever tag you return must have the position of the TE in the "x" "y" and "z" tags. Otherwise MC doesn't know which TE to apply the packet to since we don't have anything like entity ID's. Any packets whose tags are missing "x" "y" and "z" are silently discarded. The default implementation of getUpdateTag already does this for you so just call super and add on to it.

When individual TE's are (re)synced (via notifyBlockUpdate, placing blocks, etc):

  • getUpdatePacket() called serverside to get a SPacketUpdateTileEntity
  • onDataPacket() called to handle it clientside for mods
  • what vanilla does: uses the compound from getUpdateTag()
    • Writes ALL data into this tag by calling writeToNBT
    • Reads it all back out using readFromNBT
  • Mods:
    • Put whatever you want to be sent in subsequent resyncs, it comes back to you in onDataPacket()
  • Noncaveat: The position of the TE is in the packet, so this compound need not have the TE position

To resync a TE by hand:

  • Call notifyBlockUpdate with the "send to client" flag set
  • use getUpdatePacket() to get the packet and send it yourself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment