mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
sandstone generation follows the world's sand colour
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user