Fix network nbt reader

This commit is contained in:
2026-09-05 17:26:15 +08:00
parent 5e6e0ca5b9
commit a2eebe3d4e
8 files changed
+27 -13

No files matched your search

@@ -77,6 +77,12 @@ public fun NBTInput.readRootCompound(): NBTCompound {
}
public fun NBTInput.readNetworkCompound(): NBTCompound {
val root = readCompound()
return NBTCompound("", root)
return when (val type = NBTType.fromId(readByte().toInt() and 0xFF)) {
NBTType.Compound -> NBTCompound("", readCompoundTag())
NBTType.String -> NBTCompound(
"", NBTTag.CompoundTag(linkedMapOf("text" to NBTTag.StringTag(readStringTag())))
)
else -> throw UnsupportedOperationException("Unsupported network nbt tag 0x${type.id.toString(16).uppercase()}")
}
}