mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 20:44:05 +09:00
serialisation of HRQNG is fixed so it would not make illegal reflective access on Java 17
This commit is contained in:
@@ -3,6 +3,7 @@ package net.torvald.terrarum.serialise
|
||||
import com.badlogic.gdx.utils.Json
|
||||
import com.badlogic.gdx.utils.JsonValue
|
||||
import com.badlogic.gdx.utils.JsonWriter
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.gameworld.BlockLayer
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
@@ -187,6 +188,19 @@ object Common {
|
||||
return UUID.fromString(jsonData.asString())
|
||||
}
|
||||
})
|
||||
// HQRNG
|
||||
jsoner.setSerializer(HQRNG::class.java, object : Json.Serializer<HQRNG> {
|
||||
override fun write(json: Json, obj: HQRNG, knownType: Class<*>?) {
|
||||
json.writeValue("${obj.state0.toString()},${obj.state1.toString()}")
|
||||
}
|
||||
|
||||
override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): HQRNG {
|
||||
val rng = HQRNG()
|
||||
val seedstr = jsonData.asString().split(',')
|
||||
rng.setSeed(seedstr[0].toLong(), seedstr[1].toLong())
|
||||
return rng
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private data class LayerInfo(val h: String, val b: String, val x: Int, val y: Int)
|
||||
|
||||
Reference in New Issue
Block a user