15 Commits

Author SHA1 Message Date
Bjarne Koll
ffd15611c7
SPIGOT-7608: Allow empty lists to morph to any PDT list
The minecraft serialisation logic for ListTag updates the type byte of
the list tag during writing to match either the first element in the
list or 0, if said list tag is empty.
As such, list content type information cannot be carried through a
write/read process, e.g. chunk load/unload or a creative client updating
the item.

The recently introduced persistent data type collections for lists hence
can also not enforce a specific list content type if the found list is
empty, which it currently attempts to do.
As such, a call to PersistentDataContainer#has would also yield false
for any empty list as the lists type byte would be 0.

The faulty behaviour has been fixed by considering an empty list in the
persistent data container to match any list type.
This change, while technically breaking the #has check, is needed and
reasonable as the #has check for this is currently broken in the first
place as described above.
2024-03-30 10:46:03 +11:00
Bjarne Koll
4e419c774c
#1295: Define native persistent data types for lists 2024-01-06 16:03:58 +11:00
Jishuna
4fea66e448
#1299: Add new PersistentDataContainer methods and clean up docs 2023-12-08 19:29:38 +11:00
Bjarne Koll
f0661c3514
#1230: Move unstructured PDC NBT serialisation to SNBT
The initial implementation of the CraftNBTTagConfigSerialiser attempted
to represent the entire NBT tree in yaml. While the tree structure
itself is nicely represented, the values and their respective types
become increasingly difficult to properly store in the context of
snakeyml/yml in general.

This is mainly due to the fact that nbt offers a lot of different types
compared to yaml, specifically the primitive arrays and different
floating point values are troublesome as they require parsing via mojang
parsers due to their custom format.

To build a future proof system for unstructured nbt in spigot yml,
this commit moves the entire serialisation fully into SNBT,
producing a single string as output rather than a full yml tree.
SNBT remains easily readable and editable for server owners, which was
one of the main criteria during the initial implementation of the
serialiser (preventing the use of bas64ed gzipped nbt bytes), while also
completely using mojangs parsing, eliminating any need for custom
parsing logic in spigot.

Additionally, a string allows for very straight forward handling of
legacy data by simply parsing strings as SNBT and maps/yml trees as
legacy content, depending on what type snakeyml produces after parsing
the yml content, removing the need for a versioning schema.
2023-09-24 10:12:19 +10:00
Doc
40945171bf
#1182: Consolidate Preconditions use and minor cleanup 2023-06-12 19:41:02 +10:00
Bjarne Koll
f49e9d1932
#971: Remove strong chunk reference in PDC
A previous fix for SPIGOT-6814 implemented a callback function for the
PDC implementation that could be set to actively define a chunk as
unsaved, allowing chunks that have not been mutated through block
changes to still require saving if the chunks pdc was mutated.

This implementation however would pass a callback that references the
chunk access internally, meaning the PDC now actively holds onto a
callback that holds a reference to the entire chunk.

Aditionally, this change also impacted the pdc for item metas and
entities for really no reason whatsoever.

This commit re-implements the fix by introducing a new child of the pdc
implementation that the chunk now uses as its pdc. This specific
implementation maintains a dirty flag that is set to `true` on any form
of mutation and set back to false by the chunk that owns the PDC
whenever the chunk itself is flag as no longer dirty.
2021-12-05 08:53:46 +11:00
DerFrZocker
04f8e7e21f
SPIGOT-6814: (Chunk) PersistentData is lost after restart 2021-11-29 09:28:19 +11:00
md_5
a7b8b0270a
Update to Minecraft 1.18-pre5 2021-11-22 09:00:00 +11:00
Wesley Smith
d49530f9c4
#845: Remove unnecessary calls to Class#getSimpleName in PDC 2021-05-21 08:25:11 +10:00
md_5
90d6905b15
Repackage NMS 2021-03-16 09:00:00 +11:00
Parker Hawke
c49b67ac91
#685: Implement support for PersistentDataContainer arrays 2020-06-26 10:49:28 +10:00
Parker Hawke
b900513035
#671: Implement PersistentDataContainer#getKeys() 2020-06-26 10:49:28 +10:00
md_5
ce66f6937b Misc checkstyle fixes 2020-04-14 12:34:43 +10:00
md_5
de42aa13f3 Update to Minecraft 1.15 2019-12-11 09:00:00 +11:00
Bjarne Koll
42f88f72b5 Replace ItemTag API with new API that also expands to Tiles and Entities 2019-04-25 14:42:39 +10:00