From 96c3ef3e341be50cc9bf4fba2b6aac02cd22566b Mon Sep 17 00:00:00 2001 From: deathcap Date: Tue, 16 Feb 2016 00:51:18 -0800 Subject: [PATCH] compressedNbt: clear OS field in gzip header to match MC http://tools.ietf.org/html/rfc1952 defines the gzip header, which has an "OS (Operating System)" byte; node.js zlib https://nodejs.org/api/zlib.html sets OS to 0x03 (Unix) but Minecraft leaves it cleared to 0x00. To match Minecraft behavior byte-for-byte (important for examples/proxy/proxy.js), make sure this byte is cleared when writing compressedNbt. --- src/datatypes/minecraft.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/datatypes/minecraft.js b/src/datatypes/minecraft.js index 569e5d2..ed1439a 100644 --- a/src/datatypes/minecraft.js +++ b/src/datatypes/minecraft.js @@ -77,6 +77,7 @@ function writeCompressedNbt(value, buffer, offset) { 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);