mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 05:35:56 -04:00
parser recognizes map chunk bulk
This commit is contained in:
parent
d501a5a7eb
commit
c51cb26769
@ -78,8 +78,55 @@ var readers = {
|
||||
'double': readDouble,
|
||||
'float': readFloat,
|
||||
'slotArray': readSlotArray,
|
||||
'mapChunkBulk': readMapChunkBulk,
|
||||
};
|
||||
|
||||
function readMapChunkBulk (buffer, offset) {
|
||||
var cursor = offset + 6;
|
||||
if (cursor > buffer.length) return null;
|
||||
var chunkCount = buffer.readInt16BE(buffer, offset);
|
||||
var dataSize = buffer.readInt32BE(buffer, offset + 2);
|
||||
|
||||
var endCursor = cursor + 1 + dataSize + 12 * chunkCount;
|
||||
if (endCursor > buffer.length) return null;
|
||||
|
||||
var skyLightSent = !!buffer.readInt8(buffer, cursor);
|
||||
cursor += 1;
|
||||
|
||||
var compressedChunkDataEnd = cursor + dataSize;
|
||||
var compressedChunkData = buffer.slice(cursor, compressedChunkDataEnd);
|
||||
cursor = compressedChunkDataEnd;
|
||||
|
||||
var meta = [];
|
||||
var i, chunkX, chunkZ, primaryBitMap, addBitMap;
|
||||
for (i = 0; i < chunkCount; ++i) {
|
||||
chunkX = buffer.readInt32BE(buffer, cursor);
|
||||
cursor += 4;
|
||||
chunkZ = buffer.readInt32BE(buffer, cursor);
|
||||
cursor += 4;
|
||||
primaryBitMap = buffer.readUInt16BE(buffer, cursor);
|
||||
cursor += 2;
|
||||
addBitMap = buffer.readUInt16BE(buffer, cursor);
|
||||
cursor += 2;
|
||||
|
||||
meta.push({
|
||||
chunkX: chunkX,
|
||||
chunkZ: chunkZ,
|
||||
primaryBitMap: primaryBitMap,
|
||||
addBitMap: addBitMap,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
value: {
|
||||
skyLightSent: skyLightSent,
|
||||
compressedChunkData: compressedChunkData,
|
||||
meta: meta,
|
||||
},
|
||||
size: endCursor - offset,
|
||||
};
|
||||
}
|
||||
|
||||
function readString (buffer, offset) {
|
||||
var results = readShort(buffer, offset);
|
||||
if (! results) return null;
|
||||
|
20
packets.json
20
packets.json
@ -133,6 +133,26 @@
|
||||
"type": "short"
|
||||
}
|
||||
],
|
||||
"56": [
|
||||
{
|
||||
"name": "dummy",
|
||||
"type": "mapChunkBulk"
|
||||
}
|
||||
],
|
||||
"103": [
|
||||
{
|
||||
"name": "windowId",
|
||||
"type": "byte"
|
||||
},
|
||||
{
|
||||
"name": "slotId",
|
||||
"type": "short"
|
||||
},
|
||||
{
|
||||
"name": "slot",
|
||||
"type": "slot"
|
||||
}
|
||||
],
|
||||
"104": [
|
||||
{
|
||||
"name": "windowId",
|
||||
|
Loading…
x
Reference in New Issue
Block a user