925e7cd
Branches > main > 925e7cd > files
Remove packet.packet
Commit: 925e7cd500ce680f7888405359940ad75d4f621c
Parent: 03475ae
6 changed files:
src/net/bowmap/server/game/handle.clj view file
@@ -8,7 +8,6 @@ [net.bowmap.server.packet.component :as component] [net.bowmap.server.packet.entity :as entity] [net.bowmap.server.packet.gamemode :as gamemode]- [net.bowmap.server.packet.packet :as packet] [net.bowmap.server.packet.registry :as registry] [net.bowmap.server.packet.schema :as p] [net.bowmap.server.packet.schema.minecraft :as mc]@@ -19,13 +18,13 @@ state, and returns a vector of nil or a state value, followed by 0 or more response packets." (fn [state connection-uuid packet]- (::packet/id packet)))+ (::p/id packet))) (defmethod handle-packet :default [_ _ _]) (defmethod handle-packet ::serverbound/status-request [state _ _] [nil- {::packet/id ::clientbound/status-response+ {::p/id ::clientbound/status-response ::p/version-name "26.3" ::p/protocol 777 ::p/motd {::component/text "Bowmap!"@@ -35,7 +34,7 @@ (defmethod handle-packet ::serverbound/ping-request [_ _ {::p/keys! [timestamp]}] [nil- {::packet/id ::clientbound/pong-response+ {::p/id ::clientbound/pong-response ::p/timestamp timestamp}]) (defmethod handle-packet ::serverbound/login-start [state connection-uuid {::p/keys! [uuid username]}]@@ -44,7 +43,7 @@ {::player/uuid uuid ::player/username username ::connection/connection-uuid connection-uuid}])- {::packet/id ::clientbound/login-success+ {::p/id ::clientbound/login-success ::p/game-profile {::p/uuid uuid ::p/username username ::p/game-profile-properties []}@@ -52,14 +51,14 @@ (defmethod handle-packet ::serverbound/login-acknowledged [_ _ _] [nil- {::packet/id ::clientbound/known-packs+ {::p/id ::clientbound/known-packs ::p/known-packs [registry/core-data-pack]}]) (defmethod handle-packet ::serverbound/known-packs [state _ {::p/keys! [known-packs]}] (if (= [registry/core-data-pack] known-packs) (cons state (conj registry/registry-packets- {::packet/id ::clientbound/finish-config}))+ {::p/id ::clientbound/finish-config})) (throw (ex-info "Client does not support the core datapack" {:known-packs known-packs})))) @@ -70,7 +69,7 @@ {::server/playing? true ::entity/id entity-id} [= ::connection/connection-uuid connection-uuid]])- {::packet/id ::clientbound/login+ {::p/id ::clientbound/login ::entity/id entity-id :dimensions [registry/world-dimension] ::p/max-player-count server/max-player-count@@ -84,5 +83,5 @@ :portal-cooldown-ticks 0 :sea-level 60 :enforce-secure-chat? true}- {::packet/id ::clientbound/game-event+ {::p/id ::clientbound/game-event ::p/game-event-id ::p/wait-for-chunk-event}]))src/net/bowmap/server/packet/packet.clj view file
@@ -1,12 +0,0 @@-(ns net.bowmap.server.packet.packet- "A Minecraft protocol packet sent either to the server (serverbound),- or to the client (clientbound).- See https://minecraft.wiki/w/Java_Edition_protocol/Packets"- (:require- [clojure.set :as set]- [clojure.spec.alpha :as s]- [net.bowmap.server.packet.clientbound :as clientbound]- [net.bowmap.server.packet.serverbound :as serverbound]))--(s/def ::id (set/union clientbound/ids serverbound/ids))-(s/def ::packet (s/keys :opt [::id]))src/net/bowmap/server/packet/registry.clj view file
@@ -7,7 +7,6 @@ [clojure.spec.alpha :as s] [net.bowmap.server.packet.clientbound :as clientbound] [net.bowmap.server.packet.identifier :as identifier]- [net.bowmap.server.packet.packet :as packet] [net.bowmap.server.packet.schema :as p] [net.bowmap.server.packet.schema.bowmap :as bowmap] [net.bowmap.server.packet.schema.minecraft :as mc]@@ -309,7 +308,7 @@ (let [registry-packets (for [[registry-id entries] registry]- {::packet/id ::clientbound/registry-data+ {::p/id ::clientbound/registry-data ::p/registry-id registry-id ::p/registry-entries (for [[value] (sort-by val (req! registry-values->ids registry-id))]@@ -318,7 +317,7 @@ tag-packets (for [[registry tags] tags]- {::packet/id ::clientbound/update-tags+ {::p/id ::clientbound/update-tags ::p/tagged-registries [{::p/registry-id registry ::p/tags (for [tag-name tags]src/net/bowmap/server/packet/schema.clj view file
@@ -4,6 +4,9 @@ [net.bowmap.server.packet.identifier :refer [identifier?]] [net.bowmap.server.packet.nbt :as nbt])) +(s/def ::id qualified-keyword?)+(s/def ::packet (s/keys :opt [::id]))+ (s/def ::identifier identifier?) (s/def ::registry-id ::identifier)src/net/bowmap/server/packet/serialize.clj view file
@@ -2,9 +2,9 @@ (:require [net.bowmap.server.packet.clientbound :as clientbound] [net.bowmap.server.packet.frame :as frame]- [net.bowmap.server.packet.packet :as packet] [net.bowmap.server.packet.phase :as phase] [net.bowmap.server.packet.readers :as readers]+ [net.bowmap.server.packet.schema :as p] [net.bowmap.server.packet.serverbound :as serverbound] [net.bowmap.server.packet.writers :as writers]) (:import@@ -13,7 +13,7 @@ (defn encode-packet "Encodes a packet into a frame. Throws when the packet cannot be encoded."- [{::phase/keys! [phase]} {::packet/keys! [id] :as packet}]+ [{::phase/keys! [phase]} {::p/keys! [id] :as packet}] (let [numeric-id (req! (clientbound/phase->id->numeric-id phase) id) writer (req! (clientbound/phase->id->writer phase) id)] (frame/ByteBuf->frame@@ -31,4 +31,4 @@ reader (id (serverbound/phase->id->reader phase))] (assoc (when reader (reader buf))- ::packet/id id)))+ ::p/id id)))src/net/bowmap/server/runtime/connections.clj view file
@@ -5,15 +5,15 @@ [net.bowmap.server.game.server :as state] [net.bowmap.server.network.connection :as connection] [net.bowmap.server.network.server :as server]- [net.bowmap.server.packet.packet :as packet]- [net.bowmap.server.packet.serialize :as serialize] [net.bowmap.server.packet.phase :as phase]+ [net.bowmap.server.packet.schema :as p]+ [net.bowmap.server.packet.serialize :as serialize] [net.bowmap.server.packet.serverbound :as serverbound])) (defn apply-packet "Returns the value a client should take on when handling 'packet'." [client packet]- (let [{::packet/keys! [id]} packet]+ (let [{::p/keys! [id]} packet] (case id ::serverbound/handshaking (assoc client ::phase/phase (req! packet ::phase/phase)) ::serverbound/login-acknowledged (assoc client ::phase/phase ::phase/config)