Player NBT data is not server-client synced

Published by ahznb on Wed, 12/25/2019 - 12:18
Upvotes: 13
Issue description

Currently when one sets a custom NBT tag it is set on one side only. It would be nice if it can be auto set on both sides if requested by the modder (maybe as a function block?)

Issue comments

Syncing data is more advanced than just a simple procedure block as we need to use packets and this is not really possible to implement universally for all use cases.

For overlays, we can add a way to obtain player NBT data, though, I am changing the ticket to this as this could be implemented.

So the overlay would query entity NBT data from the server-side and display it on the client-side.

This fix would also address my issue with scoreboards not syncing so I really have to second this hard.

Entities in general are not the problem, only players are and this ticket is here for this exact reason

This feature will be added in 2020.4. As syncing is only problematic with players as they need data on client-side for display, a different approach was taken.

There are now two new global variable types: PLAYER_LIFETIME and PLAYER_PERSISTENT

There two variable types can be used with normal variable procedures and in UIs. Their scope is:

  • PLAYER_LIFETIME: client-server variable per player for the time of his lifetime (variables reset on death)
  • PLAYER_PERSISTENT: client-server variable per player that is permanent for a player per map save

Marking as fixed.

ALELOUYA! All the love of the world for you! However, I hope we will be able to create new variables as with NBT tags. I mean, with NBT Tags we can create a new one in changing the name, and we can do this by using another variable. So it will be nie to have the same thing for Global variables (otherwise, my camera mod won't work 😢).

Yay it was added! (Wait, Does this work for all players or just one? Sorry I don't know how nbt data works)

PLAYER_PERSISTENT: client-server variable per player that is permanent for a player per map save

YEEEET :D I could finally work on Alloy and my thirst mod again :D

Yay it was added! (Wait, Does this work for all players or just one? Sorry I don't know how nbt data works)

Per player, this system uses the Forge capability system and attaches new "variable" capability to the player.

I hope we will be able to create new variables as with NBT tags. I mean, with NBT Tags we can create a new one in changing the name, and we can do this by using another variable.

This is the reason why I could not make this work with NBT. This system uses Forge capability system and serializes each variable separately. If I would just serialize all NBT tags to support all cases, not just specifically defined tasks, this would overload network communication and also introduce potential problems.

So only variables defined at compile time can be synced to the client.

It will be compatible, but cross-accessing is not possible at the moment due to the implementation details. One could copy data to NBT on the tick update of player to expose it as NBT to other mods.



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.