01-24-2019, 02:35 AM
(This post was last modified: 01-24-2019, 02:49 AM by peterbell10.)
(01-24-2019, 12:07 AM)xoft Wrote: And that's the main problem of your solution - for some blocks this number is really huge.I don't see how this is problem, could you explain?
Quote:A bit of a problem with your solution is the conversion between BlockStateId and the block state represented as a map<AString, AString> that is serialized in the on-disk format and used in the network protocol. The part of old code you saved from refactoring is (imho more than) offset by the code that does the conversion.
I would expect you only need a single function per block type to perform the translation from the state index to (e.g.) a JSON value for the full block state itself. Whatsmore, I expect most of these to be pretty simple functions e.g. for Bamboo
Json::Value ReadableBlockState(BlockStateMeta Meta) { Json::Value State; State["age"] = Meta % 2; State["leaves"] = [&]{ switch((Meta / 2) % 3) { case 0: return "large"; case 1: return "none"; case 2: return "small"; } }(); State["stage"] = Meta / (2 * 3); return State; }
Also it look like Mojang uses a global palette internally, or at least wiki.vg claims so:
https://wiki.vg/Chunk_Format#Global_and_...n_palettes