b368129
Branches > main > b368129 > files / src / net / bowmap / server / core.clj
Use nil to denote the lack of a clientbound packet writer
Commit: b3681292c72bcbea2b9d3073112c8e9dc2579b71
Parent: 5e1b63e
2 changed files:
src/net/bowmap/server/protocol/clientbound_packets.clj view file
@@ -4,180 +4,178 @@ [net.bowmap.server.protocol.schema :as p] [net.bowmap.server.protocol.writers :refer :all])) -(defn ? [_] (throw (Exception. "Error while encoding packet: no packet definition for that packet id")))- (def clientbound-packets "Map of connection phases to pairs of [clientbound-packet-id writer]" {::phase/status [::status-response status-response-> ::pong-response [::p/timestamp long->]] ::phase/login- [::disconnect ?- ::encryption-request ?- ::login-success ?- ::set-compression ?- ::login-plugin-request ?- ::cookie-request ?]+ [::disconnect nil+ ::encryption-request nil+ ::login-success nil+ ::set-compression nil+ ::login-plugin-request nil+ ::cookie-request nil] ::phase/config- [::cookie-request ?- ::plugin-message ?- ::disconnect ?- ::finish-config ?- ::keep-alive ?- ::ping ?- ::reset-chat ?- ::registry-data ?- ::remove-resource-pack ?- ::add-resource-pack ?- ::store-cookie ?- ::transfer ?- ::feature-flags ?- ::update-tags ?- ::known-packs ?- ::custom-report-details ?- ::server-links ?- ::clear-dialog ?- ::show-dialog ?- ::code-of-conduct ?]+ [::cookie-request nil+ ::plugin-message nil+ ::disconnect nil+ ::finish-config nil+ ::keep-alive nil+ ::ping nil+ ::reset-chat nil+ ::registry-data nil+ ::remove-resource-pack nil+ ::add-resource-pack nil+ ::store-cookie nil+ ::transfer nil+ ::feature-flags nil+ ::update-tags nil+ ::known-packs nil+ ::custom-report-details nil+ ::server-links nil+ ::clear-dialog nil+ ::show-dialog nil+ ::code-of-conduct nil] ::phase/play- [::bundle-delimiter ?- ::spawn-entity ?- ::entity-animation ?- ::award-statistics ?- ::acknowledge-block-change ?- ::set-block-destroy-stage ?- ::block-entity-data ?- ::block-action ?- ::block-update ?- ::boss-bar ?- ::change-difficulty ?- ::chunk-batch-finished ?- ::chunk-batch-start ?- ::chunk-biomes ?- ::clear-titles ?- ::command-suggestions-response ?- ::commands ?- ::close-container ?- ::set-container-content ?- ::set-container-property ?- ::set-container-slot ?- ::cookie-request ?- ::set-cooldown ?- ::chat-suggestions ?- ::plugin-message ?- ::damage-event ?- ::debug-block-value ?- ::debug-chunk-value ?- ::debug-entity-value ?- ::debug-event ?- ::debug-sample ?- ::delete-message ?- ::disconnect ?- ::disguised-chat-message ?- ::entity-event ?- ::teleport-entity ?- ::explosion ?- ::unload-chunk ?- ::game-event ?- ::game-rule-values ?- ::game-test-highlight-position ?- ::open-horse-screen ?- ::hurt-animation ?- ::initialize-world-border ?- ::keep-alive ?- ::chunk-data-and-update-light ?- ::world-event ?- ::particle ?- ::update-light ?- ::login ?- ::low-disk-space-warning ?- ::map-data ?- ::merchant-offers ?- ::update-entity-position ?- ::update-entity-position-and-rotation ?- ::move-minecart-along-track ?- ::update-entity-rotation ?- ::move-vehicle ?- ::open-book ?- ::open-screen ?- ::open-sign-editor ?- ::ping ?- ::pong-response ?- ::place-ghost-recipe ?- ::player-abilities ?- ::player-chat-message ?- ::end-combat ?- ::enter-combat ?- ::combat-death ?- ::player-info-remove ?- ::player-info-update ?- ::look-at ?- ::synchronize-player-position ?- ::player-rotation ?- ::recipe-book-add ?- ::recipe-book-remove ?- ::recipe-book-settings ?- ::remove-entities ?- ::remove-entity-effect ?- ::reset-score ?- ::remove-resource-pack ?- ::add-resource-pack ?- ::respawn ?- ::set-head-rotation ?- ::update-section-blocks ?- ::select-advancements-tab ?- ::server-data ?- ::set-action-bar-text ?- ::set-border-center ?- ::set-border-lerp-size ?- ::set-border-size ?- ::set-border-warning-delay ?- ::set-border-warning-distance ?- ::set-camera ?- ::set-center-chunk ?- ::set-render-distance ?- ::set-cursor-item ?- ::set-default-spawn-position ?- ::display-objective ?- ::set-entity-metadata ?- ::link-entities ?- ::set-entity-velocity ?- ::set-equipment ?- ::set-experience ?- ::set-health ?- ::set-held-item ?- ::update-objectives ?- ::set-passengers ?- ::set-player-inventory-slot ?- ::update-teams ?- ::update-score ?- ::set-simulation-distance ?- ::set-subtitle-text ?- ::update-time ?- ::set-title-text ?- ::set-title-animation-times ?- ::entity-sound-effect ?- ::sound-effect ?- ::start-configuration ?- ::stop-sound ?- ::store-cookie ?- ::system-chat-message ?- ::set-tab-list-header-and-footer ?- ::tag-query-response ?- ::pickup-item ?- ::synchronize-vehicle-position ?- ::test-instance-block-status ?- ::set-ticking-state ?- ::step-tick ?- ::transfer ?- ::update-advancements ?- ::update-attributes ?- ::entity-effect ?- ::update-recipes ?- ::update-tags ?- ::projectile-power ?- ::custom-report-details ?- ::server-links ?- ::waypoint ?- ::clear-dialog ?- ::show-dialog-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+ ::unload-chunk nil+ ::game-event nil+ ::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 nil+ ::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+ ::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+ ::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]})src/net/bowmap/server/protocol/codec.clj view file
@@ -24,7 +24,9 @@ [{::phase/keys! [phase]} {::packet/keys! [id] :as packet}] (let [schemas (clientbound-packets phase) [numeric-id schema] (find-indexed id schemas)- payload-writer (writers/to-writer schema)]+ payload-writer (if (some? schema)+ (writers/to-writer schema)+ (throw (ex-info "No such packet with that id!" {:phase phase :numeric-id numeric-id})))] (length-prefixed (-> (frame) (writers/varint-> numeric-id)