Complete all serverbound packets at PLAY state
This commit is contained in:
153 files changed
+3636
-131
No files matched your search
@@ -79,10 +79,7 @@ public fun NBTInput.readRootCompound(): NBTCompound {
|
||||
public fun NBTInput.readNetworkCompound(): NBTCompound {
|
||||
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())))
|
||||
)
|
||||
|
||||
NBTType.String -> NBTCompound("", NBTTag.CompoundTag(linkedMapOf("text" to NBTTag.StringTag(readStringTag()))))
|
||||
else -> throw UnsupportedOperationException("Unsupported network nbt tag 0x${type.id.toString(16).uppercase()}")
|
||||
}
|
||||
}
|
||||
@@ -62,3 +62,10 @@ public fun NBTOutput.writeRootNBTCompound(name: String = ""): ByteArray {
|
||||
writeTagPayload(root)
|
||||
return toByteArray()
|
||||
}
|
||||
|
||||
public fun NBTOutput.writeNetworkCompound(compound: NBTCompound) {
|
||||
val compoundTag = compound.element as? NBTTag.CompoundTag
|
||||
?: throw IllegalArgumentException("NBTCompound element must be an NBTTag.CompoundTag")
|
||||
writeByte(NBTType.Compound.id)
|
||||
writeTagPayload(compoundTag)
|
||||
}
|
||||
Reference in New Issue
Block a user