mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 22:23:21 -04:00
recognize Set Window Items packet
This commit is contained in:
parent
33bf57b6c2
commit
d501a5a7eb
@ -77,6 +77,7 @@ var readers = {
|
|||||||
'bool': readBool,
|
'bool': readBool,
|
||||||
'double': readDouble,
|
'double': readDouble,
|
||||||
'float': readFloat,
|
'float': readFloat,
|
||||||
|
'slotArray': readSlotArray,
|
||||||
};
|
};
|
||||||
|
|
||||||
function readString (buffer, offset) {
|
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) {
|
function readShort(buffer, offset) {
|
||||||
if (offset + 2 > buffer.length) return null;
|
if (offset + 2 > buffer.length) return null;
|
||||||
var value = buffer.readInt16BE(offset);
|
var value = buffer.readInt16BE(offset);
|
||||||
|
10
packets.json
10
packets.json
@ -133,6 +133,16 @@
|
|||||||
"type": "short"
|
"type": "short"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"104": [
|
||||||
|
{
|
||||||
|
"name": "windowId",
|
||||||
|
"type": "byte"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "slots",
|
||||||
|
"type": "slotArray"
|
||||||
|
}
|
||||||
|
],
|
||||||
"201": [
|
"201": [
|
||||||
{
|
{
|
||||||
"name": "playerName",
|
"name": "playerName",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user