diff options
Diffstat (limited to 'server/coords.go')
| -rw-r--r-- | server/coords.go | 34 |
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), + } +} |
