blob: 7add606a39c299d13652a369e5df263cec13cedd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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 fromFloat(f float64) entityCoord {
return entityCoord(f * 32)
}
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),
}
}
|