mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-10-02 16:41:40 -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 {
|
dimensionRegistry?.get(null)?.let {
|
||||||
check(it is Registry<*>)
|
check(it is Registry<*>)
|
||||||
val registryGetKeyMethod = Registry::class.java.getDeclaredMethod("getId", Object::class.java)
|
val registryGetKeyMethod = Registry::class.java.getDeclaredMethod("getId", Object::class.java)
|
||||||
val dimensionTypeGetIdMethod = try {
|
val idMethod1 = try {
|
||||||
DimensionType::class.java.getDeclaredMethod("getRawId")
|
DimensionType::class.java.getDeclaredMethod("getRawId")
|
||||||
} catch (exception: Throwable) {
|
} catch (exception: Throwable) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
val idMethod2 = try {
|
||||||
it::class.java.getDeclaredMethod("getRawId", Object::class.java)
|
it::class.java.getDeclaredMethod("getRawId", Object::class.java)
|
||||||
|
} catch (exception: Throwable) {
|
||||||
|
null
|
||||||
}
|
}
|
||||||
for (entry in it) {
|
for (entry in it) {
|
||||||
check(entry is DimensionType)
|
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) {
|
} catch (exception: Exception) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user