sandstone generation follows the world's sand colour

This commit is contained in:
minjaesong
2024-09-26 14:16:19 +09:00
parent da4a850ee9
commit 6e1d3c3bb7
2 changed files with 26 additions and 9 deletions

View File

@@ -26,14 +26,7 @@ class Biomegen(world: GameWorld, isFinal: Boolean, seed: Long, params: Any, val
private val THISWORLD_SANDSTONE: ItemID
init {
val SAND_RND = (seed shake "SANDYCOLOURS").ushr(7).xor(seed and 255L).and(255L).toInt()
val SAND_BASE = when (SAND_RND) {
255 -> 5 // green
in 252..254 -> 4 // black
in 245..251 -> 2 // red
in 230..244 -> 1 // white
else -> 0
}
val SAND_BASE = getSandVariation(seed)
THISWORLD_SAND = "basegame:" + (Block.SAND.substringAfter(':').toInt() + SAND_BASE)
THISWORLD_SANDSTONE = "basegame:" + (Block.SANDSTONE.substringAfter(':').toInt() + SAND_BASE)
}
@@ -54,6 +47,19 @@ class Biomegen(world: GameWorld, isFinal: Boolean, seed: Long, params: Any, val
}
companion object {
fun getSandVariation(seed: Long): Int {
val SAND_RND = (seed shake "SANDYCOLOURS").ushr(7).xor(seed and 255L).and(255L).toInt()
val SAND_BASE = when (SAND_RND) {
255 -> 5 // green
in 252..254 -> 4 // black
in 245..251 -> 2 // red
in 230..244 -> 1 // white
else -> 0
}
return SAND_BASE
}
private const val slices = 5
private val nearbyArr8 = arrayOf(
(-1 to -1), // tileTL

View File

@@ -7,6 +7,7 @@ import net.torvald.terrarum.LoadScreenBase
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.modulebasegame.worldgenerator.Biomegen.Companion.getSandVariation
import net.torvald.terrarum.realestate.LandUtil.CHUNK_H
import net.torvald.terrarum.realestate.LandUtil.CHUNK_W
import kotlin.math.cos
@@ -30,8 +31,13 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu
else
(world.height / 2400.0).pow(0.75)
private val THISWORLD_SANDSTONE: ItemID
init {
populateCaches(seed)
val SAND_BASE = getSandVariation(seed)
THISWORLD_SANDSTONE = "basegame:" + (Block.SANDSTONE.substringAfter(':').toInt() + SAND_BASE)
}
override fun getDone(loadscreen: LoadScreenBase?) {
@@ -88,9 +94,14 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu
val isMarble = if (!isAlpha2) noiseValue[1] > 0.5 else false
val block = if (isMarble) Block.STONE_MARBLE else groundDepthBlocksCache[strataMode][terrTier]
var block = if (isMarble) Block.STONE_MARBLE else groundDepthBlocksCache[strataMode][terrTier]
//groundDepthBlocksCache[strataMode][terr]
// recolour the sandstone
if (block == Block.SANDSTONE) {
block = THISWORLD_SANDSTONE
}
world.setTileTerrain(x, y, block, true)
world.setTileWall(x, y, block, true)
}