Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
Exactly: Enchantments - do we keep them parsed as they are now, or do we just add them to the JSON data? Or both? There are data members that are in between and we will have a hard time deciding what to do with them.
Posts: 4,629
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
I suppose there is no nice way to keep both in sync somehow where once I update the m_Enchantments member the m_ItemMeta automagically updates with it.
Or is it perhaps possible using the __index and __newindex metamethod. If the enchantment member doesn't exist in the metadata it looks inside m_Enchantments.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
It's not only about the Lua side of things, it would have to be done in C++, and it would be a mess.
Posts: 513
Threads: 10
Joined: May 2014
Thanks: 138
Given 89 thank(s) in 75 post(s)
05-22-2017, 02:54 AM
(This post was last modified: 05-22-2017, 02:54 AM by Seadragon91.)
Spawn eggs also have NBT, they can have lots of information: Custom name, health, item drop, speed and much more. I would say move everything to JSON, on c++ side, too.
Posts: 5
Threads: 1
Joined: Aug 2017
Thanks: 0
Given 0 thank(s) in 0 post(s)
JSON Metadata would be exceptionally useful. Has there been any additional work on this?
Posts: 16
Threads: 0
Joined: Aug 2017
Thanks: 0
Given 2 thank(s) in 2 post(s)
Doesn't storing NBT as JSON lose type information? I suppose this would either break world compatibility or require extra handling for each item.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
It does. We'd have to add some form of support so that Cuberite or its plugins could indicate the NBT type for specific values, if desired.
I imagine there are two use-cases for custom data:
- implementing stuff that is in Vanilla, such as the spawn eggs etc.
- just using it to store custom value that the plugin can then use
For the first one, we'd need explicit type information, so that vanilla compatibility is achieved. For the second, we don't care, as long as the plugin handles whatever it needs. The question is, do we want both of these use-cases to go through the same storage mechanism, or do we want to separate them?
Posts: 16
Threads: 0
Joined: Aug 2017
Thanks: 0
Given 2 thank(s) in 2 post(s)
In the end it will all have to stored in NBT anyway so I can't see any way to separate them. However, storing as JSON and finding a way to attach extra type metadata sounds backward to me. JSON::Value is just being used as a poor man's variant.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
The custom values for plugins' use could be stored as a single json blob, so it could still benefit from the no-type-requirement usecase.