diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-08-12 21:40:02 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-08-12 21:40:02 +0200 |
commit | 2263d599391cce82735f16f43b7907e8846cbb2a (patch) | |
tree | 1b02d46fd8b4a2c2de83a959c96530d161728289 /mcmap | |
parent | d9e1c3579e63cc0ab850ea3caa5324a0243150e2 (diff) | |
download | gomcmap-2263d599391cce82735f16f43b7907e8846cbb2a.tar.gz gomcmap-2263d599391cce82735f16f43b7907e8846cbb2a.tar.bz2 gomcmap-2263d599391cce82735f16f43b7907e8846cbb2a.zip |
Implemented height map recalculation
Diffstat (limited to 'mcmap')
-rw-r--r-- | mcmap/chunk.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/mcmap/chunk.go b/mcmap/chunk.go index 9cf2dc7..d11d24b 100644 --- a/mcmap/chunk.go +++ b/mcmap/chunk.go @@ -110,4 +110,22 @@ func (c *Chunk) SetBiome(x, z int, bio Biome) { c.biomes[x*ChunkSizeXZ+z] = bio // If the chunk was modified, call MarkModified BEFORE. func (c *Chunk) MarkUnused() error { return c.reg.unloadChunk(int(c.x), int(c.z)) } -// TODO: func (c *Chunk) RecalcHeightMap() +// RecalcHeightMap recalculates the internal height map. +// +// You should use this function before marking the chunk as unused, if you modified the chunk +// (unless you know, your changes wouldn't affect the height map). +func (c *Chunk) RecalcHeightMap() { + i := 0 + for z := 0; z < ChunkSizeXZ; z++ { + for x := 0; x < ChunkSizeXZ; x++ { + for y := ChunkSizeY; y >= 0; y-- { + blkid := c.blocks[calcBlockOffset(x, y, z)].ID + if (blkid != BlkAir) && (blkid != BlkGlass) && (blkid != BlkGlassPane) { + c.heightMap[i] = int32(y) + break + } + } + i++ + } + } +} |