mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
recognize Set Window Items packet
This commit is contained in:
parent
33bf57b6c2
commit
d501a5a7eb
2 changed files with 31 additions and 0 deletions
|
@ -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);
|
||||
|
|
10
packets.json
10
packets.json
|
@ -133,6 +133,16 @@
|
|||
"type": "short"
|
||||
}
|
||||
],
|
||||
"104": [
|
||||
{
|
||||
"name": "windowId",
|
||||
"type": "byte"
|
||||
},
|
||||
{
|
||||
"name": "slots",
|
||||
"type": "slotArray"
|
||||
}
|
||||
],
|
||||
"201": [
|
||||
{
|
||||
"name": "playerName",
|
||||
|
|
Loading…
Reference in a new issue