Updated to protocol version 73 (1.6.1)

This commit is contained in:
Matt Bell 2013-07-03 01:00:05 -07:00 committed by Xabier de Zuazo
parent b334a6781d
commit e46a98a5a5

View file

@ -45,7 +45,7 @@ var packets = {
{ name: "leftClick", type: "bool" }
],
0x08: [
{ name: "health", type: "short" },
{ name: "health", type: "float" },
{ name: "food", type: "short" },
{ name: "foodSaturation", type: "float" }
],
@ -180,6 +180,12 @@ var packets = {
{ name: "z", type: "int" },
{ name: "count", type: "short" }
],
0x1b: [
{ name: "sideways", type: "float" },
{ name: "forward", type: "float" },
{ name: "jump", type: "bool" },
{ name: "unmount", type: "bool" }
],
0x1c: [
{ name: "entityId", type: "int" },
{ name: "velocityX", type: "short" },
@ -229,7 +235,8 @@ var packets = {
],
0x27: [
{ name: "entityId", type: "int" },
{ name: "vehicleId", type: "int" }
{ name: "vehicleId", type: "int" },
{ name: "leash", type: "bool" }
],
0x28: [
{ name: "entityId", type: "int" },
@ -250,6 +257,10 @@ var packets = {
{ name: "level", type: "short" },
{ name: "totalExperience", type: "short" }
],
0x2c: [
{ name: "entityId", type: "int" },
{ name: "properties", type: "propertyArray" }
],
0x33: [
{ name: "x", type: "int" },
{ name: "z", type: "int" },
@ -405,7 +416,7 @@ var packets = {
],
0xc8: [
{ name: "statisticId", type: "int" },
{ name: "amount", type: "byte" }
{ name: "amount", type: "int" }
],
0xc9: [
{ name: "playerName", type: "string" },
@ -414,8 +425,8 @@ var packets = {
],
0xca: [
{ name: "flags", type: "byte" },
{ name: "flyingSpeed", type: "byte" },
{ name: "walkingSpeed", type: "byte" }
{ name: "flyingSpeed", type: "float" },
{ name: "walkingSpeed", type: "float" }
],
0xcb: [
{ name: "text", type: "string" }
@ -499,6 +510,7 @@ var types = {
'byteVector': [readByteVector, writeByteVector, 3],
'byteVectorArray': [readByteVectorArray, writeByteVectorArray, sizeOfByteVectorArray],
'stringArray': [readStringArray, writeStringArray, sizeOfStringArray],
'propertyArray': [readPropertyArray, writePropertyArray, sizeOfPropertyArray]
};
var debug;
@ -691,6 +703,24 @@ function writeStringArray(value, buffer, offset) {
return offset;
}
function sizeOfPropertyArray(value) {
var size = 4;
for (var i = 0; i < value.length; ++i) {
size += sizeOfString(value[i].key) + types['double'][2];
}
return size;
}
function writePropertyArray(value, buffer, offset) {
buffer.writeInt32BE(value.length, offset);
offset += 4;
for (var i = 0; i < value.length; ++i) {
offset = writeString(value[i].key, buffer, offset);
offset = writeDouble(value[i].value, buffer, offset);
}
return offset;
}
function readIntArray8(buffer, offset) {
var results = readByte(buffer, offset);
if (! results) return null;
@ -994,6 +1024,35 @@ function readStringArray (buffer, offset) {
};
}
function readPropertyArray (buffer, offset) {
var results = readInt(buffer, offset);
if (! results) return null;
var count = results.value;
var cursor = offset + results.size;
var propertyArray = [];
for (var i = 0; i < count; ++i) {
var property = {};
results = readString(buffer, cursor);
if (! results) return null;
property.key = results.value;
cursor += results.size;
results = readDouble(buffer, cursor);
if (! results) return null;
property.value = results.value;
cursor += results.size;
propertyArray.push(property);
}
return {
value: propertyArray,
size: cursor - offset,
};
}
function readShort(buffer, offset) {
if (offset + 2 > buffer.length) return null;
var value = buffer.readInt16BE(offset);
@ -1290,8 +1349,8 @@ function parsePacket(buffer, isServer) {
}
module.exports = {
version: 61,
minecraftVersion: '1.5.2',
version: 73,
minecraftVersion: '1.6.1',
sessionVersion: 13,
parsePacket: parsePacket,
createPacketBuffer: createPacketBuffer,