serverbound_packets.clj

Bowmap · bowmap.git · Tickets

Branches > main > 0123d38 > files / src / net / bowmap / server / protocol / serverbound_packets.clj

(ns net.bowmap.server.protocol.serverbound-packets
  (:require
   [net.bowmap.server.protocol.phase :as phase]
   [net.bowmap.server.protocol.readers :refer :all]
   [net.bowmap.server.protocol.schema :as p]))

(def serverbound-packets
  "Map of connection phases to pairs of [serverbound-packet-id reader]"
  {::phase/handshaking
   [::handshaking [:protocol varint<
                   :address string<
                   :port short<
                   ::phase/phase (enum< varint< {1 ::phase/status 2 ::phase/login 3 ::phase/transfer})]]
   ::phase/status
   [::status-request []
    ::ping-request [::p/timestamp long<]]
   ::phase/login
   [::login-start [::p/username string<
                   ::p/uuid uuid<]
    ::encryption-response nil
    ::login-plugin-response nil
    ::login-acknowledged nil
    ::cookie-response nil]
   ::phase/config
   [::client-information nil
    ::cookie-response nil
    ::plugin-message nil
    ::finish-config nil
    ::keep-alive nil
    ::pong nil
    ::resource-pack-response nil
    ::known-packs nil
    ::custom-click-action nil
    ::accept-code-of-conduct nil]
   ::phase/play
   [::confirm-teleportation nil
    ::attack nil
    ::query-block-entity-tag nil
    ::bundle-item-selected nil
    ::change-difficulty nil
    ::change-game-mode nil
    ::acknowledge-message nil
    ::chat-command nil
    ::signed-chat-command nil
    ::chat-message nil
    ::player-session nil
    ::chunk-batch-received nil
    ::client-status nil
    ::client-tick-end nil
    ::client-information nil
    ::command-suggestions-request nil
    ::acknowledge-configuration nil
    ::click-container-button nil
    ::click-container nil
    ::close-container nil
    ::change-container-slot-state nil
    ::cookie-response nil
    ::plugin-message nil
    ::debug-subscription-request nil
    ::edit-book nil
    ::query-entity-tag nil
    ::interact nil
    ::jigsaw-generate nil
    ::keep-alive nil
    ::lock-difficulty nil
    ::set-player-position nil
    ::set-player-position-and-rotation nil
    ::set-player-rotation nil
    ::set-player-movement-flags nil
    ::move-vehicle nil
    ::paddle-boat nil
    ::pick-item-from-block nil
    ::pick-item-from-entity nil
    ::ping-request nil
    ::place-recipe nil
    ::player-abilities nil
    ::player-action nil
    ::player-command nil
    ::player-input nil
    ::player-loaded nil
    ::pong nil
    ::change-recipe-book-settings nil
    ::set-seen-recipe nil
    ::rename-item nil
    ::resource-pack-response nil
    ::seen-advancements nil
    ::select-trade nil
    ::set-beacon-effect nil
    ::select-hotbar-slot nil
    ::program-command-block nil
    ::program-command-block-minecart nil
    ::set-creative-mode-slot nil
    ::set-game-rules nil
    ::program-jigsaw-block nil
    ::program-structure-block nil
    ::set-test-block nil
    ::update-sign nil
    ::spectator-action nil
    ::swing-arm nil
    ::teleport-to-entity nil
    ::test-instance-block-action nil
    ::use-item-on nil
    ::use-item nil
    ::custom-click-action nil]})

(def phase->numeric-id->id (update-vals serverbound-packets #(zipmap (range) (take-nth 2 %))))
(def phase->id->reader (update-vals serverbound-packets #(-> (apply hash-map %)
                                                             (update-vals ->reader))))

(def ids (set (mapcat #(take-nth 2 %) (vals serverbound-packets))))