Rodrigo Silva
Rodrigo Silva
The fix itself is quite simple: ```python class Root(Compound): __slots__ = ( 'root_name', ) # Optional, but safer than relying on .parse() to be always invoked def __init__(self, root_name: str...
While I'm still digesting your great points, and elaborating an extended answer, I've noticed you dropped `Root` class as a whole. Just to note this wasn't the proposed fix to...
There are 2 important and distinct design choices involved here, both are open to interpretation by the "official" docs: 1 - Who "owns" a tag's name? Itself or its parent?...
But a tag not owning its own name leaves `nbtlib` with a (small) problem: What about the root? In NBT, the root tag (whatever type it is), _does_ have a...
So handling a root's name while keeping `nbtlib`'s data model is easy, and can be addressed in many ways. Now for the hard part, the other major design decision: -...
So, NBT-wise, `nbtlib` is _not_ assuming the root is a compound. If it were something else, it would be handled properly and losslessly. But to do so it wraps the...
In order to avoid the extra layer _and_ preserve the root name, we _must_ parse it separately from other tags, as each tag's `.parse()` assume its own name (and tag...
In this scenario, class `File`/`Root` _inheriting_ from `Compound` becomes a problem. It means the root tag is _always_ a Compound. And if we go that road, life is easy and...
> We need a way to save a tag, _any_ tag, **as** root. That is, to write its own type and its own name, unlike other tags. So a root,...
I've just found this: http://web.archive.org/web/20110723210920/http://www.minecraft.net/docs/NBT.txt > An NBT file consists of a single GZIPped Named Tag of type TAG_Compound. > Decoding example: > (Use http://www.minecraft.net/docs/test.nbt to test your implementation) >...