pmmp / NBT

PHP library for working with the NBT (Named Binary Tag) data storage format, as designed by Mojang.
GNU Lesser General Public License v3.0
40 stars 20 forks source link

Better handling of duplicate CompoundTag keys #101

Open dktapps opened 2 years ago

dktapps commented 2 years ago

Currently, a duplicate key appearing anywhere in some NBT data tree will cause the entire tree to be undecodable using this library. This is severely problematic for legacy PM worlds, because the entire chunk is stored as one big NBT blob in MCRegion, Anvil and PMAnvil worlds. This means that any appearance of a duplicated key will cause the entire chunk to be discarded as corrupted.

This issue has caused a large number of worlds created with PM older than ~2017 to lose any chunks containing furnace due to a duplicate BurnTime key (this was originally fixed by https://github.com/pmmp/PocketMine-MP/commit/20b86bdea8764a5ce5020758b90fb0e7228ce479). However, any worlds created before this commit which were not loaded prior to the fix of #54 will now experience full data loss if this happened in any of their chunks, which is not cool.

Possible solutions

dktapps commented 2 years ago

For now I've resorted to just ignoring the duplicates, since this is a major issue that is actively causing data loss for older worlds. 3e0d9ef6b6c5fb45e3745a121296e75631b3eefe