packets.clj

Bowmap · bowmap.git · Tickets

Branches > main > 2c5e1ba > files / src / net / bowmap / server / runtime / packets.clj

(ns net.bowmap.server.runtime.packets
  (:require
   [net.bowmap.server.protocol.clientbound-packets :as clientbound]
   [net.bowmap.server.protocol.packet :as packet]
   [net.bowmap.server.protocol.phase :as phase]
   [net.bowmap.server.protocol.schema :as p]
   [net.bowmap.server.protocol.serverbound-packets :as serverbound]))

(defn apply-packet
  "'Applies' a serverbound packet to a client.
   Returns [client' [packet*]?]"
  [client packet]
  (let [{::packet/keys! [id]} packet]
    (case id
      ::serverbound/handshaking [(assoc client ::phase/phase (req! packet ::phase/phase))]
      ::serverbound/status-request [client [{::packet/id ::clientbound/status-response
                                             ::p/version-name "26.2"
                                             ::p/protocol 776}]]
      ::serverbound/login-acknowledged [(assoc client ::phase/phase ::phase/config)]
      ::serverbound/finish-config [(assoc client ::phase/phase ::phase/play)]
      [client])))