mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 05:54:05 +09:00
lightsource randomiser hash will be same even when x < 0
This commit is contained in:
@@ -10,9 +10,11 @@ import net.torvald.terrarum.gameworld.fmod
|
||||
* Created by minjaesong on 2016-03-27.
|
||||
*/
|
||||
object LandUtil {
|
||||
fun getBlockAddr(world: GameWorld, x: Int, y: Int): BlockAddress =
|
||||
// coercing and fmod-ing follows ROUNDWORLD rule. See: GameWorld.coerceXY()
|
||||
(world.width * y.coerceIn(0, world.height - 1)).toLong() + x.fmod(world.width)
|
||||
fun getBlockAddr(world: GameWorld, x: Int, y: Int): BlockAddress {
|
||||
// coercing and fmod-ing follows ROUNDWORLD rule. See: GameWorld.coerceXY()
|
||||
val (x, y) = world.coerceXY(x, y)
|
||||
return (world.width.toLong() * y) + x
|
||||
}
|
||||
|
||||
fun resolveBlockAddr(world: GameWorld, t: BlockAddress): Pair<Int, Int> =
|
||||
Pair((t % world.width).toInt(), (t / world.width).toInt())
|
||||
|
||||
Reference in New Issue
Block a user