93fc876
Branches > main > 93fc876 > files
Implement the location writer
Commit: 93fc87671073d8a3315a60758c6d8f940dc14fe7
Parent: 0065285
1 changed file:
src/net/bowmap/transport/writers.clj view file
@@ -3,9 +3,10 @@ When given bad data, write functions will throw. See https://minecraft.wiki/w/Java_Edition_protocol/Packets#Data_types" (:require- [clojure.spec.alpha :as s] [clojure.data.json :as json] [clojure.set :as set]+ [clojure.spec.alpha :as s]+ [net.bowmap.server.location :as location] [net.bowmap.transport.packet-types :as t]) (:import [io.netty.buffer ByteBuf CompositeByteBuf Unpooled]@@ -192,8 +193,12 @@ (def float-> ByteBuf/.writeFloat) (def double-> ByteBuf/.writeDouble) (def identifier-> string->)-(defn location-> [pos]- (throw (Exception. "YOU NEVER ACTUALLY IMPLEMENTED THE LOCATION TYPE REMEMBER?")))++(defn location-> [{::location/keys! [x y z]}]+ (bit-or+ (bit-shift-left (bit-and x 0x3FFFFFF) 38)+ (bit-shift-left (bit-and z 0x3FFFFFF) 12)+ (bit-and y 0xFFF))) (defn or-> [writer default] (fn [buf x]