4ef4505

Branches > refactor/use-spec-1 > 4ef4505 > files / deps.edn

Join into the world and everything that goes along with that idk it was a lot but lfg

Grahp, 2026-03-08

Commit: 4ef450544a7d63442b8f491acf406054136a6cc6
Parent: c9b29ed

4 changed files:

src/net/bowmap/packet/client.clj modified (view file)

@@ -243,7 +243,10 @@               :death-location [:context-optional :position]               :portal-cooldown :varint               :sea-level :varint-              :enforce-secure-chat? :boolean]}))+              :enforce-secure-chat? :boolean]+     ;; And others too but we don't talk about those+     ::game-event [:event [:enum :byte {3 :set-gamemode 13 :wait-for-chunks}]+                   :value [:or :float 0]]}))  (defn numeric-id [state id]   (packet-ids {::state/state state ::pk/id id}))

src/net/bowmap/packet/server.clj modified (view file)

@@ -137,7 +137,8 @@      ::client-information []      ::known-packs []      ::finish-config []-     ::keep-alive [:id :long]}))+     ::keep-alive [:id :long]+     ::client-tick-end []}))  #_"Decodes and returns one packet from ByteBuf 'buf', which should contain at least one readable packet.    The initial length field of the packet should not be stripped from 'buf'.

src/net/bowmap/packet/write.clj modified (view file)

@@ -2,14 +2,15 @@   "Functions to write Minecraft protocol types.    See https://minecraft.wiki/w/Java_Edition_protocol/Packets#Data_types"   (:require-    [clojure.alpha.spec :as s]-    [clojure.data.json :as json]-    [dev.grahp.error :refer [raise]]-    [net.bowmap.packet.types :as t])+   [clojure.alpha.spec :as s]+   [clojure.data.json :as json]+   [clojure.set :as set]+   [dev.grahp.error :refer [raise]]+   [net.bowmap.packet.types :as t])   (:import-    [io.netty.buffer ByteBuf]-    [java.nio.charset Charset]-    [java.util UUID]))+   [io.netty.buffer ByteBuf]+   [java.nio.charset Charset]+   [java.util UUID]))  (defn write-varint! [buf n]   (loop [buf buf@@ -48,7 +49,7 @@             (try               (codec acc (get m field))               (catch Throwable e-                (raise "Error while encoding packet field" {:field field :map m} e))))+                (raise "Error while encoding packet field" {:field field :value (get m field)} e))))           buf codec-fields))  (declare writers)@@ -131,7 +132,7 @@         (ByteBuf/.writeInt (count xs))         (write-array! encoder xs)))) -(defn >nbt-compound [buf m]+(defn write-nbt-compound! [buf m]   (-> (reduce (fn [acc [k v]]                 (let [t (nbt-type v)]                   (-> acc@@ -161,7 +162,7 @@                   :double ByteBuf/.writeDouble                   :string write-nbt-string!                   :list write-nbt-list!-                  :compound >nbt-compound})+                  :compound write-nbt-compound!})  (def nbt-ids {:byte 1               :boolean 1@@ -188,6 +189,8 @@    :ushort ByteBuf/.writeShort    :int    ByteBuf/.writeInt    :long   ByteBuf/.writeLong+   :float  ByteBuf/.writeFloat+   :double ByteBuf/.writeLong    :varint write-varint!    :string write-string!    :json   write-json!@@ -197,8 +200,17 @@     :nbt write-nbt! +   :or (fn [t default]+         (fn [buf x]+           (println "uh x is:" x)+           (let [x (if (nil? x) default x)]+             ((writer t) buf x))))++   ;; TODO what actually happens when the value is nil?    :enum (fn [t m]-           (fn [buf x] (write-enum! buf (writer t) m x)))+           (let [m (set/map-invert m)]+             (fn [buf x]+               (write-enum! buf (writer t) m x))))     :position (fn [t pos] (raise "YOU NEVER ACTUALLY IMPLEMENTED THE POSITION TYPE REMEMBER?")) 

src/net/bowmap/packet_handling.clj modified (view file)

@@ -54,4 +54,27 @@                    {::pk/id ::cp/finish-config})})  (defmethod handle-packet ::sp/finish-config [pk client]-  {:client (assoc client ::state/state ::state/play)})+  {:client (assoc client ::state/state ::state/play)+   :response [{::pk/id ::cp/login+              :entity-id 0 ;; TODO magic zero :p+              :hardcore? false+              :dimension-names ["world"]+              :max-players 1000+              :view-distance 32+              :simulation-distance 32+              :reduced-debug-info? false+              :enable-respawn-screen? false+              :do-limited-crafting? false+              :dimension-type-id 0+              :dimension-name "world"+              :hashed-seed 203894+              :gamemode :creative+              :previous-gamemode :unknown+              :debug-world? false+              :superflat-world? true+              :has-death-location? false+              :portal-cooldown 10+              :sea-level 60+              :enforce-secure-chat? true}+              {::pk/id ::cp/game-event+               :event :wait-for-chunks}]})