From c3d63652a4b80add587ee17f5c9f3773417203ad Mon Sep 17 00:00:00 2001 From: raven Date: Fri, 20 Mar 2026 14:29:52 -0500 Subject: initial commit --- server/coords.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 server/coords.go (limited to 'server/coords.go') 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), + } +} -- cgit v1.2.3