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.
This commit is contained in:
deathcap 2016-02-16 00:51:18 -08:00
parent d8b95d7755
commit 96c3ef3e34

View File

@ -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);