fix: tile randomiser breaks on world seam again

This commit is contained in:
minjaesong
2023-11-11 12:17:25 +09:00
parent 5fcaec2c74
commit 6291c799cf
3 changed files with 14 additions and 2 deletions

View File

@@ -34,7 +34,10 @@ class OregenAutotiling(world: GameWorld, seed: Long, val tilingModes: HashMap<It
Worldgen.threadExecutor.join()
}
private fun getHashCoord(x: Int, y: Int, mod: Int) = (XXHash64.hash(LandUtil.getBlockAddr(world, x, y).toBig64(), ((x*16777619) xor (y+1073)).toLong()) fmod mod.toLong()).toInt()
private fun getHashCoord(x: Int, y: Int, mod: Int): Int {
val (x, y) = world.coerceXY(x, y)
return (XXHash64.hash(LandUtil.getBlockAddr(world, x, y).toBig64(), ((x*16777619) xor (y+1073)).toLong()) fmod mod.toLong()).toInt()
}
private fun draw(x: Int) {
for (y in 0 until world.height) {

View File

@@ -0,0 +1,6 @@
package net.torvald.terrarum.modulebasegame.worldgenerator
/**
* Created by minjaesong on 2023-11-10.
*/class Treegen {
}

View File

@@ -307,7 +307,10 @@ internal object BlocksDrawer {
}
private fun getHashCoord(x: Int, y: Int, mod: Int, layer: Int) = (XXHash64.hash(LandUtil.getBlockAddr(world, x, y).toBig64(), ((x*16777619) xor (y+1+layer)).toLong()) fmod mod.toLong()).toInt()
private fun getHashCoord(x: Int, y: Int, mod: Int, layer: Int): Int {
val (x, y) = world.coerceXY(x, y)
return (XXHash64.hash(LandUtil.getBlockAddr(world, x, y).toBig64(), ((x*16777619) xor (y+1+layer)).toLong()) fmod mod.toLong()).toInt()
}
/**
* Autotiling; writes to buffer. Actual draw code must be called after this operation.