diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-08-12 15:44:06 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-08-12 15:44:06 +0200 |
commit | f194b131e0cac55d1937e75c98edf62ba04e1df4 (patch) | |
tree | f2f762f1d5d7038bfe95b2a9e8a5bedbef5575cd /mcmap/chunk.go | |
parent | bb8ddfbc5574a7682594fd15178083f5308766e7 (diff) | |
download | gomcmap-f194b131e0cac55d1937e75c98edf62ba04e1df4.tar.gz gomcmap-f194b131e0cac55d1937e75c98edf62ba04e1df4.tar.bz2 gomcmap-f194b131e0cac55d1937e75c98edf62ba04e1df4.zip |
Added Iter function to Chunk
Diffstat (limited to 'mcmap/chunk.go')
-rw-r--r-- | mcmap/chunk.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mcmap/chunk.go b/mcmap/chunk.go index 3241d82..9cf2dc7 100644 --- a/mcmap/chunk.go +++ b/mcmap/chunk.go @@ -86,6 +86,17 @@ func (c *Chunk) Height(x, z int) int { return int(c.heightMap[z*ChunkSizeXZ+x]) } +// Iter iterates ofer all blocks of this chunk and calls the function fx with the coords (x,y,z) and a pointer to the block. +func (c *Chunk) Iter(fx func(int, int, int, *Block)) { + for x := 0; x < ChunkSizeXZ; x++ { + for y := 0; y < ChunkSizeY; y++ { + for z := 0; z < ChunkSizeXZ; z++ { + fx(x, y, z, &(c.blocks[calcBlockOffset(x, y, z)])) + } + } + } +} + // Biome gets the Biome at x,z. func (c *Chunk) Biome(x, z int) Biome { return c.biomes[x*ChunkSizeXZ+z] } |