clientbound.clj

Bowmap · bowmap.git · Tickets

Branches > main > af0a324 > files / src / net / bowmap / server / packet / clientbound.clj

(ns net.bowmap.server.packet.clientbound
  (:require
   [net.bowmap.server.game.server :as server]
   [net.bowmap.server.packet.gamemode :as gamemode]
   [net.bowmap.server.packet.phase :as phase]
   [net.bowmap.server.packet.schema :as p]
   [net.bowmap.server.packet.writers :refer :all]))

(def clientbound-packets
  "Map of connection phases to pairs of clientbound packet IDs and writers.
   The ordering of packet IDs in the vectors determines their numeric ID."
  {::phase/status
   [::status-response status-response>
    ::pong-response (map> ::p/timestamp long>)]
   ::phase/login
   [::disconnect nil
    ::encryption-request nil
    ::login-success (map> ::p/game-profile game-profile>
                          ::p/session-uuid uuid>)
    ::set-compression nil
    ::login-plugin-request nil
    ::cookie-request nil]
   ::phase/config
   [::cookie-request nil
    ::plugin-message nil
    ::disconnect nil
    ::finish-config (map>)
    ::keep-alive nil
    ::ping nil
    ::reset-chat nil
    ::registry-data (map> ::p/registry-id identifier>
                          ::p/registry-entries (list> ::p/registry-entry-id identifier>
                                                      ::p/registry-data (optional> nbt>)))
    ::remove-resource-pack nil
    ::add-resource-pack nil
    ::post-effects nil
    ::store-cookie nil
    ::transfer nil
    ::feature-flags nil
    ::update-tags (map> ::p/tagged-registries
                        (list> ::p/registry-id identifier>
                               ::p/tags (list> ::p/tag-name identifier>
                                               ::p/tag-entries (list> varint>))))
    ::known-packs (map> ::p/known-packs (list> ::p/registry-id split-identifier>
                                               ::p/pack-version string>))
    ::custom-report-details nil
    ::server-links nil
    ::clear-dialog nil
    ::show-dialog nil
    ::code-of-conduct nil]
   ::phase/play
   [::bundle-delimiter nil
    ::spawn-entity nil
    ::entity-animation nil
    ::award-statistics nil
    ::acknowledge-block-change nil
    ::set-block-destroy-stage nil
    ::block-entity-data nil
    ::block-action nil
    ::block-update nil
    ::boss-bar nil
    ::change-difficulty nil
    ::chunk-batch-finished nil
    ::chunk-batch-start nil
    ::chunk-biomes nil
    ::clear-titles nil
    ::command-suggestions-response nil
    ::commands nil
    ::close-container nil
    ::set-container-content nil
    ::set-container-property nil
    ::set-container-slot nil
    ::cookie-request nil
    ::set-cooldown nil
    ::chat-suggestions nil
    ::plugin-message nil
    ::damage-event nil
    ::debug-block-value nil
    ::debug-chunk-value nil
    ::debug-entity-value nil
    ::debug-event nil
    ::debug-sample nil
    ::delete-message nil
    ::disconnect nil
    ::disguised-chat-message nil
    ::entity-event nil
    ::teleport-entity nil
    ::explosion nil
    ::add-transient-block nil
    ::unload-chunk nil
    ::game-event (map> ::p/game-event-id (enum> ubyte> {13 ::p/wait-for-chunk-event})
                       ::p/game-event-value (or> float> 0))
    ::game-rule-values nil
    ::game-test-highlight-position nil
    ::open-horse-screen nil
    ::hurt-animation nil
    ::initialize-world-border nil
    ::keep-alive nil
    ::chunk-data-and-update-light nil
    ::world-event nil
    ::particle nil
    ::update-light nil
    ::login (map> ::server/entity-id int>
                  :hardcore? boolean>
                  :dimensions (list> identifier>)
                  ::p/max-player-count varint>
                  :render-distance varint>
                  :simulation-distance varint>
                  :reduced-debug-info? boolean>
                  :use-respawn-screen? boolean>
                  :do-limited-crafting? boolean>
                  :current-dimension-registry-id varint>
                  :current-dimension identifier>
                  :first-8-bytes-of-the-sha-256-hash-of-the-world's-seed long>
                  ::gamemode/gamemode (enum> varint> {0 ::gamemode/survival 1 ::gamemode/creative 2 ::gamemode/adventure 3 ::gamemode/spectator})
                  :previous-gamemode (enum> varint> {0 nil 1 ::gamemode/survival 2 ::gamemode/creative 3 ::gamemode/adventure 4 ::gamemode/spectator})
                  :debug-world? boolean>
                  :superflat-world? boolean>
                  :has-death-location? boolean>
                  :death-dimension-name (context-optional> identifier>)
                  :death-location (context-optional> block-location>)
                  :portal-cooldown-ticks varint>
                  :sea-level varint>
                  :online? boolean>
                  :enforce-secure-chat? boolean>)
    ::low-disk-space-warning nil
    ::map-data nil
    ::merchant-offers nil
    ::update-entity-position nil
    ::update-entity-position-and-rotation nil
    ::move-minecart-along-track nil
    ::update-entity-rotation nil
    ::move-vehicle nil
    ::open-book nil
    ::open-screen nil
    ::open-sign-editor nil
    ::ping nil
    ::pong-response nil
    ::place-ghost-recipe nil
    ::player-abilities nil
    ::player-chat-message nil
    ::end-combat nil
    ::enter-combat nil
    ::combat-death nil
    ::player-info-remove nil
    ::player-info-update nil
    ::look-at nil
    ::synchronize-player-position nil
    ::player-rotation nil
    ::recipe-book-add nil
    ::recipe-book-remove nil
    ::recipe-book-settings nil
    ::remove-entities nil
    ::remove-entity-effect nil
    ::reset-score nil
    ::remove-resource-pack nil
    ::add-resource-pack nil
    ::post-effects nil
    ::respawn nil
    ::set-head-rotation nil
    ::update-section-blocks nil
    ::select-advancements-tab nil
    ::server-data nil
    ::set-action-bar-text nil
    ::set-border-center nil
    ::set-border-lerp-size nil
    ::set-border-size nil
    ::set-border-warning-delay nil
    ::set-border-warning-distance nil
    ::set-camera nil
    ::set-center-chunk nil
    ::set-render-distance nil
    ::set-cursor-item nil
    ::set-default-spawn-position nil
    ::display-objective nil
    ::set-entity-metadata nil
    ::link-entities nil
    ::set-entity-velocity nil
    ::set-equipment nil
    ::set-experience nil
    ::set-health nil
    ::set-held-item nil
    ::update-objectives nil
    ::set-passengers nil
    ::set-player-inventory-slot nil
    ::update-teams nil
    ::update-score nil
    ::set-simulation-distance nil
    ::set-subtitle-text nil
    ::update-time nil
    ::set-title-text nil
    ::set-title-animation-times nil
    ::entity-sound-effect nil
    ::sound-effect nil
    ::start-configuration nil
    ::stop-sound nil
    ::store-cookie nil
    ::swing-animation nil
    ::system-chat-message nil
    ::set-tab-list-header-and-footer nil
    ::tag-query-response nil
    ::pickup-item nil
    ::synchronize-vehicle-position nil
    ::test-instance-block-status nil
    ::set-ticking-state nil
    ::step-tick nil
    ::transfer nil
    ::update-advancements nil
    ::update-attributes nil
    ::entity-effect nil
    ::update-recipes nil
    ::update-tags nil
    ::projectile-power nil
    ::custom-report-details nil
    ::server-links nil
    ::waypoint nil
    ::clear-dialog nil
    ::show-dialog-play nil]})

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

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