summaryrefslogtreecommitdiff
path: root/server/coords.go
diff options
context:
space:
mode:
authorraven <citrons@mondecitronne.com>2026-03-20 14:29:52 -0500
committerraven <citrons@mondecitronne.com>2026-03-20 14:29:52 -0500
commitc3d63652a4b80add587ee17f5c9f3773417203ad (patch)
treee26e1d36f912f1bca210e1aaa3e314668d0b010b /server/coords.go
initial commit
Diffstat (limited to 'server/coords.go')
-rw-r--r--server/coords.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/server/coords.go b/server/coords.go
new file mode 100644
index 0000000..ebe71c9
--- /dev/null
+++ b/server/coords.go
@@ -0,0 +1,34 @@
+package server
+
+const playerHeight = 51
+const blockSize = 32
+
+type blockCoord int64
+type entityCoord int64
+
+type entityFacing struct {
+ Yaw, Pitch uint8
+}
+
+type blockPos struct {
+ X, Y, Z blockCoord
+}
+type entityPos struct {
+ X, Y, Z entityCoord
+}
+
+func entityToBlock(pos entityPos) blockPos {
+ return blockPos {
+ blockCoord(pos.X >> 5),
+ blockCoord(pos.Y >> 5),
+ blockCoord(pos.Z >> 5),
+ }
+}
+
+func blockToEntity(pos blockPos) entityPos {
+ return entityPos {
+ entityCoord(pos.X << 5),
+ entityCoord(pos.Y << 5),
+ entityCoord(pos.Z << 5),
+ }
+}