mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-27 05:59:53 -04:00
22wxx+: generate dimensions properly
This commit is contained in:
parent
866a56457e
commit
a494adccb6
@ -18,7 +18,7 @@ import java.util.zip.GZIPOutputStream
|
||||
object PixLyzer {
|
||||
private val startTime = System.currentTimeMillis()
|
||||
|
||||
val ENTITY_META_DATA_MAPPING = Util.readJsonResource("entities_data_mappings.json")
|
||||
val ENTITY_DATA_MAPPING = Util.readJsonResource("entities_data_mappings.json")
|
||||
|
||||
|
||||
@JvmStatic
|
||||
|
@ -134,22 +134,25 @@ object DimensionGenerator : Generator(
|
||||
private fun getDimensions(): MutableSet<Triple<Identifier, Int?, DimensionType>> {
|
||||
val types: MutableSet<Triple<Identifier, Int?, DimensionType>> = mutableSetOf()
|
||||
|
||||
if (types.isEmpty()) {
|
||||
val dimensionRegistry = getField(Registry::class.java, "DIMENSION", "DIMENSION_TYPE")
|
||||
|
||||
try {
|
||||
dimensionRegistry?.get(null)?.let {
|
||||
check(it is Registry<*>)
|
||||
val registryGetKeyMethod = Registry::class.java.getDeclaredMethod("getId", Object::class.java)
|
||||
val dimensionTypeGetIdMethod = DimensionType::class.java.getDeclaredMethod("getRawId")
|
||||
for (entry in it) {
|
||||
check(entry is DimensionType)
|
||||
types.add(Triple(registryGetKeyMethod.invoke(it, entry) as Identifier, dimensionTypeGetIdMethod.invoke(entry) as Int, entry))
|
||||
val dimensionRegistry = getField(getClass("net.minecraft.util.registry.BuiltinRegistries"), "DIMENSION_TYPE") ?: getField(Registry::class.java, "DIMENSION", "DIMENSION_TYPE")
|
||||
|
||||
}
|
||||
try {
|
||||
dimensionRegistry?.get(null)?.let {
|
||||
check(it is Registry<*>)
|
||||
val registryGetKeyMethod = Registry::class.java.getDeclaredMethod("getId", Object::class.java)
|
||||
val dimensionTypeGetIdMethod = try {
|
||||
DimensionType::class.java.getDeclaredMethod("getRawId")
|
||||
} catch (exception: Throwable) {
|
||||
it::class.java.getDeclaredMethod("getRawId", Object::class.java)
|
||||
}
|
||||
for (entry in it) {
|
||||
check(entry is DimensionType)
|
||||
types.add(Triple(registryGetKeyMethod.invoke(it, entry) as Identifier, dimensionTypeGetIdMethod.invoke(it, entry) as Int, entry))
|
||||
}
|
||||
} catch (exception: Exception) {
|
||||
}
|
||||
} catch (exception: Exception) {
|
||||
exception.printStackTrace()
|
||||
}
|
||||
|
||||
if (types.isEmpty()) {
|
||||
|
@ -188,7 +188,7 @@ object EntityGenerator : Generator(
|
||||
field.isAccessible = true
|
||||
val dataAccessor: TrackedData<*> = field.get(null) as TrackedData<*>
|
||||
val className = correctClassName(clazz.simpleName)
|
||||
val entityClazzData = PixLyzer.ENTITY_META_DATA_MAPPING[className]?.mapCast() ?: error("Can not find entity: $className, requires field ${field.name}")
|
||||
val entityClazzData = PixLyzer.ENTITY_DATA_MAPPING[className]?.mapCast() ?: error("Can not find entity: $className, requires field ${field.name}")
|
||||
val entityData = entityClazzData["data"]!!.mapCast()!!
|
||||
val realFieldName = entityData[field.name]?.toString() ?: error("Can not find meta data field ${field.name} for ${clazz.simpleName}")
|
||||
json[realFieldName] = dataAccessor.id
|
||||
|
Loading…
x
Reference in New Issue
Block a user