go generate ./... && go fmt ./...

This commit is contained in:
Tnze
2021-01-09 13:25:51 +08:00
parent 8bc0d5d0e3
commit 0e959dfbc0
124 changed files with 1293 additions and 1278 deletions

View File

@ -1,21 +1,21 @@
package world
import (
"fmt"
"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)
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)
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))
return TilePosition((y&0xff)<<16 | (x&15)<<8 | (z & 15))
}