Class NBTHandler
java.lang.Object
me.pauleff.common.handlers.NBTHandler
Provides utilities for reading, writing, and inspecting Minecraft NBT files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyPlayerDataNBT(Path nbtSource, Path nbtDest) Writes playerdata fromnbtSourcetonbtDest, preserving selected tags from the destination when it already exists.static booleanDetermines whether a file can be parsed as a valid NBT document.
-
Method Details
-
isNBTFile
Determines whether a file can be parsed as a valid NBT document.Attempts to read the file via
NBTUtil.read(File), which detects GZIP and NBT headers. Parse failures (including invalid gzip or tag IDs) are treated as non-NBT.- Parameters:
file- the file to inspect- Returns:
trueif the file parses as NBT;falseotherwise
-
copyPlayerDataNBT
Writes playerdata fromnbtSourcetonbtDest, preserving selected tags from the destination when it already exists.Loads the source compound, then for each path in the default keep-list copies the corresponding tag from the destination into the source before writing. Nested paths use dot notation (e.g.
abilities.flying). The destination is written with GZIP compression as handled by the Querz NBT library.- Parameters:
nbtSource- the path to the source NBT playerdata filenbtDest- the path to write the merged playerdata to- Throws:
IOException- if reading or writing either NBT file fails
-