diff --git a/src/main/kotlin/de/bixilon/pixlyzer/generator/generators/DimensionGenerator.kt b/src/main/kotlin/de/bixilon/pixlyzer/generator/generators/DimensionGenerator.kt index 71cbd67..800866c 100644 --- a/src/main/kotlin/de/bixilon/pixlyzer/generator/generators/DimensionGenerator.kt +++ b/src/main/kotlin/de/bixilon/pixlyzer/generator/generators/DimensionGenerator.kt @@ -4,6 +4,7 @@ import com.google.gson.JsonObject import de.bixilon.pixlyzer.generator.Generator import de.bixilon.pixlyzer.util.ReflectionUtil.getClass import de.bixilon.pixlyzer.util.ReflectionUtil.getField +import net.minecraft.core.Registry import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.dimension.DimensionType import java.lang.reflect.Modifier @@ -108,24 +109,38 @@ object DimensionGenerator : Generator( private fun getDimensions(): MutableSet> { val types: MutableSet> = mutableSetOf() - for (field in DimensionType::class.java.declaredFields) { - if (field.type != DimensionType::class.java) { - continue + val dimensionRegistry = getField(Registry::class.java, "DIMENSION_TYPE") + + dimensionRegistry?.get(null)?.let { + check(it is Registry<*>) + val registryGetKeyMethod = Registry::class.java.getDeclaredMethod("getKey", Object::class.java) + val dimensionTypeGetIdMethod = DimensionType::class.java.getDeclaredMethod("getId") + for (entry in it) { + check(entry is DimensionType) + types.add(Triple(registryGetKeyMethod.invoke(it, entry) as ResourceLocation, dimensionTypeGetIdMethod.invoke(entry) as Int, entry)) + } - if (!Modifier.isStatic(field.modifiers)) { - continue - } - field.isAccessible = true - val resourceLocation = when (field.name) { - "DEFAULT_OVERWORLD", "OVERWORLD" -> ResourceLocation("overworld") - "DEFAULT_OVERWORLD_CAVES" -> ResourceLocation("overworld_caves") - "DEFAULT_NETHER", "NETHER" -> ResourceLocation("the_nether") - "DEFAULT_END", "THE_END" -> ResourceLocation("the_end") - else -> TODO("Can not find dimension ${field.name}") - } - types.add(Triple(resourceLocation, null, field.get(null) as DimensionType)) } + if (types.isEmpty()) { + for (field in DimensionType::class.java.declaredFields) { + if (field.type != DimensionType::class.java) { + continue + } + if (!Modifier.isStatic(field.modifiers)) { + continue + } + field.isAccessible = true + val resourceLocation = when (field.name) { + "DEFAULT_OVERWORLD", "OVERWORLD" -> ResourceLocation("overworld") + "DEFAULT_OVERWORLD_CAVES" -> ResourceLocation("overworld_caves") + "DEFAULT_NETHER", "NETHER" -> ResourceLocation("the_nether") + "DEFAULT_END", "THE_END" -> ResourceLocation("the_end") + else -> TODO("Can not find dimension ${field.name}") + } + types.add(Triple(resourceLocation, null, field.get(null) as DimensionType)) + } + } if (types.isEmpty()) { val field = getField(DimensionType::class.java, "BUILTIN") ?: return types diff --git a/wrapper/PixLyzer.py b/wrapper/PixLyzer.py index 41c4c61..fcb8fa4 100755 --- a/wrapper/PixLyzer.py +++ b/wrapper/PixLyzer.py @@ -15,7 +15,7 @@ OUT_FOLDER = os.path.abspath("data/version/") + "/" DATA_FOLDER = os.path.abspath("data/data/") + "/" MC_REMAPPER_EXECUTABLE = "/home/moritz/Games/Minecraft/MC-Remapper/build/install/MC-Remapper/bin/MC-Remapper" -JAVA_PATH = "/usr/lib/jvm/java-8-openjdk-amd64/bin/java" +JAVA_PATH = "/usr/lib/jvm/graalvm-ce-java11-21.0.0.2/bin/java" ADDITIONAL_CLASSPATH = "/home/moritz/kotlin-stdlib-1.4.30.jar:/home/moritz/Games/Minecraft/PixLyzer/wrapper/data/objenesis-tck-3.1.jar" VERSION_MANIFEST_URL = "https://launchermeta.mojang.com/mc/game/version_manifest.json"