hexa to hexa string from json convertion

This commit is contained in:
Romain Beaumont 2015-05-08 03:37:42 +02:00
parent ea2e97d59f
commit b350229160
2 changed files with 112 additions and 112 deletions

View File

@ -31,7 +31,7 @@ var packetStates = {toClient: {}, toServer: {}};
['toClient', 'toServer'].forEach(function(direction) { ['toClient', 'toServer'].forEach(function(direction) {
for (var name in packets[state][direction]) { for (var name in packets[state][direction]) {
var info = packets[state][direction][name]; var info = packets[state][direction][name];
var id = info.id; var id = parseInt(info.id);
var fields = info.fields; var fields = info.fields;
assert(id !== undefined, 'missing id for packet '+name); assert(id !== undefined, 'missing id for packet '+name);

View File

@ -2,7 +2,7 @@ module.exports= {
handshaking: { handshaking: {
toClient: {}, toClient: {},
toServer: { toServer: {
set_protocol: {id: 0x00, fields: [ set_protocol: {id: "0x00", fields: [
{ name: "protocolVersion", type: "varint" }, { name: "protocolVersion", type: "varint" },
{ name: "serverHost", type: "string" }, { name: "serverHost", type: "string" },
{ name: "serverPort", type: "ushort" }, { name: "serverPort", type: "ushort" },
@ -12,16 +12,16 @@ module.exports= {
}, },
status: { status: {
toClient: { toClient: {
server_info: {id: 0x00, fields: [ server_info: {id: "0x00", fields: [
{ name: "response", type: "ustring" } { name: "response", type: "ustring" }
]}, ]},
ping: {id: 0x01, fields: [ ping: {id: "0x01", fields: [
{ name: "time", type: "long" } { name: "time", type: "long" }
]} ]}
}, },
toServer: { toServer: {
ping_start: {id: 0x00, fields: []}, ping_start: {id: "0x00", fields: []},
ping: {id: 0x01, fields: [ ping: {id: "0x01", fields: [
{ name: "time", type: "long" } { name: "time", type: "long" }
]} ]}
} }
@ -29,29 +29,29 @@ module.exports= {
login: { login: {
toClient: { toClient: {
disconnect: {id: 0x00, fields: [ disconnect: {id: "0x00", fields: [
{ name: "reason", type: "string" } { name: "reason", type: "string" }
]}, ]},
encryption_begin: {id: 0x01, fields: [ encryption_begin: {id: "0x01", fields: [
{ name: "serverId", type: "string" }, { name: "serverId", type: "string" },
{ name: "publicKeyLength", type: "count", typeArgs: { type: "varint", countFor: "publicKey" } }, { name: "publicKeyLength", type: "count", typeArgs: { type: "varint", countFor: "publicKey" } },
{ name: "publicKey", type: "buffer", typeArgs: { count: "publicKeyLength" } }, { name: "publicKey", type: "buffer", typeArgs: { count: "publicKeyLength" } },
{ name: "verifyTokenLength", type: "count", typeArgs: { type: "varint", countFor: "verifyToken" } }, { name: "verifyTokenLength", type: "count", typeArgs: { type: "varint", countFor: "verifyToken" } },
{ name: "verifyToken", type: "buffer", typeArgs: { count: "verifyTokenLength" } }, { name: "verifyToken", type: "buffer", typeArgs: { count: "verifyTokenLength" } },
]}, ]},
success: {id: 0x02, fields: [ success: {id: "0x02", fields: [
{ name: "uuid", type: "string" }, { name: "uuid", type: "string" },
{ name: "username", type: "string" } { name: "username", type: "string" }
]}, ]},
compress: { id: 0x03, fields: [ compress: { id: "0x03", fields: [
{ name: "threshold", type: "varint"} { name: "threshold", type: "varint"}
]} ]}
}, },
toServer: { toServer: {
login_start: {id: 0x00, fields: [ login_start: {id: "0x00", fields: [
{ name: "username", type: "string" } { name: "username", type: "string" }
]}, ]},
encryption_begin: {id: 0x01, fields: [ encryption_begin: {id: "0x01", fields: [
{ name: "sharedSecretLength", type: "count", typeArgs: { type: "varint", countFor: "sharedSecret" } }, { name: "sharedSecretLength", type: "count", typeArgs: { type: "varint", countFor: "sharedSecret" } },
{ name: "sharedSecret", type: "buffer", typeArgs: { count: "sharedSecretLength" } }, { name: "sharedSecret", type: "buffer", typeArgs: { count: "sharedSecretLength" } },
{ name: "verifyTokenLength", type: "count", typeArgs: { type: "varint", countFor: "verifyToken" } }, { name: "verifyTokenLength", type: "count", typeArgs: { type: "varint", countFor: "verifyToken" } },
@ -62,10 +62,10 @@ module.exports= {
play: { play: {
toClient: { toClient: {
keep_alive: {id: 0x00, fields: [ keep_alive: {id: "0x00", fields: [
{ name: "keepAliveId", type: "varint" }, { name: "keepAliveId", type: "varint" },
]}, ]},
login: {id: 0x01, fields: [ login: {id: "0x01", fields: [
{ name: "entityId", type: "int" }, { name: "entityId", type: "int" },
{ name: "gameMode", type: "ubyte" }, { name: "gameMode", type: "ubyte" },
{ name: "dimension", type: "byte" }, { name: "dimension", type: "byte" },
@ -74,34 +74,34 @@ module.exports= {
{ name: "levelType", type: "string" }, { name: "levelType", type: "string" },
{ name: "reducedDebugInfo", type: "bool"} { name: "reducedDebugInfo", type: "bool"}
]}, ]},
chat: {id: 0x02, fields: [ chat: {id: "0x02", fields: [
{ name: "message", type: "ustring" }, { name: "message", type: "ustring" },
{ name: "position", type: "byte" } { name: "position", type: "byte" }
]}, ]},
update_time: {id: 0x03, fields: [ update_time: {id: "0x03", fields: [
{ name: "age", type: "long" }, { name: "age", type: "long" },
{ name: "time", type: "long" }, { name: "time", type: "long" },
]}, ]},
entity_equipment: {id: 0x04, fields: [ entity_equipment: {id: "0x04", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "slot", type: "short" }, { name: "slot", type: "short" },
{ name: "item", type: "slot" } { name: "item", type: "slot" }
]}, ]},
spawn_position: {id: 0x05, fields: [ spawn_position: {id: "0x05", fields: [
{ name: "location", type: "position" } { name: "location", type: "position" }
]}, ]},
update_health: {id: 0x06, fields: [ update_health: {id: "0x06", fields: [
{ name: "health", type: "float" }, { name: "health", type: "float" },
{ name: "food", type: "varint" }, { name: "food", type: "varint" },
{ name: "foodSaturation", type: "float" } { name: "foodSaturation", type: "float" }
]}, ]},
respawn: {id: 0x07, fields: [ respawn: {id: "0x07", fields: [
{ name: "dimension", type: "int" }, { name: "dimension", type: "int" },
{ name: "difficulty", type: "ubyte" }, { name: "difficulty", type: "ubyte" },
{ name: "gamemode", type: "ubyte" }, { name: "gamemode", type: "ubyte" },
{ name: "levelType", type: "string" } { name: "levelType", type: "string" }
]}, ]},
position: {id: 0x08, fields: [ position: {id: "0x08", fields: [
{ name: "x", type: "double" }, { name: "x", type: "double" },
{ name: "y", type: "double" }, { name: "y", type: "double" },
{ name: "z", type: "double" }, { name: "z", type: "double" },
@ -109,18 +109,18 @@ module.exports= {
{ name: "pitch", type: "float" }, { name: "pitch", type: "float" },
{ name: "flags", type: "byte"} { name: "flags", type: "byte"}
]}, ]},
held_item_slot: {id: 0x09, fields: [ held_item_slot: {id: "0x09", fields: [
{ name: "slot", type: "byte" } { name: "slot", type: "byte" }
]}, ]},
bed: {id: 0x0a, fields: [ bed: {id: "0x0a", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "location", type: "position" } { name: "location", type: "position" }
]}, ]},
animation: {id: 0x0b, fields: [ animation: {id: "0x0b", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "animation", type: "ubyte" } { name: "animation", type: "ubyte" }
]}, ]},
named_entity_spawn: {id: 0x0c, fields: [ named_entity_spawn: {id: "0x0c", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "playerUUID", type: "UUID"}, { name: "playerUUID", type: "UUID"},
{ name: "x", type: "int" }, { name: "x", type: "int" },
@ -131,11 +131,11 @@ module.exports= {
{ name: "currentItem", type: "short" }, { name: "currentItem", type: "short" },
{ name: "metadata", type: "entityMetadata" } { name: "metadata", type: "entityMetadata" }
]}, ]},
collect: {id: 0x0d, fields: [ collect: {id: "0x0d", fields: [
{ name: "collectedEntityId", type: "varint" }, { name: "collectedEntityId", type: "varint" },
{ name: "collectorEntityId", type: "varint" } { name: "collectorEntityId", type: "varint" }
]}, ]},
spawn_entity: {id: 0x0e, fields: [ spawn_entity: {id: "0x0e", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "type", type: "byte" }, { name: "type", type: "byte" },
{ name: "x", type: "int" }, { name: "x", type: "int" },
@ -150,7 +150,7 @@ module.exports= {
{ name: "velocityZ", type: "short", condition: {"field":"intField","values":[0],"different":true,"this":true}} { name: "velocityZ", type: "short", condition: {"field":"intField","values":[0],"different":true,"this":true}}
]}} ]}}
]}, ]},
spawn_entity_living: {id: 0x0f, fields: [ spawn_entity_living: {id: "0x0f", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "type", type: "ubyte" }, { name: "type", type: "ubyte" },
{ name: "x", type: "int" }, { name: "x", type: "int" },
@ -164,46 +164,46 @@ module.exports= {
{ name: "velocityZ", type: "short" }, { name: "velocityZ", type: "short" },
{ name: "metadata", type: "entityMetadata" }, { name: "metadata", type: "entityMetadata" },
]}, ]},
spawn_entity_painting: {id: 0x10, fields: [ spawn_entity_painting: {id: "0x10", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "title", type: "string" }, { name: "title", type: "string" },
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "direction", type: "ubyte" } { name: "direction", type: "ubyte" }
]}, ]},
spawn_entity_experience_orb: {id: 0x11, fields: [ spawn_entity_experience_orb: {id: "0x11", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "x", type: "int" }, { name: "x", type: "int" },
{ name: "y", type: "int" }, { name: "y", type: "int" },
{ name: "z", type: "int" }, { name: "z", type: "int" },
{ name: "count", type: "short" } { name: "count", type: "short" }
]}, ]},
entity_velocity: {id: 0x12, fields: [ entity_velocity: {id: "0x12", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "velocityX", type: "short" }, { name: "velocityX", type: "short" },
{ name: "velocityY", type: "short" }, { name: "velocityY", type: "short" },
{ name: "velocityZ", type: "short" } { name: "velocityZ", type: "short" }
]}, ]},
entity_destroy: {id: 0x13, fields: [ entity_destroy: {id: "0x13", fields: [
{ name: "count", type: "count", typeArgs: { type: "varint", countFor: "entityIds" } }, { name: "count", type: "count", typeArgs: { type: "varint", countFor: "entityIds" } },
{ name: "entityIds", type: "array", typeArgs: { type: "varint", count: "count" } } { name: "entityIds", type: "array", typeArgs: { type: "varint", count: "count" } }
]}, ]},
entity: {id: 0x14, fields: [ entity: {id: "0x14", fields: [
{ name: "entityId", type: "varint" } { name: "entityId", type: "varint" }
]}, ]},
rel_entity_move: {id: 0x15, fields: [ rel_entity_move: {id: "0x15", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "dX", type: "byte" }, { name: "dX", type: "byte" },
{ name: "dY", type: "byte" }, { name: "dY", type: "byte" },
{ name: "dZ", type: "byte" }, { name: "dZ", type: "byte" },
{ name: "onGround", type: "bool"} { name: "onGround", type: "bool"}
]}, ]},
entity_look: {id: 0x16, fields: [ entity_look: {id: "0x16", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "yaw", type: "byte" }, { name: "yaw", type: "byte" },
{ name: "pitch", type: "byte" }, { name: "pitch", type: "byte" },
{ name: "onGround", type: "bool"} { name: "onGround", type: "bool"}
]}, ]},
entity_move_look: {id: 0x17, fields: [ entity_move_look: {id: "0x17", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "dX", type: "byte" }, { name: "dX", type: "byte" },
{ name: "dY", type: "byte" }, { name: "dY", type: "byte" },
@ -212,7 +212,7 @@ module.exports= {
{ name: "pitch", type: "byte" }, { name: "pitch", type: "byte" },
{ name: "onGround", type: "bool"} { name: "onGround", type: "bool"}
]}, ]},
entity_teleport: {id: 0x18, fields: [ entity_teleport: {id: "0x18", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "x", type: "int" }, { name: "x", type: "int" },
{ name: "y", type: "int" }, { name: "y", type: "int" },
@ -221,40 +221,40 @@ module.exports= {
{ name: "pitch", type: "byte" }, { name: "pitch", type: "byte" },
{ name: "onGround", type: "bool"} { name: "onGround", type: "bool"}
]}, ]},
entity_head_rotation: {id: 0x19, fields: [ entity_head_rotation: {id: "0x19", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "headYaw", type: "byte" }, { name: "headYaw", type: "byte" },
]}, ]},
entity_status: {id: 0x1a, fields: [ entity_status: {id: "0x1a", fields: [
{ name: "entityId", type: "int" }, { name: "entityId", type: "int" },
{ name: "entityStatus", type: "byte" } { name: "entityStatus", type: "byte" }
]}, ]},
attach_entity: {id: 0x1b, fields: [ attach_entity: {id: "0x1b", fields: [
{ name: "entityId", type: "int" }, { name: "entityId", type: "int" },
{ name: "vehicleId", type: "int" }, { name: "vehicleId", type: "int" },
{ name: "leash", type: "bool" } { name: "leash", type: "bool" }
]}, ]},
entity_metadata: {id: 0x1c, fields: [ entity_metadata: {id: "0x1c", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "metadata", type: "entityMetadata" } { name: "metadata", type: "entityMetadata" }
]}, ]},
entity_effect: {id: 0x1d, fields: [ entity_effect: {id: "0x1d", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "effectId", type: "byte" }, { name: "effectId", type: "byte" },
{ name: "amplifier", type: "byte" }, { name: "amplifier", type: "byte" },
{ name: "duration", type: "varint" }, { name: "duration", type: "varint" },
{ name: "hideParticles", type: "bool" } { name: "hideParticles", type: "bool" }
]}, ]},
remove_entity_effect: {id: 0x1e, fields: [ remove_entity_effect: {id: "0x1e", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "effectId", type: "byte" } { name: "effectId", type: "byte" }
]}, ]},
experience: {id: 0x1f, fields: [ experience: {id: "0x1f", fields: [
{ name: "experienceBar", type: "float" }, { name: "experienceBar", type: "float" },
{ name: "level", type: "varint" }, { name: "level", type: "varint" },
{ name: "totalExperience", type: "varint" } { name: "totalExperience", type: "varint" }
]}, ]},
update_attributes: {id: 0x20, fields: [ update_attributes: {id: "0x20", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "count", type: "count", typeArgs: { type: "int", countFor: "properties" } }, { name: "count", type: "count", typeArgs: { type: "int", countFor: "properties" } },
{ name: "properties", type: "array", typeArgs: { count: "count", { name: "properties", type: "array", typeArgs: { count: "count",
@ -271,7 +271,7 @@ module.exports= {
]} ]}
}} }}
]}, ]},
map_chunk: {id: 0x21, fields: [ map_chunk: {id: "0x21", fields: [
{ name: "x", type: "int" }, { name: "x", type: "int" },
{ name: "z", type: "int" }, { name: "z", type: "int" },
{ name: "groundUp", type: "bool" }, { name: "groundUp", type: "bool" },
@ -279,7 +279,7 @@ module.exports= {
{ name: "chunkDataLength", type: "count", typeArgs: { type: "varint", countFor: "chunkData" } }, { name: "chunkDataLength", type: "count", typeArgs: { type: "varint", countFor: "chunkData" } },
{ name: "chunkData", type: "buffer", typeArgs: { count: "chunkDataLength" } }, { name: "chunkData", type: "buffer", typeArgs: { count: "chunkDataLength" } },
]}, ]},
multi_block_change: {id: 0x22, fields: [ multi_block_change: {id: "0x22", fields: [
{ name: "chunkX", type: "int" }, { name: "chunkX", type: "int" },
{ name: "chunkZ", type: "int" }, { name: "chunkZ", type: "int" },
{ name: "recordCount", type: "count", typeArgs: { type: "varint", countFor: "records" } }, { name: "recordCount", type: "count", typeArgs: { type: "varint", countFor: "records" } },
@ -289,22 +289,22 @@ module.exports= {
{ name: "blockId", type: "varint" } { name: "blockId", type: "varint" }
]}}} ]}}}
]}, ]},
block_change: {id: 0x23, fields: [ block_change: {id: "0x23", fields: [
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "type", type: "varint" }, { name: "type", type: "varint" },
]}, ]},
block_action: {id: 0x24, fields: [ block_action: {id: "0x24", fields: [
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "byte1", type: "ubyte" }, { name: "byte1", type: "ubyte" },
{ name: "byte2", type: "ubyte" }, { name: "byte2", type: "ubyte" },
{ name: "blockId", type: "varint" } { name: "blockId", type: "varint" }
]}, ]},
block_break_animation: {id: 0x25, fields: [ block_break_animation: {id: "0x25", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "destroyStage", type: "byte" } { name: "destroyStage", type: "byte" }
]}, ]},
map_chunk_bulk: {id: 0x26, fields: [ map_chunk_bulk: {id: "0x26", fields: [
{ name: "skyLightSent", type: "bool" }, { name: "skyLightSent", type: "bool" },
{ name: "chunkColumnCount", type: "count", typeArgs: { type: "varint", countFor: "meta" } }, { name: "chunkColumnCount", type: "count", typeArgs: { type: "varint", countFor: "meta" } },
{ name: "meta", type: "array", typeArgs: { count: "chunkColumnCount", type: "container", typeArgs: { fields: [ { name: "meta", type: "array", typeArgs: { count: "chunkColumnCount", type: "container", typeArgs: { fields: [
@ -314,7 +314,7 @@ module.exports= {
]}}}, ]}}},
{ name: "data", type: "restBuffer" } { name: "data", type: "restBuffer" }
]}, ]},
explosion: {id: 0x27, fields: [ explosion: {id: "0x27", fields: [
{ name: "x", type: "float" }, { name: "x", type: "float" },
{ name: "y", type: "float" }, { name: "y", type: "float" },
{ name: "z", type: "float" }, { name: "z", type: "float" },
@ -331,13 +331,13 @@ module.exports= {
{ name: "playerMotionY", type: "float" }, { name: "playerMotionY", type: "float" },
{ name: "playerMotionZ", type: "float" } { name: "playerMotionZ", type: "float" }
]}, ]},
world_event: {id: 0x28, fields: [ world_event: {id: "0x28", fields: [
{ name: "effectId", type: "int" }, { name: "effectId", type: "int" },
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "data", type: "int" }, { name: "data", type: "int" },
{ name: "global", type: "bool" } { name: "global", type: "bool" }
]}, ]},
named_sound_effect: {id: 0x29, fields: [ named_sound_effect: {id: "0x29", fields: [
{ name: "soundName", type: "string" }, { name: "soundName", type: "string" },
{ name: "x", type: "int" }, { name: "x", type: "int" },
{ name: "y", type: "int" }, { name: "y", type: "int" },
@ -345,7 +345,7 @@ module.exports= {
{ name: "volume", type: "float" }, { name: "volume", type: "float" },
{ name: "pitch", type: "ubyte" } { name: "pitch", type: "ubyte" }
]}, ]},
world_particles: {id: 0x2a, fields: [ world_particles: {id: "0x2a", fields: [
{ name: "particleId", type: "int" }, { name: "particleId", type: "int" },
{ name: "longDistance", type: "bool"}, { name: "longDistance", type: "bool"},
{ name: "x", type: "float" }, { name: "x", type: "float" },
@ -360,55 +360,55 @@ module.exports= {
typeArgs: { count: {"field":"particleId","map":{"36":2,"37":1,"38":1},"default":0}, typeArgs: { count: {"field":"particleId","map":{"36":2,"37":1,"38":1},"default":0},
type: "varint" } } type: "varint" } }
]}, ]},
game_state_change: {id: 0x2b, fields: [ game_state_change: {id: "0x2b", fields: [
{ name: "reason", type: "ubyte" }, { name: "reason", type: "ubyte" },
{ name: "gameMode", type: "float" } { name: "gameMode", type: "float" }
]}, ]},
spawn_entity_weather:{id: 0x2c, fields: [ spawn_entity_weather:{id: "0x2c", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "type", type: "byte" }, { name: "type", type: "byte" },
{ name: "x", type: "int" }, { name: "x", type: "int" },
{ name: "y", type: "int" }, { name: "y", type: "int" },
{ name: "z", type: "int" } { name: "z", type: "int" }
]}, ]},
open_window: {id: 0x2d, fields: [ open_window: {id: "0x2d", fields: [
{ name: "windowId", type: "ubyte" }, { name: "windowId", type: "ubyte" },
{ name: "inventoryType", type: "string" }, { name: "inventoryType", type: "string" },
{ name: "windowTitle", type: "string" }, { name: "windowTitle", type: "string" },
{ name: "slotCount", type: "ubyte" }, { name: "slotCount", type: "ubyte" },
{ name: "entityId", type: "int", condition: {"field":"inventoryType","values":[11]}} { name: "entityId", type: "int", condition: {"field":"inventoryType","values":[11]}}
]}, ]},
close_window: {id: 0x2e, fields: [ close_window: {id: "0x2e", fields: [
{ name: "windowId", type: "ubyte" } { name: "windowId", type: "ubyte" }
]}, ]},
set_slot: {id: 0x2f, fields: [ set_slot: {id: "0x2f", fields: [
{ name: "windowId", type: "byte" }, { name: "windowId", type: "byte" },
{ name: "slot", type: "short" }, { name: "slot", type: "short" },
{ name: "item", type: "slot" } { name: "item", type: "slot" }
]}, ]},
window_items: {id: 0x30, fields: [ window_items: {id: "0x30", fields: [
{ name: "windowId", type: "ubyte" }, { name: "windowId", type: "ubyte" },
{ name: "count", type: "count", typeArgs: { type: "short", countFor: "items" } }, { name: "count", type: "count", typeArgs: { type: "short", countFor: "items" } },
{ name: "items", type: "array", typeArgs: { type: "slot", count: "count" } } { name: "items", type: "array", typeArgs: { type: "slot", count: "count" } }
]}, ]},
craft_progress_bar: {id: 0x31, fields: [ craft_progress_bar: {id: "0x31", fields: [
{ name: "windowId", type: "ubyte" }, { name: "windowId", type: "ubyte" },
{ name: "property", type: "short" }, { name: "property", type: "short" },
{ name: "value", type: "short" } { name: "value", type: "short" }
]}, ]},
transaction:{id: 0x32, fields: [ transaction:{id: "0x32", fields: [
{ name: "windowId", type: "byte" }, { name: "windowId", type: "byte" },
{ name: "action", type: "short" }, { name: "action", type: "short" },
{ name: "accepted", type: "bool" } { name: "accepted", type: "bool" }
]}, ]},
update_sign: {id: 0x33, fields: [ update_sign: {id: "0x33", fields: [
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "text1", type: "string" }, { name: "text1", type: "string" },
{ name: "text2", type: "string" }, { name: "text2", type: "string" },
{ name: "text3", type: "string" }, { name: "text3", type: "string" },
{ name: "text4", type: "string" } { name: "text4", type: "string" }
]}, ]},
map: {id: 0x34, fields: [ map: {id: "0x34", fields: [
{ name: "itemDamage", type: "varint" }, { name: "itemDamage", type: "varint" },
{ name: "scale", type: "byte" }, { name: "scale", type: "byte" },
{ name: "iconLength", type: "count", typeArgs: { type: "varint", countFor: "icons" } }, { name: "iconLength", type: "count", typeArgs: { type: "varint", countFor: "icons" } },
@ -424,15 +424,15 @@ module.exports= {
{ name: "dataLength", type: "count", typeArgs: { countFor: "data", type: "varint" }, condition: {"field":"columns","values":[0],"different":true}}, { name: "dataLength", type: "count", typeArgs: { countFor: "data", type: "varint" }, condition: {"field":"columns","values":[0],"different":true}},
{ name: "data", type: "buffer", typeArgs: { count: "dataLength" }, condition: {"field":"columns","values":[0],"different":true}}, { name: "data", type: "buffer", typeArgs: { count: "dataLength" }, condition: {"field":"columns","values":[0],"different":true}},
]}, ]},
tile_entity_data:{id: 0x35, fields: [ tile_entity_data:{id: "0x35", fields: [
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "action", type: "ubyte" }, { name: "action", type: "ubyte" },
{ name: "nbtData", type: "restBuffer" } { name: "nbtData", type: "restBuffer" }
]}, ]},
open_sign_entity: {id: 0x36, fields: [ open_sign_entity: {id: "0x36", fields: [
{ name: "location", type: "position" }, { name: "location", type: "position" },
]}, ]},
statistics: {id: 0x37, fields: [ statistics: {id: "0x37", fields: [
{ name: "count", type: "count", typeArgs: { type: "varint", countFor: "entries" } }, { name: "count", type: "count", typeArgs: { type: "varint", countFor: "entries" } },
{ name: "entries", type: "array", typeArgs: { count: "count", { name: "entries", type: "array", typeArgs: { count: "count",
type: "container", typeArgs: { fields: [ type: "container", typeArgs: { fields: [
@ -441,7 +441,7 @@ module.exports= {
]} ]}
}} }}
]}, ]},
player_info: {id: 0x38, fields: [ player_info: {id: "0x38", fields: [
{ name: "action", type: "varint" }, { name: "action", type: "varint" },
{ name: "length", type: "count", typeArgs: { type: "varint", countFor: "data" }}, { name: "length", type: "count", typeArgs: { type: "varint", countFor: "data" }},
{ name: "data", type: "array", typeArgs: { count: "length", type: "container", typeArgs: { fields: [ { name: "data", type: "array", typeArgs: { count: "length", type: "container", typeArgs: { fields: [
@ -462,32 +462,32 @@ module.exports= {
{ name: "displayName", type: "string", condition: {"field":"hasDisplayName","values":[true]}} { name: "displayName", type: "string", condition: {"field":"hasDisplayName","values":[true]}}
]}}} ]}}}
]}, ]},
abilities: {id: 0x39, fields: [ abilities: {id: "0x39", fields: [
{ name: "flags", type: "byte" }, { name: "flags", type: "byte" },
{ name: "flyingSpeed", type: "float" }, { name: "flyingSpeed", type: "float" },
{ name: "walkingSpeed", type: "float" } { name: "walkingSpeed", type: "float" }
]}, ]},
tab_complete: {id: 0x3a, fields: [ tab_complete: {id: "0x3a", fields: [
{ name: "count", type: "count", typeArgs: { type: "varint", countFor: "matches" } }, { name: "count", type: "count", typeArgs: { type: "varint", countFor: "matches" } },
{ name: "matches", type: "array", typeArgs: { type: "string", count: "count" } } { name: "matches", type: "array", typeArgs: { type: "string", count: "count" } }
]}, ]},
scoreboard_objective: {id: 0x3b, fields: [ scoreboard_objective: {id: "0x3b", fields: [
{ name: "name", type: "string" }, { name: "name", type: "string" },
{ name: "action", type: "byte" }, { name: "action", type: "byte" },
{ name: "displayText", type: "string", condition: {"field":"action","values":[0,2]}}, { name: "displayText", type: "string", condition: {"field":"action","values":[0,2]}},
{ name: "type", type: "string", condition: {"field":"action","values":[0,2]}} { name: "type", type: "string", condition: {"field":"action","values":[0,2]}}
]}, ]},
scoreboard_score: {id: 0x3c, fields: [ scoreboard_score: {id: "0x3c", fields: [
{ name: "itemName", type: "string" }, { name: "itemName", type: "string" },
{ name: "action", type: "byte" }, { name: "action", type: "byte" },
{ name: "scoreName", type: "string" }, { name: "scoreName", type: "string" },
{ name: "value", type: "varint", condition: {"field":"action","values":[1],"different":true}} { name: "value", type: "varint", condition: {"field":"action","values":[1],"different":true}}
]}, ]},
scoreboard_display_objective: {id: 0x3d, fields: [ scoreboard_display_objective: {id: "0x3d", fields: [
{ name: "position", type: "byte" }, { name: "position", type: "byte" },
{ name: "name", type: "string" } { name: "name", type: "string" }
]}, ]},
scoreboard_team: {id: 0x3e, fields: [ scoreboard_team: {id: "0x3e", fields: [
{ name: "team", type: "string" }, { name: "team", type: "string" },
{ name: "mode", type: "byte" }, { name: "mode", type: "byte" },
{ name: "name", type: "string", condition: {"field":"mode","values":[0,2]}}, { name: "name", type: "string", condition: {"field":"mode","values":[0,2]}},
@ -499,27 +499,27 @@ module.exports= {
{ name: "playerCount", type: "count", condition: {"field":"mode","values":[0,3,4]}, typeArgs: { type: "short", countFor: "players" } }, { name: "playerCount", type: "count", condition: {"field":"mode","values":[0,3,4]}, typeArgs: { type: "short", countFor: "players" } },
{ name: "players", type: "array", condition: {"field":"mode","values":[0,3,4]}, typeArgs: { type: "string", count: "playerCount" } } { name: "players", type: "array", condition: {"field":"mode","values":[0,3,4]}, typeArgs: { type: "string", count: "playerCount" } }
]}, ]},
custom_payload: {id: 0x3f, fields: [ custom_payload: {id: "0x3f", fields: [
{ name: "channel", type: "string" }, { name: "channel", type: "string" },
{ name: "data", type: "restBuffer" } { name: "data", type: "restBuffer" }
]}, ]},
kick_disconnect: {id: 0x40, fields: [ kick_disconnect: {id: "0x40", fields: [
{ name: "reason", type: "string" } { name: "reason", type: "string" }
]}, ]},
difficulty: { id: 0x41, fields: [ difficulty: { id: "0x41", fields: [
{ name: "difficulty", type: "ubyte" } { name: "difficulty", type: "ubyte" }
]}, ]},
combat_event: { id: 0x42, fields: [ combat_event: { id: "0x42", fields: [
{ name: "event", type: "varint"}, { name: "event", type: "varint"},
{ name: "duration", type: "varint", condition: {"field":"event","values":[1]}}, { name: "duration", type: "varint", condition: {"field":"event","values":[1]}},
{ name: "playerId", type: "varint", condition: {"field":"event","values":[2]}}, { name: "playerId", type: "varint", condition: {"field":"event","values":[2]}},
{ name: "entityId", type: "int", condition: {"field":"event","values":[1,2]}}, { name: "entityId", type: "int", condition: {"field":"event","values":[1,2]}},
{ name: "message", type: "string", condition: {"field":"event","values":[2]}} { name: "message", type: "string", condition: {"field":"event","values":[2]}}
]}, ]},
camera: { id: 0x43, fields: [ camera: { id: "0x43", fields: [
{ name: "cameraId", type: "varint" } { name: "cameraId", type: "varint" }
]}, ]},
world_border: { id: 0x44, fields: [ world_border: { id: "0x44", fields: [
{ name: "action", type: "varint"}, { name: "action", type: "varint"},
{ name: "radius", type: "double", condition: {"field":"action","values":[0]}}, { name: "radius", type: "double", condition: {"field":"action","values":[0]}},
{ name: "x", type: "double", condition: {"field":"action","values":[2,3]}}, { name: "x", type: "double", condition: {"field":"action","values":[2,3]}},
@ -531,58 +531,58 @@ module.exports= {
{ name: "warning_time", type: "varint", condition: {"field":"action","values":[4,3]}}, { name: "warning_time", type: "varint", condition: {"field":"action","values":[4,3]}},
{ name: "warning_blocks", type: "varint", condition: {"field":"action","values":[5,3]}} { name: "warning_blocks", type: "varint", condition: {"field":"action","values":[5,3]}}
]}, ]},
title: { id: 0x45, fields: [ title: { id: "0x45", fields: [
{ name: "action", type: "varint"}, { name: "action", type: "varint"},
{ name: "text", type: "string", condition: {"field":"action","values":[0,1]}}, { name: "text", type: "string", condition: {"field":"action","values":[0,1]}},
{ name: "fadeIn", type: "int", condition: {"field":"action","values":[2]}}, { name: "fadeIn", type: "int", condition: {"field":"action","values":[2]}},
{ name: "stay", type: "int", condition: {"field":"action","values":[2]}}, { name: "stay", type: "int", condition: {"field":"action","values":[2]}},
{ name: "fadeOut", type: "int", condition: {"field":"action","values":[2]}} { name: "fadeOut", type: "int", condition: {"field":"action","values":[2]}}
]}, ]},
set_compression: { id: 0x46, fields: [ set_compression: { id: "0x46", fields: [
{ name: "threshold", type: "varint"} { name: "threshold", type: "varint"}
]}, ]},
playerlist_header: { id: 0x47, fields: [ playerlist_header: { id: "0x47", fields: [
{ name: "header", type: "string" }, { name: "header", type: "string" },
{ name: "footer", type: "string" } { name: "footer", type: "string" }
]}, ]},
resource_pack_send: { id: 0x48, fields: [ resource_pack_send: { id: "0x48", fields: [
{ name: "url", type: "string" }, { name: "url", type: "string" },
{ name: "hash", type: "string" } { name: "hash", type: "string" }
]}, ]},
update_entity_nbt: { id: 0x49, fields: [ update_entity_nbt: { id: "0x49", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "tag", type: "restBuffer"} { name: "tag", type: "restBuffer"}
]} ]}
}, },
toServer: { toServer: {
keep_alive: {id: 0x00, fields: [ keep_alive: {id: "0x00", fields: [
{ name: "keepAliveId", type: "varint" } { name: "keepAliveId", type: "varint" }
]}, ]},
chat: {id: 0x01, fields: [ chat: {id: "0x01", fields: [
{ name: "message", type: "string" } { name: "message", type: "string" }
]}, ]},
use_entity: {id: 0x02, fields: [ use_entity: {id: "0x02", fields: [
{ name: "target", type: "varint" }, { name: "target", type: "varint" },
{ name: "mouse", type: "varint" }, { name: "mouse", type: "varint" },
{ name: "x", type: "float", condition: {"field":"mouse","values":[2]}}, { name: "x", type: "float", condition: {"field":"mouse","values":[2]}},
{ name: "y", type: "float", condition: {"field":"mouse","values":[2]}}, { name: "y", type: "float", condition: {"field":"mouse","values":[2]}},
{ name: "z", type: "float", condition: {"field":"mouse","values":[2]}}, { name: "z", type: "float", condition: {"field":"mouse","values":[2]}},
]}, ]},
flying: {id: 0x03, fields: [ flying: {id: "0x03", fields: [
{ name: "onGround", type: "bool" } { name: "onGround", type: "bool" }
]}, ]},
position: {id: 0x04, fields: [ position: {id: "0x04", fields: [
{ name: "x", type: "double" }, { name: "x", type: "double" },
{ name: "y", type: "double" }, { name: "y", type: "double" },
{ name: "z", type: "double" }, { name: "z", type: "double" },
{ name: "onGround", type: "bool" } { name: "onGround", type: "bool" }
]}, ]},
look: {id: 0x05, fields: [ look: {id: "0x05", fields: [
{ name: "yaw", type: "float" }, { name: "yaw", type: "float" },
{ name: "pitch", type: "float" }, { name: "pitch", type: "float" },
{ name: "onGround", type: "bool" } { name: "onGround", type: "bool" }
]}, ]},
position_look: {id: 0x06, fields: [ position_look: {id: "0x06", fields: [
{ name: "x", type: "double" }, { name: "x", type: "double" },
{ name: "y", type: "double" }, { name: "y", type: "double" },
{ name: "z", type: "double" }, { name: "z", type: "double" },
@ -590,12 +590,12 @@ module.exports= {
{ name: "pitch", type: "float" }, { name: "pitch", type: "float" },
{ name: "onGround", type: "bool" } { name: "onGround", type: "bool" }
]}, ]},
block_dig: {id: 0x07, fields: [ block_dig: {id: "0x07", fields: [
{ name: "status", type: "byte" }, { name: "status", type: "byte" },
{ name: "location", type: "position"}, { name: "location", type: "position"},
{ name: "face", type: "byte" } { name: "face", type: "byte" }
]}, ]},
block_place: {id: 0x08, fields: [ block_place: {id: "0x08", fields: [
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "direction", type: "byte" }, { name: "direction", type: "byte" },
{ name: "heldItem", type: "slot" }, { name: "heldItem", type: "slot" },
@ -603,24 +603,24 @@ module.exports= {
{ name: "cursorY", type: "byte" }, { name: "cursorY", type: "byte" },
{ name: "cursorZ", type: "byte" } { name: "cursorZ", type: "byte" }
]}, ]},
held_item_slot: {id: 0x09, fields: [ held_item_slot: {id: "0x09", fields: [
{ name: "slotId", type: "short" } { name: "slotId", type: "short" }
]}, ]},
arm_animation: {id: 0x0a, fields: []}, arm_animation: {id: "0x0a", fields: []},
entity_action: {id: 0x0b, fields: [ entity_action: {id: "0x0b", fields: [
{ name: "entityId", type: "varint" }, { name: "entityId", type: "varint" },
{ name: "actionId", type: "varint" }, { name: "actionId", type: "varint" },
{ name: "jumpBoost", type: "varint" } { name: "jumpBoost", type: "varint" }
]}, ]},
steer_vehicle: {id: 0x0c, fields: [ steer_vehicle: {id: "0x0c", fields: [
{ name: "sideways", type: "float" }, { name: "sideways", type: "float" },
{ name: "forward", type: "float" }, { name: "forward", type: "float" },
{ name: "jump", type: "ubyte" } { name: "jump", type: "ubyte" }
]}, ]},
close_window: {id: 0x0d, fields: [ close_window: {id: "0x0d", fields: [
{ name: "windowId", type: "byte" } { name: "windowId", type: "byte" }
]}, ]},
window_click: {id: 0x0e, fields: [ window_click: {id: "0x0e", fields: [
{ name: "windowId", type: "byte" }, { name: "windowId", type: "byte" },
{ name: "slot", type: "short" }, { name: "slot", type: "short" },
{ name: "mouseButton", type: "byte" }, { name: "mouseButton", type: "byte" },
@ -628,54 +628,54 @@ module.exports= {
{ name: "mode", type: "byte" }, { name: "mode", type: "byte" },
{ name: "item", type: "slot" } { name: "item", type: "slot" }
]}, ]},
transaction: {id: 0x0f, fields: [ transaction: {id: "0x0f", fields: [
{ name: "windowId", type: "byte" }, { name: "windowId", type: "byte" },
{ name: "action", type: "short" }, { name: "action", type: "short" },
{ name: "accepted", type: "bool" } { name: "accepted", type: "bool" }
]}, ]},
set_creative_slot: {id: 0x10, fields: [ set_creative_slot: {id: "0x10", fields: [
{ name: "slot", type: "short" }, { name: "slot", type: "short" },
{ name: "item", type: "slot" } { name: "item", type: "slot" }
]}, ]},
enchant_item: {id: 0x11, fields: [ enchant_item: {id: "0x11", fields: [
{ name: "windowId", type: "byte" }, { name: "windowId", type: "byte" },
{ name: "enchantment", type: "byte" } { name: "enchantment", type: "byte" }
]}, ]},
update_sign: {id: 0x12, fields: [ update_sign: {id: "0x12", fields: [
{ name: "location", type: "position" }, { name: "location", type: "position" },
{ name: "text1", type: "string" }, { name: "text1", type: "string" },
{ name: "text2", type: "string" }, { name: "text2", type: "string" },
{ name: "text3", type: "string" }, { name: "text3", type: "string" },
{ name: "text4", type: "string" } { name: "text4", type: "string" }
]}, ]},
abilities: {id: 0x13, fields: [ abilities: {id: "0x13", fields: [
{ name: "flags", type: "byte" }, { name: "flags", type: "byte" },
{ name: "flyingSpeed", type: "float" }, { name: "flyingSpeed", type: "float" },
{ name: "walkingSpeed", type: "float" } { name: "walkingSpeed", type: "float" }
]}, ]},
tab_complete: {id: 0x14, fields: [ tab_complete: {id: "0x14", fields: [
{ name: "text", type: "string" }, { name: "text", type: "string" },
{ name: "hasPosition", type: "bool" }, { name: "hasPosition", type: "bool" },
{ name: "block", type: "position", condition: {"field":"hasPosition","values":[true]}} { name: "block", type: "position", condition: {"field":"hasPosition","values":[true]}}
]}, ]},
settings: {id: 0x15, fields: [ settings: {id: "0x15", fields: [
{ name: "locale", type: "string" }, { name: "locale", type: "string" },
{ name: "viewDistance", type: "byte" }, { name: "viewDistance", type: "byte" },
{ name: "chatFlags", type: "byte" }, { name: "chatFlags", type: "byte" },
{ name: "chatColors", type: "bool" }, { name: "chatColors", type: "bool" },
{ name: "skinParts", type: "ubyte" } { name: "skinParts", type: "ubyte" }
]}, ]},
client_command: {id: 0x16, fields: [ client_command: {id: "0x16", fields: [
{ name: "payload", type: "varint" } { name: "payload", type: "varint" }
]}, ]},
custom_payload: {id: 0x17, fields: [ custom_payload: {id: "0x17", fields: [
{ name: "channel", type: "string" }, { name: "channel", type: "string" },
{ name: "data", type: "restBuffer"} { name: "data", type: "restBuffer"}
]}, ]},
spectate: { id: 0x18, fields: [ spectate: { id: "0x18", fields: [
{ name: "target", type: "UUID"} { name: "target", type: "UUID"}
]}, ]},
resource_pack_receive: { id: 0x19, fields: [ resource_pack_receive: { id: "0x19", fields: [
{ name: "hash", type: "string" }, { name: "hash", type: "string" },
{ name: "result", type: "varint" } { name: "result", type: "varint" }
]} ]}