af0a324

Bowmap · bowmap.git · Tickets

Branches > main > af0a324 > files

Don't throw Errors when writing bad data

Grahp, 2026-10-12

Commit: af0a324a6f4a9c65025213151adeb057a2caca2b
Parent: d4a482d

1 changed file:

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

@@ -168,7 +168,6 @@ (def status-response> (apply> ->status-response json>))  (defn uuid> [buf uuid]-  {:pre [(uuid? uuid)]}   (-> buf       (long> (UUID/.getMostSignificantBits uuid))       (long> (UUID/.getLeastSignificantBits uuid))))@@ -219,14 +218,16 @@    bits for the x, 26 bits for the y, and 12 bits for the z. Throws if any    of the coordinates do not fit within their respective integer sizes."   [buf {::block/keys! [x y z]}]-  {:pre [(<= (Math/pow -2 25) x (- (Math/pow 2 25) 1))-         (<= (Math/pow -2 25) z (- (Math/pow 2 25) 1))-         (<= (Math/pow -2 11) y (- (Math/pow 2 11) 1))]}-  (long> buf-         (bit-or-           (bit-shift-left (bit-and x 0x3FFFFFF) 38)-           (bit-shift-left (bit-and z 0x3FFFFFF) 12)-           (bit-and y 0xFFF))))+  (if (and (<= (Math/pow -2 25) x (- (Math/pow 2 25) 1))+           (<= (Math/pow -2 25) z (- (Math/pow 2 25) 1))+           (<= (Math/pow -2 11) y (- (Math/pow 2 11) 1)))+    (long> buf+           (bit-or+             (bit-shift-left (bit-and x 0x3FFFFFF) 38)+             (bit-shift-left (bit-and z 0x3FFFFFF) 12)+             (bit-and y 0xFFF)))+    (throw (ex-info "Cannot write invalid block location."+                    {:x x :y y :z z}))))  (defn- name* [x]   (cond