Beispiel #1
0
func (rw *RegionWrapper) renderTile(chunk *mcmap.Chunk) (maptile, biotile *gdk.Pixmap, biocache []mcmap.Biome) {
	maptile = emptyPixmap(tileSize, tileSize, 24)
	mtDrawable := maptile.GetDrawable()
	mtGC := gdk.NewGC(mtDrawable)

	biotile = emptyPixmap(tileSize, tileSize, 24)
	btDrawable := biotile.GetDrawable()
	btGC := gdk.NewGC(btDrawable)

	biocache = make([]mcmap.Biome, mcmap.ChunkRectXZ)

	i := 0
	for z := 0; z < mcmap.ChunkSizeXZ; z++ {
	scanX:
		for x := 0; x < mcmap.ChunkSizeXZ; x++ {
			bio := chunk.Biome(x, z)
			btGC.SetRgbFgColor(rw.bioLookup.Color(bio))
			btDrawable.DrawRectangle(btGC, true, x*zoom, z*zoom, zoom, zoom)

			biocache[i] = bio
			i++

			for y := chunk.Height(x, z); y >= 0; y-- {
				if col, ok := blockColors[chunk.Block(x, y, z).ID]; ok {
					mtGC.SetRgbFgColor(col)
					mtDrawable.DrawRectangle(mtGC, true, x*zoom, z*zoom, zoom, zoom)
					continue scanX
				}
			}

			mtGC.SetRgbFgColor(gdk.NewColor("#ffffff"))
			mtDrawable.DrawRectangle(mtGC, true, x*zoom, z*zoom, zoom, zoom)
		}
	}

	return
}
Beispiel #2
0
func (rw *RegionWrapper) fixWeather(bio mcmap.Biome, bx, bz int, chunk *mcmap.Chunk) (newcol *gdk.Color) {
	snowLine := rw.bioLookup.SnowLine(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]
			} 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 {
			// Melt ice and remove snow cover
			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
}