From d501a5a7ebd1217ad21529dc9375a5603dd7a84d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 1 Jan 2013 05:10:24 -0500 Subject: [PATCH] recognize Set Window Items packet --- lib/parser.js | 21 +++++++++++++++++++++ packets.json | 10 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/parser.js b/lib/parser.js index b3c5580..f71ee46 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -77,6 +77,7 @@ var readers = { 'bool': readBool, 'double': readDouble, 'float': readFloat, + 'slotArray': readSlotArray, }; function readString (buffer, offset) { @@ -111,6 +112,26 @@ function readByteArray (buffer, offset) { }; } +function readSlotArray (buffer, offset) { + var results = readShort(buffer, offset); + if (! results) return null; + var count = results.value; + var cursor = offset + results.size; + + var slotArray = []; + for (var i = 0; i < count; ++i) { + results = readSlot(buffer, cursor); + if (! results) return null; + slotArray.push(results.value); + cursor += results.size; + } + + return { + value: slotArray, + size: cursor - offset, + }; +} + function readShort(buffer, offset) { if (offset + 2 > buffer.length) return null; var value = buffer.readInt16BE(offset); diff --git a/packets.json b/packets.json index f235e7d..c803ab7 100644 --- a/packets.json +++ b/packets.json @@ -133,6 +133,16 @@ "type": "short" } ], + "104": [ + { + "name": "windowId", + "type": "byte" + }, + { + "name": "slots", + "type": "slotArray" + } + ], "201": [ { "name": "playerName",