summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--biome_infos.go131
-rw-r--r--region_wrapper.go38
2 files changed, 83 insertions, 86 deletions
diff --git a/biome_infos.go b/biome_infos.go
index 8e42b47..c45294c 100644
--- a/biome_infos.go
+++ b/biome_infos.go
@@ -137,69 +137,70 @@ var bioColors = map[mcmap.Biome]*gdk.Color{
mcmap.BioUncalculated: gdk.NewColor("#333333"),
}
-// TODO: Minecraft 1.7 will let it snow in some medium-cold biomes, depending on the height. We should simulate that.
-var coldBiome = map[mcmap.Biome]bool{
- mcmap.BioOcean: false,
- mcmap.BioPlains: false,
- mcmap.BioDesert: false,
- mcmap.BioExtremeHills: false,
- mcmap.BioForest: false,
- mcmap.BioTaiga: false,
- mcmap.BioSwampland: false,
- mcmap.BioRiver: false,
- mcmap.BioHell: false,
- mcmap.BioSky: false,
- mcmap.BioFrozenOcean: true,
- mcmap.BioFrozenRiver: true,
- mcmap.BioIcePlains: true,
- mcmap.BioIceMountains: true,
- mcmap.BioMushroomIsland: false,
- mcmap.BioMushroomIslandShore: false,
- mcmap.BioBeach: false,
- mcmap.BioDesertHills: false,
- mcmap.BioForestHills: false,
- mcmap.BioTaigaHills: true,
- mcmap.BioExtremeHillsEdge: false,
- mcmap.BioJungle: false,
- mcmap.BioJungleHills: false,
- mcmap.BioJungleEdge: false,
- mcmap.BioDeepOcean: false,
- mcmap.BioStoneBeach: false,
- mcmap.BioColdBeach: true,
- mcmap.BioBirchForest: false,
- mcmap.BioBirchForestHills: false,
- mcmap.BioRoofedForest: false,
- mcmap.BioColdTaiga: true,
- mcmap.BioColdTaigaHills: true,
- mcmap.BioMegaTaiga: false,
- mcmap.BioMegaTaigaHills: false,
- mcmap.BioExtremeHillsPlus: false,
- mcmap.BioSavanna: false,
- mcmap.BioSavannaPlateau: false,
- mcmap.BioMesa: false,
- mcmap.BioMesaPlateauF: false,
- mcmap.BioMesaPlateau: false,
- mcmap.BioSunflowerPlains: false,
- mcmap.BioDesertM: false,
- mcmap.BioExtremeHillsM: false,
- mcmap.BioFlowerForest: false,
- mcmap.BioTaigaM: false,
- mcmap.BioSwamplandM: false,
- mcmap.BioIcePlainsSpikes: true,
- mcmap.BioIceMountainsSpikes: true,
- mcmap.BioJungleM: false,
- mcmap.BioJungleEdgeM: false,
- mcmap.BioBirchForestM: false,
- mcmap.BioBirchForestHillsM: false,
- mcmap.BioRoofedForestM: false,
- mcmap.BioColdTaigaM: true,
- mcmap.BioMegaSpruceTaiga: false,
- mcmap.BioMegaSpruceTaigaHills: false,
- mcmap.BioExtremeHillsPlusM: false,
- mcmap.BioSavannaM: false,
- mcmap.BioSavannaPlateauM: false,
- mcmap.BioMesaBryce: false,
- mcmap.BioMesaPlateauFM: false,
- mcmap.BioMesaPlateauM: false,
- mcmap.BioUncalculated: false,
+// snowLines maps a biome to the lowest y coordinate that can have snow naturally.
+// TODO: Get the actual values that Minecraft uses (could not find them).
+var snowLines = map[mcmap.Biome]int{
+ mcmap.BioOcean: mcmap.ChunkSizeY,
+ mcmap.BioPlains: mcmap.ChunkSizeY,
+ mcmap.BioDesert: mcmap.ChunkSizeY,
+ mcmap.BioExtremeHills: 95,
+ mcmap.BioForest: mcmap.ChunkSizeY,
+ mcmap.BioTaiga: mcmap.ChunkSizeY,
+ mcmap.BioSwampland: mcmap.ChunkSizeY,
+ mcmap.BioRiver: mcmap.ChunkSizeY,
+ mcmap.BioHell: mcmap.ChunkSizeY,
+ mcmap.BioSky: mcmap.ChunkSizeY,
+ mcmap.BioFrozenOcean: 0,
+ mcmap.BioFrozenRiver: 0,
+ mcmap.BioIcePlains: 0,
+ mcmap.BioIceMountains: 0,
+ mcmap.BioMushroomIsland: mcmap.ChunkSizeY,
+ mcmap.BioMushroomIslandShore: mcmap.ChunkSizeY,
+ mcmap.BioBeach: mcmap.ChunkSizeY,
+ mcmap.BioDesertHills: mcmap.ChunkSizeY,
+ mcmap.BioForestHills: mcmap.ChunkSizeY,
+ mcmap.BioTaigaHills: 0,
+ mcmap.BioExtremeHillsEdge: 95,
+ mcmap.BioJungle: mcmap.ChunkSizeY,
+ mcmap.BioJungleHills: mcmap.ChunkSizeY,
+ mcmap.BioJungleEdge: mcmap.ChunkSizeY,
+ mcmap.BioDeepOcean: mcmap.ChunkSizeY,
+ mcmap.BioStoneBeach: mcmap.ChunkSizeY,
+ mcmap.BioColdBeach: 0,
+ mcmap.BioBirchForest: mcmap.ChunkSizeY,
+ mcmap.BioBirchForestHills: mcmap.ChunkSizeY,
+ mcmap.BioRoofedForest: mcmap.ChunkSizeY,
+ mcmap.BioColdTaiga: 0,
+ mcmap.BioColdTaigaHills: 0,
+ mcmap.BioMegaTaiga: mcmap.ChunkSizeY,
+ mcmap.BioMegaTaigaHills: mcmap.ChunkSizeY,
+ mcmap.BioExtremeHillsPlus: 95,
+ mcmap.BioSavanna: mcmap.ChunkSizeY,
+ mcmap.BioSavannaPlateau: mcmap.ChunkSizeY,
+ mcmap.BioMesa: mcmap.ChunkSizeY,
+ mcmap.BioMesaPlateauF: mcmap.ChunkSizeY,
+ mcmap.BioMesaPlateau: mcmap.ChunkSizeY,
+ mcmap.BioSunflowerPlains: mcmap.ChunkSizeY,
+ mcmap.BioDesertM: mcmap.ChunkSizeY,
+ mcmap.BioExtremeHillsM: 95,
+ mcmap.BioFlowerForest: mcmap.ChunkSizeY,
+ mcmap.BioTaigaM: mcmap.ChunkSizeY,
+ mcmap.BioSwamplandM: mcmap.ChunkSizeY,
+ mcmap.BioIcePlainsSpikes: 0,
+ mcmap.BioIceMountainsSpikes: 0,
+ mcmap.BioJungleM: mcmap.ChunkSizeY,
+ mcmap.BioJungleEdgeM: mcmap.ChunkSizeY,
+ mcmap.BioBirchForestM: mcmap.ChunkSizeY,
+ mcmap.BioBirchForestHillsM: mcmap.ChunkSizeY,
+ mcmap.BioRoofedForestM: mcmap.ChunkSizeY,
+ mcmap.BioColdTaigaM: 0,
+ mcmap.BioMegaSpruceTaiga: mcmap.ChunkSizeY,
+ mcmap.BioMegaSpruceTaigaHills: mcmap.ChunkSizeY,
+ mcmap.BioExtremeHillsPlusM: 95,
+ mcmap.BioSavannaM: mcmap.ChunkSizeY,
+ mcmap.BioSavannaPlateauM: mcmap.ChunkSizeY,
+ mcmap.BioMesaBryce: mcmap.ChunkSizeY,
+ mcmap.BioMesaPlateauFM: mcmap.ChunkSizeY,
+ mcmap.BioMesaPlateauM: mcmap.ChunkSizeY,
+ mcmap.BioUncalculated: mcmap.ChunkSizeY,
}
diff --git a/region_wrapper.go b/region_wrapper.go
index 2f8abe4..bf23913 100644
--- a/region_wrapper.go
+++ b/region_wrapper.go
@@ -242,9 +242,18 @@ func (rw *RegionWrapper) 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 := mcmap.ChunkSizeY - 1; y >= 0; y-- {
- if blk := chunk.Block(bx, y, bz); blk.ID != mcmap.BlkAir {
+func fixWeather(bio mcmap.Biome, bx, bz int, chunk *mcmap.Chunk) (newcol *gdk.Color) {
+ snowLine := snowLines[bio]
+
+ for y := mcmap.ChunkSizeY; y >= 0; y-- {
+ blk := chunk.Block(bx, y, bz)
+
+ if blk.ID == mcmap.BlkAir {
+ continue
+ }
+
+ if y >= snowLine {
+ // Freeze water and cover blocks with snow
if (blk.ID == mcmap.BlkStationaryWater) || (blk.ID == mcmap.BlkWater) {
blk.ID = mcmap.BlkIce
newcol = blockColors[mcmap.BlkIce]
@@ -256,17 +265,8 @@ func fixFreeze(bx, bz int, chunk *mcmap.Chunk) (newcol *gdk.Color) {
newcol = blockColors[mcmap.BlkSnow]
}
}
-
- break
- }
- }
-
- return
-}
-
-func fixMelt(bx, bz int, chunk *mcmap.Chunk) (newcol *gdk.Color) {
- for y := mcmap.ChunkSizeY - 1; y >= 0; y-- {
- if blk := chunk.Block(bx, y, bz); blk.ID != mcmap.BlkAir {
+ } else {
+ // Melt ice and remove snow cover
if blk.ID == mcmap.BlkIce {
blk.ID = mcmap.BlkStationaryWater
blk.Data = 0x0
@@ -280,9 +280,9 @@ func fixMelt(bx, bz int, chunk *mcmap.Chunk) (newcol *gdk.Color) {
}
}
}
-
- break
}
+
+ break
}
return
@@ -306,11 +306,7 @@ func (rw *RegionWrapper) SetBiomeAt(x, z int, bio mcmap.Biome) {
var newcol *gdk.Color
if rw.fixSnowIce {
- if coldBiome[bio] {
- newcol = fixFreeze(bx, bz, chunk)
- } else {
- newcol = fixMelt(bx, bz, chunk)
- }
+ newcol = fixWeather(bio, bx, bz, chunk)
}
chunk.MarkModified()