!version: 1.7

^types:
   varint: native
   pstring: native
   u16: native
   u8: native
   i64: native
   buffer: native
   i32: native
   i8: native
   bool: native
   i16: native
   f32: native
   f64: native
   UUID: native
   option: native
   entityMetadataLoop: native
   bitfield: native
   bitflags: native
   container: native
   switch: native
   void: native
   array: native
   restBuffer: native
   nbt: native
   compressedNbt: native
   ByteArray: ["buffer", { "countType": "varint" }]
   string: ["pstring", { "countType": "varint" }]
   vec3i16:
      x: i16
      y: i16
      z: i16
   slot:   
      blockId: i16
      _: blockId ?
         if -1: void
         default:         
            itemCount: i8
            itemDamage: i16
            nbtData: compressedNbt
   position_iii:   
      x: i32
      y: i32
      z: i32
   position_isi:   
      x: i32
      y: i16
      z: i32
   position_ibi:   
      x: i32
      y: u8
      z: i32
   entityMetadataItem: $compareTo ?
      if 0: i8
      if 1: i16
      if 2: i32
      if 3: f32
      if 4: string
      if 5: slot
      if 6:      
         x: i32
         y: i32
         z: i32
      if 7:      
         pitch: f32
         yaw: f32
         roll: f32
   entityMetadata: [
      "entityMetadataLoop",
      {
         "endVal": 127,
         "type": [
            "container",
            [
               {
                  "anon": true,
                  "type": [
                     "bitfield",
                     [
                        {
                           "name": "type",
                           "size": 3,
                           "signed": false
                        },
                        {
                           "name": "key",
                           "size": 5,
                           "signed": false
                        }
                     ]
                  ]
               },
               {
                  "name": "value",
                  "type": [
                     "entityMetadataItem",
                     {
                        "compareTo": "type"
                     }
                  ]
               }
            ]
         ]
      }
   ]

^handshaking.toClient.types:
   packet:   
      name: varint =>
      params: ["switch",{"compareTo":"name","fields":{}}]

^handshaking.toServer.types:
   packet_set_protocol:   
      protocolVersion: varint
      serverHost: string
      serverPort: u16
      nextState: varint
   packet_legacy_server_list_ping:   
      payload: u8
   packet:   
      name: varint =>
         0x00: set_protocol
         0xfe: legacy_server_list_ping
      params: name ?
         if set_protocol: packet_set_protocol
         if legacy_server_list_ping: packet_legacy_server_list_ping

^status.toClient.types:
   packet_server_info:   
      response: string
   packet_ping:   
      time: i64
   packet:   
      name: varint =>
         0x00: server_info
         0x01: ping
      params: name ?
         if server_info: packet_server_info
         if ping: packet_ping

^status.toServer.types:
   packet_ping_start:   
      # Empty
   packet_ping:   
      time: i64
   packet:   
      name: varint =>
         0x00: ping_start
         0x01: ping
      params: name ?
         if ping_start: packet_ping_start
         if ping: packet_ping

^login.toClient.types:
   packet_disconnect:   
      reason: string
   packet_encryption_begin:   
      serverId: string
      publicKey: [
         "buffer",
         {
            "countType": "i16"
         }
      ]
      verifyToken: [
         "buffer",
         {
            "countType": "i16"
         }
      ]
   packet_success:   
      uuid: string
      username: string
   packet:   
      name: varint =>
         0x00: disconnect
         0x01: encryption_begin
         0x02: success
      params: name ?
         if disconnect: packet_disconnect
         if encryption_begin: packet_encryption_begin
         if success: packet_success

^login.toServer.types:
   packet_login_start:   
      username: string
   packet_encryption_begin:   
      sharedSecret: [
         "buffer",
         {
            "countType": "i16"
         }
      ]
      verifyToken: [
         "buffer",
         {
            "countType": "i16"
         }
      ]
   packet:   
      name: varint =>
         0x00: login_start
         0x01: encryption_begin
      params: name ?
         if login_start: packet_login_start
         if encryption_begin: packet_encryption_begin

