77bc4d7

Branches > main > 77bc4d7 > files / src / net / bowmap / network

Rename position reader to location

Grahp, 2026-08-20

Commit: 77bc4d7a1ac107f24f67c1ccd9f8b0eefa0c8632
Parent: 4a76ca7

3 changed files:

src/net/bowmap/network/packets/readers.clj modified (view file)

@@ -4,7 +4,8 @@    See https://minecraft.wiki/w/Java_Edition_protocol/Packets#Data_types"   (:require    [clojure.spec.alpha :as s]-   [net.bowmap.network.packets.types :as t])+   [net.bowmap.network.packets.types :as t]+   [net.bowmap.server.location :as location])   (:import    [io.netty.buffer ByteBuf]    [java.nio.charset Charset]@@ -81,12 +82,12 @@     (fn [buf]       (read-bit-mask! buf reader mask)))) -(defn ->position [buf]+(defn ->location [buf]   (let [v (ByteBuf/.readLong buf)         x (bit-shift-right v 38)         y (bit-shift-right (bit-shift-left v 52) 52)         z (bit-shift-right (bit-shift-left v 26) 38)]-    {:x x :y y :z z}))+    #::location{:x x :y y :z z}))  ;; TODO untested! (defn- read-array [reader buf length]

src/net/bowmap/network/packets/serverbound.clj modified (view file)

@@ -3,7 +3,7 @@    [net.bowmap.network.packet :as pk]    [net.bowmap.network.packets.readers     :refer [->bit-mask ->boolean ->byte ->double ->enum ->float ->identifier-            ->int ->list ->long ->optional ->position ->short ->string ->ubyte+            ->int ->list ->long ->optional ->location ->short ->string ->ubyte             ->uuid ->varint coerce]]    [net.bowmap.network.state :as state])) @@ -204,7 +204,7 @@    ::player-action [:status (->enum ->varint [:started-digging :canceled-digging :finished-digging                                               :drop-item-stack :drop-item :update-item-state :swap-item-in-hand])                     ; TODO aren't positions and locations different things?-                    :location ->position+                    :location ->location                     ; TODO block face might be something logical                     :face (->enum ->byte [:bottom :top :north :south :west :east])                     :sequence ->varint]

src/net/bowmap/server/location.clj added (view file)

@@ -0,0 +1,7 @@+(ns net.bowmap.server.location+  (:require+   [clojure.spec.alpha :as s]))++(s/def ::x integer?)+(s/def ::y integer?)+(s/def ::z integer?)