forked from quag/mcobj
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsides.go
More file actions
39 lines (30 loc) · 660 Bytes
/
sides.go
File metadata and controls
39 lines (30 loc) · 660 Bytes
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
39
package main
var (
emptySide ChunkSide
solidSide ChunkSide
defaultSide *ChunkSide
)
func init() {
for i, _ := range solidSide {
solidSide[i] = 1
}
defaultSide = &solidSide
}
type ChunkSide [128 * 16]uint16
type ChunkSides [4]*ChunkSide
func (s *ChunkSides) Side(i int) *ChunkSide {
return (*s)[i]
}
func (s *ChunkSide) Index(x, y int) int {
return y + (x * 128)
}
func (s *ChunkSide) BlockId(x, y int) uint16 {
return (*s)[s.Index(x, y)]
}
func (s *ChunkSide) Column(x int) BlockColumn {
var i = 128 * x
return BlockColumn((*s)[i : i+128])
}
func (s *ChunkSide) SetBlockId(x, y int, blockId uint16) {
(*s)[s.Index(x, y)] = blockId
}