mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
Add state to the returned packet. Fix a couple broken packets. Fix UUID
This commit is contained in:
parent
ab24877359
commit
04ebd393d6
@ -483,14 +483,14 @@ var packets = {
|
|||||||
}},
|
}},
|
||||||
{ name: "propertiesLength", type: "count", condition: function(field_values) {
|
{ name: "propertiesLength", type: "count", condition: function(field_values) {
|
||||||
return field_values["action"] === 0;
|
return field_values["action"] === 0;
|
||||||
}, typeArgs: { countFor: "properties", type: "varint" }},
|
}, typeArgs: { countFor: "this.properties", type: "varint" }},
|
||||||
{ name: "properties", type: "array", condition: function(field_values) {
|
{ name: "properties", type: "array", condition: function(field_values) {
|
||||||
return field_values["action"] === 0;
|
return field_values["action"] === 0;
|
||||||
}, typeArgs: { count: "propertiesLength", type: "container", typeArgs: { fields: [
|
}, typeArgs: { count: "this.propertiesLength", type: "container", typeArgs: { fields: [
|
||||||
{ name: "name", type: "string" },
|
{ name: "name", type: "string" },
|
||||||
{ name: "value", type: "string" },
|
{ name: "value", type: "ustring" },
|
||||||
{ name: "isSigned", type: "bool" },
|
{ name: "isSigned", type: "bool" },
|
||||||
{ name: "signature", type: "string", condition: function(field_values) {
|
{ name: "signature", type: "ustring", condition: function(field_values) {
|
||||||
return field_values["isSigned"];
|
return field_values["isSigned"];
|
||||||
}}
|
}}
|
||||||
]}}},
|
]}}},
|
||||||
@ -904,10 +904,10 @@ function writeEntityMetadata(value, buffer, offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function writeUUID(value, buffer, offset) {
|
function writeUUID(value, buffer, offset) {
|
||||||
buffer.writeInt32BE(value[0], offset);
|
buffer.writeUInt32BE(value[0], offset);
|
||||||
buffer.writeInt32BE(value[1], offset + 4);
|
buffer.writeUInt32BE(value[1], offset + 4);
|
||||||
buffer.writeInt32BE(value[2], offset + 8);
|
buffer.writeUInt32BE(value[2], offset + 8);
|
||||||
buffer.writeInt32BE(value[3], offset + 12);
|
buffer.writeUInt32BE(value[3], offset + 12);
|
||||||
return offset + 16;
|
return offset + 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -966,10 +966,10 @@ function readString (buffer, offset) {
|
|||||||
function readUUID(buffer, offset) {
|
function readUUID(buffer, offset) {
|
||||||
return {
|
return {
|
||||||
value: [
|
value: [
|
||||||
buffer.readInt32BE(offset),
|
buffer.readUInt32BE(offset),
|
||||||
buffer.readInt32BE(offset + 4),
|
buffer.readUInt32BE(offset + 4),
|
||||||
buffer.readInt32BE(offset + 8),
|
buffer.readUInt32BE(offset + 8),
|
||||||
buffer.readInt32BE(offset + 12),
|
buffer.readUInt32BE(offset + 12),
|
||||||
],
|
],
|
||||||
size: 16,
|
size: 16,
|
||||||
};
|
};
|
||||||
@ -1466,7 +1466,7 @@ function parsePacketData(buffer, state, isServer, packetsToParse) {
|
|||||||
var packetId = packetIdField.value;
|
var packetId = packetIdField.value;
|
||||||
cursor += packetIdField.size;
|
cursor += packetIdField.size;
|
||||||
|
|
||||||
var results = { id: packetId };
|
var results = { id: packetId, state: state };
|
||||||
// Only parse the packet if there is a need for it, AKA if there is a listener attached to it
|
// Only parse the packet if there is a need for it, AKA if there is a listener attached to it
|
||||||
var name = packetNames[state][isServer ? "toServer" : "toClient"][packetId];
|
var name = packetNames[state][isServer ? "toServer" : "toClient"][packetId];
|
||||||
var shouldParse = (!packetsToParse.hasOwnProperty(name) || packetsToParse[name] <= 0)
|
var shouldParse = (!packetsToParse.hasOwnProperty(name) || packetsToParse[name] <= 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user