^play.toClient.types:
   packet_keep_alive:   
      keepAliveId: i32
   packet_login:   
      entityId: i32
      gameMode: u8
      dimension: i8
      difficulty: u8
      maxPlayers: u8
      levelType: string
   packet_chat:   
      message: string
   packet_update_time:   
      age: i64
      time: i64
   packet_entity_equipment:   
      entityId: i32
      slot: i16
      item: slot
   packet_spawn_position:   
      location: position_iii
   packet_update_health:   
      health: f32
      food: i16
      foodSaturation: f32
   packet_respawn:   
      dimension: i32
      difficulty: u8
      gamemode: u8
      levelType: string
   packet_position:   
      x: f64
      y: f64
      z: f64
      yaw: f32
      pitch: f32
      onGround: bool
   packet_held_item_slot:   
      slot: i8
   packet_bed:   
      entityId: i32
      location: position_ibi
   packet_animation:   
      entityId: varint
      animation: u8
   packet_named_entity_spawn:   
      entityId: varint
      playerUUID: string
      playerName: string
      data: []varint
         name: string
         value: string
         signature: string
      x: i32
      y: i32
      z: i32
      yaw: i8
      pitch: i8
      currentItem: i16
      metadata: entityMetadata
   packet_collect:   
      collectedEntityId: i32
      collectorEntityId: i32
   packet_spawn_entity:   
      entityId: varint
      type: i8
      x: i32
      y: i32
      z: i32
      pitch: i8
      yaw: i8
      objectData:      
         intField: i32
         velocityX: intField ?
            if 0: void
            default: i16
         velocityY: intField ?
            if 0: void
            default: i16
         velocityZ: intField ?
            if 0: void
            default: i16
   packet_spawn_entity_living:   
      entityId: varint
      type: u8
      x: i32
      y: i32
      z: i32
      yaw: i8
      pitch: i8
      headPitch: i8
      velocity: vec3i16
      metadata: entityMetadata
   packet_spawn_entity_painting:   
      entityId: varint
      title: string
      location: position_iii
      direction: i32
   packet_spawn_entity_experience_orb:   
      entityId: varint
      x: i32
      y: i32
      z: i32
      count: i16
   packet_entity_velocity:   
      entityId: i32
      velocity: vec3i16
   packet_entity_destroy:   
      entityIds: i32[]i8
   packet_entity:   
      entityId: i32
   packet_rel_entity_move:   
      entityId: i32
      dX: i8
      dY: i8
      dZ: i8
   packet_entity_look:   
      entityId: i32
      yaw: i8
      pitch: i8
   packet_entity_move_look:   
      entityId: i32
      dX: i8
      dY: i8
      dZ: i8
      yaw: i8
      pitch: i8
   packet_entity_teleport:   
      entityId: i32
      x: i32
      y: i32
      z: i32
      yaw: i8
      pitch: i8
   packet_entity_head_rotation:   
      entityId: i32
      headYaw: i8
   packet_entity_status:   
      entityId: i32
      entityStatus: i8
   packet_attach_entity:   
      entityId: i32
      vehicleId: i32
      leash: bool
   packet_entity_metadata:   
      entityId: i32
      metadata: entityMetadata
   packet_entity_effect:   
      entityId: i32
      effectId: i8
      amplifier: i8
      duration: i16
   packet_remove_entity_effect:   
      entityId: i32
      effectId: i8
   packet_experience:   
      experienceBar: f32
      level: i16
      totalExperience: i16
   packet_update_attributes:   
      entityId: i32
      properties: []i32
         key: string
         value: f64
         modifiers: []i16
            uuid: UUID
            amount: f64
            operation: i8
   packet_map_chunk:   
      x: i32
      z: i32
      groundUp: bool
      bitMap: u16
      addBitMap: u16
      compressedChunkData: [
         "buffer",
         {
            "countType": "i32"
         }
      ]
   packet_multi_block_change:   
      chunkX: i32
      chunkZ: i32
      recordCount: [
         "count",
         {
            "type": "i16",
            "countFor": "records"
         }
      ]
      dataLength: i32
      records: []$recordCount
         _: [
            "bitfield",
            [
               {
                  "name": "metadata",
                  "size": 4,
                  "signed": false
               },
               {
                  "name": "blockId",
                  "size": 12,
                  "signed": false
               }
            ]
         ]
         y: u8
         _: [
            "bitfield",
            [
               {
                  "name": "z",
                  "size": 4,
                  "signed": false
               },
               {
                  "name": "x",
                  "size": 4,
                  "signed": false
               }
            ]
         ]
   packet_block_change:   
      location: position_ibi
      type: varint
      metadata: u8
   packet_block_action:   
      location: position_isi
      byte1: u8
      byte2: u8
      blockId: varint
   packet_block_break_animation:   
      entityId: varint
      location: position_iii
      destroyStage: i8
   packet_map_chunk_bulk:   
      chunkColumnCount: [
         "count",
         {
            "type": "i16",
            "countFor": "meta"
         }
      ]
      dataLength: [
         "count",
         {
            "type": "i32",
            "countFor": "compressedChunkData"
         }
      ]
      skyLightSent: bool
      compressedChunkData: [
         "buffer",
         {
            "count": "dataLength"
         }
      ]
      meta: []$chunkColumnCount
         x: i32
         z: i32
         bitMap: u16
         addBitMap: u16
   packet_explosion:   
      x: f32
      y: f32
      z: f32
      radius: f32
      affectedBlockOffsets: []i32
         x: i8
         y: i8
         z: i8
      playerMotionX: f32
      playerMotionY: f32
      playerMotionZ: f32
   packet_world_event:   
      effectId: i32
      location: position_ibi
      data: i32
      global: bool
   packet_named_sound_effect:   
      soundName: string
      x: i32
      y: i32
      z: i32
      volume: f32
      pitch: u8
   packet_world_particles:   
      particleName: string
      x: f32
      y: f32
      z: f32
      offsetX: f32
      offsetY: f32
      offsetZ: f32
      particleData: f32
      particles: i32
   packet_game_state_change:   
      reason: u8
      gameMode: f32
   packet_spawn_entity_weather:   
      entityId: varint
      type: i8
      x: i32
      y: i32
      z: i32
   packet_open_window:   
      windowId: u8
      inventoryType: u8
      windowTitle: string
      slotCount: u8
      useProvidedTitle: bool
      entityId: inventoryType ?
         if 11: i32
         default: void
   packet_close_window:   
      windowId: u8
   packet_set_slot:   
      windowId: i8
      slot: i16
      item: slot
   packet_window_items:   
      windowId: u8
      items: slot[]i16
   packet_craft_progress_bar:   
      windowId: u8
      property: i16
      value: i16
   packet_transaction:   
      windowId: u8
      action: i16
      accepted: bool
   packet_update_sign:   
      location: position_isi
      text1: string
      text2: string
      text3: string
      text4: string
   packet_map:   
      itemDamage: varint
      data: [
         "buffer",
         {
            "countType": "i16"
         }
      ]
   packet_tile_entity_data:   
      location: position_isi
      action: u8
      nbtData: compressedNbt
   packet_open_sign_entity:   
      location: position_iii
   packet_statistics:   
      entries: []varint
         name: string
         value: varint
   packet_player_info:   
      playerName: string
      online: bool
      ping: i16
   packet_abilities:   
      flags: i8
      flyingSpeed: f32
      walkingSpeed: f32
   packet_tab_complete:   
      matches: string[]varint
   packet_scoreboard_objective:   
      name: string
      displayText: string
      action: i8
   packet_scoreboard_score:   
      itemName: string
      action: i8
      scoreName: action ?
         if 1: void
         default: string
      value: action ?
         if 1: void
         default: i32
   packet_scoreboard_display_objective:   
      position: i8
      name: string
   packet_scoreboard_team:   
      team: string
      mode: i8
      name: mode ?
         if 0: string
         if 2: string
         default: void
      prefix: mode ?
         if 0: string
         if 2: string
         default: void
      suffix: mode ?
         if 0: string
         if 2: string
         default: void
      friendlyFire: mode ?
         if 0: i8
         if 2: i8
         default: void
      players: mode ?
         if 0: string[]i16
         if 3: string[]i16
         if 4: string[]i16
         default: void
   packet_custom_payload:   
      channel: string
      data: [
         "buffer",
         {
            "countType": "i16"
         }
      ]
   packet_kick_disconnect:   
      reason: string
   packet:   
      name: varint =>
         0x00: keep_alive
         0x01: login
         0x02: chat
         0x03: update_time
         0x04: entity_equipment
         0x05: spawn_position
         0x06: update_health
         0x07: respawn
         0x08: position
         0x09: held_item_slot
         0x0a: bed
         0x0b: animation
         0x0c: named_entity_spawn
         0x0d: collect
         0x0e: spawn_entity
         0x0f: spawn_entity_living
         0x10: spawn_entity_painting
         0x11: spawn_entity_experience_orb
         0x12: entity_velocity
         0x13: entity_destroy
         0x14: entity
         0x15: rel_entity_move
         0x16: entity_look
         0x17: entity_move_look
         0x18: entity_teleport
         0x19: entity_head_rotation
         0x1a: entity_status
         0x1b: attach_entity
         0x1c: entity_metadata
         0x1d: entity_effect
         0x1e: remove_entity_effect
         0x1f: experience
         0x20: update_attributes
         0x21: map_chunk
         0x22: multi_block_change
         0x23: block_change
         0x24: block_action
         0x25: block_break_animation
         0x26: map_chunk_bulk
         0x27: explosion
         0x28: world_event
         0x29: named_sound_effect
         0x2a: world_particles
         0x2b: game_state_change
         0x2c: spawn_entity_weather
         0x2d: open_window
         0x2e: close_window
         0x2f: set_slot
         0x30: window_items
         0x31: craft_progress_bar
         0x32: transaction
         0x33: update_sign
         0x34: map
         0x35: tile_entity_data
         0x36: open_sign_entity
         0x37: statistics
         0x38: player_info
         0x39: abilities
         0x3a: tab_complete
         0x3b: scoreboard_objective
         0x3c: scoreboard_score
         0x3d: scoreboard_display_objective
         0x3e: scoreboard_team
         0x3f: custom_payload
         0x40: kick_disconnect
      params: name ?
         if keep_alive: packet_keep_alive
         if login: packet_login
         if chat: packet_chat
         if update_time: packet_update_time
         if entity_equipment: packet_entity_equipment
         if spawn_position: packet_spawn_position
         if update_health: packet_update_health
         if respawn: packet_respawn
         if position: packet_position
         if held_item_slot: packet_held_item_slot
         if bed: packet_bed
         if animation: packet_animation
         if named_entity_spawn: packet_named_entity_spawn
         if collect: packet_collect
         if spawn_entity: packet_spawn_entity
         if spawn_entity_living: packet_spawn_entity_living
         if spawn_entity_painting: packet_spawn_entity_painting
         if spawn_entity_experience_orb: packet_spawn_entity_experience_orb
         if entity_velocity: packet_entity_velocity
         if entity_destroy: packet_entity_destroy
         if entity: packet_entity
         if rel_entity_move: packet_rel_entity_move
         if entity_look: packet_entity_look
         if entity_move_look: packet_entity_move_look
         if entity_teleport: packet_entity_teleport
         if entity_head_rotation: packet_entity_head_rotation
         if entity_status: packet_entity_status
         if attach_entity: packet_attach_entity
         if entity_metadata: packet_entity_metadata
         if entity_effect: packet_entity_effect
         if remove_entity_effect: packet_remove_entity_effect
         if experience: packet_experience
         if update_attributes: packet_update_attributes
         if map_chunk: packet_map_chunk
         if multi_block_change: packet_multi_block_change
         if block_change: packet_block_change
         if block_action: packet_block_action
         if block_break_animation: packet_block_break_animation
         if map_chunk_bulk: packet_map_chunk_bulk
         if explosion: packet_explosion
         if world_event: packet_world_event
         if named_sound_effect: packet_named_sound_effect
         if world_particles: packet_world_particles
         if game_state_change: packet_game_state_change
         if spawn_entity_weather: packet_spawn_entity_weather
         if open_window: packet_open_window
         if close_window: packet_close_window
         if set_slot: packet_set_slot
         if window_items: packet_window_items
         if craft_progress_bar: packet_craft_progress_bar
         if transaction: packet_transaction
         if update_sign: packet_update_sign
         if map: packet_map
         if tile_entity_data: packet_tile_entity_data
         if open_sign_entity: packet_open_sign_entity
         if statistics: packet_statistics
         if player_info: packet_player_info
         if abilities: packet_abilities
         if tab_complete: packet_tab_complete
         if scoreboard_objective: packet_scoreboard_objective
         if scoreboard_score: packet_scoreboard_score
         if scoreboard_display_objective: packet_scoreboard_display_objective
         if scoreboard_team: packet_scoreboard_team
         if custom_payload: packet_custom_payload
         if kick_disconnect: packet_kick_disconnect

