recognize Set Window Items packet

This commit is contained in:
Andrew Kelley 2013-01-01 05:10:24 -05:00
parent 33bf57b6c2
commit d501a5a7eb
2 changed files with 31 additions and 0 deletions

View file

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

View file

@ -133,6 +133,16 @@
"type": "short"
}
],
"104": [
{
"name": "windowId",
"type": "byte"
},
{
"name": "slots",
"type": "slotArray"
}
],
"201": [
{
"name": "playerName",