diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-08-17 22:37:12 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-08-17 22:37:12 +0200 |
commit | 428a21265c4600aa4d492b6e0252a5723180a91e (patch) | |
tree | a31917a89c324b12b7b1f483b57ba4f7353cf4d5 | |
parent | c15c92e507f37a476b29f391564b760c38f538a9 (diff) | |
download | biomed-428a21265c4600aa4d492b6e0252a5723180a91e.tar.gz biomed-428a21265c4600aa4d492b6e0252a5723180a91e.tar.bz2 biomed-428a21265c4600aa4d492b6e0252a5723180a91e.zip |
Tidied up Ice/Snow fixing.
-rw-r--r-- | mapwidget.go | 82 |
1 files changed, 50 insertions, 32 deletions
diff --git a/mapwidget.go b/mapwidget.go index 3592e42..0727038 100644 --- a/mapwidget.go +++ b/mapwidget.go @@ -478,6 +478,52 @@ func (mw *MapWidget) GetBiomeAt(x, z int) (mcmap.Biome, bool) { return chunk.Biome(bx, bz), true } +func fixFreeze(bx, bz int, chunk *mcmap.Chunk) (newcol *gdk.Color) { + for y := chunk.Height(bx, bz); y >= 0; y-- { + if blk := chunk.Block(bx, y, bz); blk.ID != mcmap.BlkAir { + if (blk.ID == mcmap.BlkStationaryWater) || (blk.ID == mcmap.BlkWater) { + blk.ID = mcmap.BlkIce + newcol = blockColors[mcmap.BlkIce] + } else if blockCanSnowIn[blk.ID] { + if yFix := y + 1; yFix < mcmap.ChunkSizeY { + blkFix := chunk.Block(bx, yFix, bz) + blkFix.ID = mcmap.BlkSnow + blkFix.Data = 0x0 + newcol = blockColors[mcmap.BlkSnow] + } + } + + break + } + } + + return +} + +func fixMelt(bx, bz int, chunk *mcmap.Chunk) (newcol *gdk.Color) { + for y := chunk.Height(bx, bz); y >= 0; y-- { + if blk := chunk.Block(bx, y, bz); blk.ID != mcmap.BlkAir { + if blk.ID == mcmap.BlkIce { + blk.ID = mcmap.BlkStationaryWater + blk.Data = 0x0 + newcol = blockColors[mcmap.BlkStationaryWater] + } else if blk.ID == mcmap.BlkSnow { + blk.ID = mcmap.BlkAir + for y2 := y - 1; y2 >= 0; y2-- { + if col, ok := blockColors[chunk.Block(bx, y2, bz).ID]; ok { + newcol = col + break + } + } + } + + break + } + } + + return +} + func (mw *MapWidget) SetBiomeAt(x, z int, bio mcmap.Biome) { cx, cz, bx, bz := mcmap.BlockToChunk(x, z) pos := XZPos{cx, cz} @@ -496,38 +542,10 @@ func (mw *MapWidget) SetBiomeAt(x, z int, bio mcmap.Biome) { var newcol *gdk.Color if mw.fixSnowIce { - for y := chunk.Height(bx, bz); y >= 0; y-- { - if blk := chunk.Block(bx, y, bz); blk.ID != mcmap.BlkAir { - if coldBiome[bio] { - if (blk.ID == mcmap.BlkStationaryWater) || (blk.ID == mcmap.BlkWater) { - blk.ID = mcmap.BlkIce - newcol = blockColors[mcmap.BlkIce] - } else if blockCanSnowIn[blk.ID] { - if yFix := y + 1; yFix < mcmap.ChunkSizeY { - blkFix := chunk.Block(bx, yFix, bz) - blkFix.ID = mcmap.BlkSnow - blkFix.Data = 0x0 - newcol = blockColors[mcmap.BlkSnow] - } - } - } else { - if blk.ID == mcmap.BlkIce { - blk.ID = mcmap.BlkStationaryWater - blk.Data = 0x0 - newcol = blockColors[mcmap.BlkStationaryWater] - } else if blk.ID == mcmap.BlkSnow { - blk.ID = mcmap.BlkAir - for y2 := y - 1; y2 >= 0; y2-- { - if col, ok := blockColors[chunk.Block(bx, y2, bz).ID]; ok { - newcol = col - break - } - } - } - } - - break - } + if coldBiome[bio] { + newcol = fixFreeze(bx, bz, chunk) + } else { + newcol = fixMelt(bx, bz, chunk) } } |