-
-
Notifications
You must be signed in to change notification settings - Fork 632
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
Add an NBT tree structure #4179
base: master
Are you sure you want to change the base?
Conversation
783c8ff
to
089fe45
Compare
Just for the naming I would prefer |
The name is meant to complement |
85ca4f3
to
3ebab4c
Compare
5726089
to
93b3f95
Compare
@peterbell10 are you still working on this? May I help you? I'd like to use the NBT tags with my banner pull request |
As far as I remember this works as-is. It just never got reviewed. |
Time for a review then, I'll try rebasing and have a go this evening. |
So I rebased on master. There were two words which required attention in MVSC. I fixed this but i'm not quite shure if I should commit. In all I think the code should be merged |
|
||
void clear() { m_Tags.clear(); } | ||
|
||
void swap(cList & a_Other) NOEXCEPT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void swap(cList & a_Other) NOEXCEPT | |
void swap(cList & a_Other) noexcept |
MSVC doesn't like this. Didn't check other. Yeah GCC doesn't like this either
m_Tags.swap(a_Other.m_Tags); | ||
} | ||
|
||
friend void swap(cList & a_Lhs, cList & a_Rhs) NOEXCEPT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
friend void swap(cList & a_Lhs, cList & a_Rhs) NOEXCEPT | |
friend void swap(cList & a_Lhs, cList & a_Rhs) noexcept |
same here
Another thing: we should enable the Packet writer and the NBT write to write those tags into themselves for easy transimission and saving |
Bearbin and I took a look at this and we came to the conclusion that this was a reimplementation of std::variant. Something like this may suffice. #include <cassert>
#include <iostream>
#include <map>
#include <variant>
#include <vector>
class NBT
{
public:
using List = std::vector<NBT>;
using Compound = std::map<std::string, NBT>;
using NubbyTree = std::variant<
int,
bool,
List,
Compound
>;
NBT(NubbyTree canopy)
{
top = canopy;
}
auto & Expose() const
{
return top;
}
void Poosh(NBT nubby)
{
assert(std::holds_alternative<List>(top));
auto & lIsT = std::get<List>(top);
assert(
lIsT.empty() ||
lIsT.back().top.index() == nubby.top.index()
);
lIsT.emplace_back(std::move(nubby));
}
private: // its privates
NubbyTree top;
};
void MakeNubby()
{
NBT Root{ NBT::List() };
Root.Poosh({ 1 });
Root.Poosh({ 2 });
for (const auto & Item : std::get<NBT::List>(Root.Expose()))
{
std::cout << std::get<int>(Item.Expose()) << '\n';
}
}
int main()
{
MakeNubby();
} |
Yeah I just noticed that also that you use a variant and make a nice interface |
So what do we do now? I'd like to have the NBT for items added for other projects (Banner, Potions,...) |
Has there been any progress on this recently? |
Check the discussion in #5015 |
This is the first step in fixing #3682 and adding support for storing arbitrary NBT in
cItem
.