Track and update tile entities

This commit is contained in:
Tom
2020-09-20 17:11:18 -07:00
parent 52f30dc402
commit a46acaa064
5 changed files with 123 additions and 6 deletions

21
bot/world/tile.go Normal file
View 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))
}