Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const nbt = require('prismarine-nbt')
const UUID = require('uuid-1345')
const zlib = require('zlib')
module.exports = {
UUID: [readUUID, writeUUID, 16],
nbt: [readNbt, writeNbt, sizeOfNbt],
optionalNbt: [readOptionalNbt, writeOptionalNbt, sizeOfOptionalNbt],
compressedNbt: [readCompressedNbt, writeCompressedNbt, sizeOfCompressedNbt],
restBuffer: [readRestBuffer, writeRestBuffer, sizeOfRestBuffer],
entityMetadataLoop: [readEntityMetadata, writeEntityMetadata, sizeOfEntityMetadata]
}
var PartialReadError = require('protodef').utils.PartialReadError
function readUUID (buffer, offset) {
if (offset + 16 > buffer.length) { throw new PartialReadError() }
return {
value: UUID.stringify(buffer.slice(offset, 16 + offset)),
size: 16
}
}
function writeUUID (value, buffer, offset) {
const buf = UUID.parse(value)
buf.copy(buffer, offset)
return offset + 16
}
function readNbt (buffer, offset) {