How to use the prismarine-nbt.proto function in prismarine-nbt

To help you get started, we’ve selected a few prismarine-nbt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PrismarineJS / node-minecraft-protocol / src / datatypes / minecraft.js View on Github external
function writeCompressedNbt (value, buffer, offset) {
  if (value === undefined) {
    buffer.writeInt16BE(-1, offset)
    return offset + 2
  }
  const nbtBuffer = Buffer.alloc(sizeOfNbt(value))
  nbt.proto.write(value, nbtBuffer, 0, 'nbt')

  const compressedNbt = zlib.gzipSync(nbtBuffer) // TODO: async
  compressedNbt.writeUInt8(0, 9) // clear the OS field to match MC

  buffer.writeInt16BE(compressedNbt.length, offset)
  compressedNbt.copy(buffer, offset + 2)
  return offset + 2 + compressedNbt.length
}
github PrismarineJS / node-minecraft-protocol / src / datatypes / minecraft.js View on Github external
function sizeOfNbt (value) {
  return nbt.proto.sizeOf(value, 'nbt')
}

prismarine-nbt

A parser and serializer for NBT archives

MIT
Latest version published 9 days ago

Package Health Score

81 / 100
Full package analysis