Track and update tile entities
This commit is contained in:
21
bot/world/tile.go
Normal file
21
bot/world/tile.go
Normal file
@ -0,0 +1,21 @@
|
||||
package world
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// TilePosition describes the location of a tile/block entity within a chunk.
|
||||
type TilePosition uint32
|
||||
|
||||
func (p TilePosition) Pos() (x, y, z int) {
|
||||
return int((p>>8) & 0xff), int((p>>16) & 0xff), int(p&0xff)
|
||||
}
|
||||
|
||||
func (p TilePosition) String() string {
|
||||
x, y, z := p.Pos()
|
||||
return fmt.Sprintf("(%d, %d, %d)", x, y, z)
|
||||
}
|
||||
|
||||
func ToTilePos(x, y, z int) TilePosition {
|
||||
return TilePosition((y&0xff) << 16 | (x&15) << 8 | (z&15))
|
||||
}
|
Reference in New Issue
Block a user