serverbound.clj
Branches > main > 015bd59 > files / src / net / bowmap / protocol / packet / serverbound.clj
(ns net.bowmap.protocol.packet.serverbound
(:require
[net.bowmap.transport.readers
:refer [->bit-mask ->boolean ->byte ->double ->enum ->float ->identifier
->int ->list ->location ->long ->optional ->short ->string ->ubyte
->uuid ->varint]]
[net.bowmap.transport.phase :as phase]
[net.bowmap.server.position :as position]))
(def unused-fields [])
(def packets
"Map of packet ids to schemas"
; Handshaking
{::handshaking [:protocol ->varint
:address ->string
:port ->short
; TODO move to protocol state when that ns is sorted
::phase/phase (->enum ->varint {1 ::phase/status 2 ::phase/login 3 ::phase/transfer})]
; Status
::status-request []
::ping-request [:timestamp ->long]
; Login
::login-start [:username ->string
:uuid ->uuid]
::encryption-response [:shared-secret (->list ->byte)]
::login-plugin-response [:message ->varint
:data (fn [buf] (throw (Exception. "Fuck you")))]
::login-acknowledged []
::cookie-response [:key ->identifier
:payload (->optional (->list ->byte))]
; Config
::client-information unused-fields
::plugin-message unused-fields
::finish-config []
::pong [:id ->int]
::resource-pack-response [:uuid ->uuid
:result (->enum ->varint {0 :sucessfully-downloaded
1 :declined
2 :failed-to-download
3 :accepted
4 :downloaded
5 :invalid-url
6 :failed-to-reload
7 :discarded})]
; The wiki is too damn confusing
::known-packs unused-fields
; Play
::chat-message [:message ->string
#_"And then a bunch of fields I don't really care about :p"]
::confirm-teleportation [:teleport-id ->varint]
::client-tick-end []
::close-container [:window-id ->varint]
::keep-alive [:id ->long]
::set-player-rotation [::position/yaw ->float
::position/pitch ->float
:flags (->bit-mask ->byte [:on-ground :pushing-against-wall])]
::set-player-position-and-rotation [::position/x ->double
::position/y ->double
::position/z ->double
::position/yaw ->float
::position/pitch ->float
:flags (->bit-mask ->byte [:on-ground :pushing-against-wall])]
::set-player-position [::position/x ->double
::position/y ->double
::position/z ->double
:flags (->bit-mask ->byte [:on-ground :pushing-against-wall])]
::set-player-movement-flags [:flags (->bit-mask ->byte [:on-ground :pushing-against-wall])]
::player-abilities [:flags (->bit-mask ->byte {1 :flying?})] ; is this right?
::player-action [:status (->enum ->varint [:started-digging :canceled-digging :finished-digging
:drop-item-stack :drop-item :update-item-state :swap-item-in-hand])
; TODO aren't positions and locations different things?
:location ->location
; TODO block face might be something logical
:face (->enum ->byte [:bottom :top :north :south :west :east])
:sequence ->varint]
::player-command [:entity-id ->varint
:action-id (->enum ->varint [:leave-bed :start-sprinting :stop-sprinting :start-jumping-with-horse
:stop-jumping-with-horse :open-vehicle-inventory :start-flying-with-elytra])
:jump-boost ->varint]
::player-input [:flags (->bit-mask ->ubyte [:forward :backward :left :right :jump :sneak :sprint])]
::player-loaded []
::change-recipe-book-settings [:id (->enum ->varint [:crafting :furnace :blast-furnace :smoker])
:book-open? ->boolean
:filter-active? ->boolean]
::select-hotbar-slot [:slot "Slots 0-8" ->varint]
::swing-arm [:hand (->enum ->varint [:main-hand :off-hand])]})
(def packet-order
"Map of connection phases to vectors of serverbound packet ids in the order the appear in the protocol."
{::phase/handshaking
[::handshaking]
::phase/status
[::status-request
::ping-request]
::phase/login
[::login-start
::encryption-response
::login-plugin-response
::login-acknowledged
::cookie-response]
::phase/config
[::client-information
::cookie-response
::plugin-message
::finish-config
::keep-alive
::pong
::resource-pack-response
::known-packs
::custom-click-action
::accept-code-of-conduct]
::phase/play
[::confirm-teleportation
::attack
::query-block-entity-tag
::bundle-item-selected
::change-difficulty
::change-game-mode
::acknowledge-message
::chat-command
::signed-chat-command
::chat-message
::player-session
::chunk-batch-received
::client-status
::client-tick-end
::client-information
::command-suggestions-request
::acknowledge-configuration
::click-container-button
::click-container
::close-container
::change-container-slot-state
::cookie-response
::plugin-message
::debug-subscription-request
::edit-book
::query-entity-tag
::interact
::jigsaw-generate
::keep-alive
::lock-difficulty
::set-player-position
::set-player-position-and-rotation
::set-player-rotation
::set-player-movement-flags
::move-vehicle
::paddle-boat
::pick-item-from-block
::pick-item-from-entity
::ping-request
::place-recipe
::player-abilities
::player-action
::player-command
::player-input
::player-loaded
::pong
::change-recipe-book-settings
::set-seen-recipe
::rename-item
::resource-pack-response
::seen-advancements
::select-trade
::set-beacon-effect
::select-hotbar-slot
::program-command-block
::program-command-block-minecart
::set-creative-mode-slot
::set-game-rules
::program-jigsaw-block
::program-structure-block
::set-test-block
::update-sign
::spectator-action
::swing-arm
::teleport-to-entity
::test-instance-block-action
::use-item-on
::use-item
::custom-click-action]})