^play.toServer.types:
   packet_keep_alive:   
      keepAliveId: i32
   packet_chat:   
      message: string
   packet_use_entity:   
      target: i32
      mouse: i8
      x: mouse ?
         if 2: f32
         default: void
      y: mouse ?
         if 2: f32
         default: void
      z: mouse ?
         if 2: f32
         default: void
   packet_flying:   
      onGround: bool
   packet_position:   
      x: f64
      stance: f64
      y: f64
      z: f64
      onGround: bool
   packet_look:   
      yaw: f32
      pitch: f32
      onGround: bool
   packet_position_look:   
      x: f64
      stance: f64
      y: f64
      z: f64
      yaw: f32
      pitch: f32
      onGround: bool
   packet_block_dig:   
      status: i8
      location: position_ibi
      face: i8
   packet_block_place:   
      location: position_ibi
      direction: i8
      heldItem: slot
      cursorX: i8
      cursorY: i8
      cursorZ: i8
   packet_held_item_slot:   
      slotId: i16
   packet_arm_animation:   
      entityId: i32
      animation: i8
   packet_entity_action:   
      entityId: i32
      actionId: i8
      jumpBoost: i32
   packet_steer_vehicle:   
      sideways: f32
      forward: f32
      jump: bool
      unmount: bool
   packet_close_window:   
      windowId: u8
   packet_window_click:   
      windowId: i8
      slot: i16
      mouseButton: i8
      action: i16
      mode: i8
      item: slot
   packet_transaction:   
      windowId: i8
      action: i16
      accepted: bool
   packet_set_creative_slot:   
      slot: i16
      item: slot
   packet_enchant_item:   
      windowId: i8
      enchantment: i8
   packet_update_sign:   
      location: position_isi
      text1: string
      text2: string
      text3: string
      text4: string
   packet_abilities:   
      flags: i8
      flyingSpeed: f32
      walkingSpeed: f32
   packet_tab_complete:   
      text: string
   packet_settings:   
      locale: string
      viewDistance: i8
      chatFlags: i8
      chatColors: bool
      difficulty: u8
      showCape: bool
   packet_client_command:   
      payload: i8
   packet_custom_payload:   
      channel: string
      data: [
         "buffer",
         {
            "countType": "i16"
         }
      ]
   packet:   
      name: varint =>
         0x00: keep_alive
         0x01: chat
         0x02: use_entity
         0x03: flying
         0x04: position
         0x05: look
         0x06: position_look
         0x07: block_dig
         0x08: block_place
         0x09: held_item_slot
         0x0a: arm_animation
         0x0b: entity_action
         0x0c: steer_vehicle
         0x0d: close_window
         0x0e: window_click
         0x0f: transaction
         0x10: set_creative_slot
         0x11: enchant_item
         0x12: update_sign
         0x13: abilities
         0x14: tab_complete
         0x15: settings
         0x16: client_command
         0x17: custom_payload
      params: name ?
         if keep_alive: packet_keep_alive
         if chat: packet_chat
         if use_entity: packet_use_entity
         if flying: packet_flying
         if position: packet_position
         if look: packet_look
         if position_look: packet_position_look
         if block_dig: packet_block_dig
         if block_place: packet_block_place
         if held_item_slot: packet_held_item_slot
         if arm_animation: packet_arm_animation
         if entity_action: packet_entity_action
         if steer_vehicle: packet_steer_vehicle
         if close_window: packet_close_window
         if window_click: packet_window_click
         if transaction: packet_transaction
         if set_creative_slot: packet_set_creative_slot
         if enchant_item: packet_enchant_item
         if update_sign: packet_update_sign
         if abilities: packet_abilities
         if tab_complete: packet_tab_complete
         if settings: packet_settings
         if client_command: packet_client_command
         if custom_payload: packet_custom_payload
