mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-27 14:10:01 -04:00
dimensions: fix id generation
This commit is contained in:
parent
4d9d23ae80
commit
052dd62bf7
@ -141,14 +141,20 @@ object DimensionGenerator : Generator(
|
||||
dimensionRegistry?.get(null)?.let {
|
||||
check(it is Registry<*>)
|
||||
val registryGetKeyMethod = Registry::class.java.getDeclaredMethod("getId", Object::class.java)
|
||||
val dimensionTypeGetIdMethod = try {
|
||||
val idMethod1 = try {
|
||||
DimensionType::class.java.getDeclaredMethod("getRawId")
|
||||
} catch (exception: Throwable) {
|
||||
null
|
||||
}
|
||||
val idMethod2 = try {
|
||||
it::class.java.getDeclaredMethod("getRawId", Object::class.java)
|
||||
} catch (exception: Throwable) {
|
||||
null
|
||||
}
|
||||
for (entry in it) {
|
||||
check(entry is DimensionType)
|
||||
types.add(Triple(registryGetKeyMethod.invoke(it, entry) as Identifier, dimensionTypeGetIdMethod.invoke(it, entry) as Int, entry))
|
||||
val id1 = idMethod1?.invoke(entry) ?: idMethod2?.invoke(it, entry) ?: throw IllegalStateException("Can not get dimension id for $entry")
|
||||
types.add(Triple(registryGetKeyMethod.invoke(it, entry) as Identifier, id1 as Int, entry))
|
||||
}
|
||||
}
|
||||
} catch (exception: Exception) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user