diff --git a/lib/parser.js b/lib/parser.js index d40338f..17c3ab5 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -62,6 +62,7 @@ Parser.prototype.writePacket = function(packetId, params) { var writers = { 'int': IntWriter, 'byte': ByteWriter, + 'ubyte': UByteWriter, 'string': StringWriter, 'byteArray': ByteArrayWriter, }; @@ -72,6 +73,7 @@ var readers = { 'short': readShort, 'int': readInt, 'byte': readByte, + 'ubyte': readUByte, 'long': readLong, 'slot': readSlot, 'bool': readBool, @@ -333,6 +335,15 @@ function readByte(buffer, offset) { }; } +function readUByte(buffer, offset) { + if (offset + 1 > buffer.length) return null; + var value = buffer.readUInt8(offset); + return { + value: value, + size: 1, + }; +} + function readBool(buffer, offset) { if (offset + 1 > buffer.length) return null; var value = buffer.readInt8(offset); diff --git a/packets.json b/packets.json index 63e65e4..dc87f71 100644 --- a/packets.json +++ b/packets.json @@ -97,6 +97,98 @@ "type": "int" } ], + "7": [ + { + "name": "user", + "type": "int" + }, + { + "name": "target", + "type": "int" + }, + { + "name": "mouseButton", + "type": "bool" + } + ], + "8": [ + { + "name": "health", + "type": "short" + }, + { + "name": "food", + "type": "short" + }, + { + "name": "foodSaturation", + "type": "float" + } + ], + "9": [ + { + "name": "dimension", + "type": "int" + }, + { + "name": "difficulty", + "type": "byte" + }, + { + "name": "gameMode", + "type": "byte" + }, + { + "name": "worldHeight", + "type": "short" + }, + { + "name": "levelType", + "type": "string" + } + ], + "10": [ + { + "name": "onGround", + "type": "bool" + } + ], + "11": [ + { + "name": "x", + "type": "double" + }, + { + "name": "y", + "type": "double" + }, + { + "name": "stance", + "type": "double" + }, + { + "name": "z", + "type": "double" + }, + { + "name": "onGround", + "type": "bool" + } + ], + "12": [ + { + "name": "yaw", + "type": "float" + }, + { + "name": "pitch", + "type": "float" + }, + { + "name": "onGround", + "type": "bool" + } + ], "13": [ { "name": "x", @@ -127,12 +219,110 @@ "type": "bool" } ], + "14": [ + { + "name": "status", + "type": "byte" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "byte" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "face", + "type": "byte" + } + ], + "15": [ + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "ubyte" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "direction", + "type": "byte" + }, + { + "name": "heldItem", + "type": "slot" + }, + { + "name": "cursorX", + "type": "byte" + }, + { + "name": "cursorY", + "type": "byte" + }, + { + "name": "cursorZ", + "type": "byte" + } + ], "16": [ { "name": "slotId", "type": "short" } ], + "17": [ + { + "name": "entityId", + "type": "int" + }, + { + "name": "_unknown", + "type": "byte" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "byte" + }, + { + "name": "z", + "type": "int" + } + ], + "18": [ + { + "name": "entityId", + "type": "int" + }, + { + "name": "animation", + "type": "byte" + } + ], + "19": [ + { + "name": "entityId", + "type": "int" + }, + { + "name": "actionId", + "type": "byte" + } + ], "20": [ { "name": "entityId", @@ -171,6 +361,16 @@ "type": "entityMetadata" } ], + "22": [ + { + "name": "collectedEntityId", + "type": "int" + }, + { + "name": "collectorEntityId", + "type": "int" + } + ], "23": [ { "name": "entityId",