New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create NBT Support with Variant in cItem #5454
base: master
Are you sure you want to change the base?
Conversation
Looks good, seems like the right idea! My main initial observation is that std::optional isn't very graceful; one liners are expanding into 4+ lines before our very eyes. I don't think there's much we can do about that. For the tags we're storing in the variant, I remember vanilla putting a lot of fields in the root level but we could group ours by purpose, mainly to prevent any conflicts. It's also surprising that vanilla calls for the item's damage to also be stored in the variant as a "general tag", this will probably cause a bit a breakage and API headaches. I can have a more detailed look 🔍 later... |
Reguarding Yeah. This isn't very graceful indeed. I thought about that but returning a Boolean and using a reference as a parameter as the better didn't seem better. And creating the requested value if it didn't exist destroys the purpose of the variant vector. Reguarding the damage. Good point. I kept the integer values purposefully out of the variant for easy access and since they consume little memory it shouldn't be that bad. |
I need some help with the manual bindings to the firework item. I am not quite sure how to obtain a pointer to the firework item since a pointer is needed |
There was no function to push a firework item to the lua stack so the firework pointer is evaluated to bool which is :(
Hello CI are you there? |
This PR tries to kick of further development if additional data is stored into an item.
There is a new member
m_Properties
which is a vector of a variant which stores all possible data.Access is done with
get<>()
andset<>()
which both are templated methods which return a optional which contains the requested data. I tried to keep access as simple as possible to ensure easy programming. Sadly optional doesn't support references so the value has to be retrieved withget
, modified ad written back with.set
.Any use in the C++ code is adapted to this. Old Lua Binding should be intact by manual binding the old values.
Im am not 100% sure about my Lua implementation, please check that!