Mod crashes and burns in Fabric Yarn Development Environment
BasiqueEvangelist opened this issue · 1 comments
OpenPAC manually finds fields by checking Forge SRG, Fabric Intermediary and Mojmap. (e.g. here and here). While this is fine in production and in a Mojmap dev env, this burns horribly in a Yarn dev env (which is the default on Fabric).
[15:10:15] [Server thread/ERROR] (Minecraft) Encountered an unexpected exception
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at xaero.pac.common.event.CommonEventsFabric.onServerTick(CommonEventsFabric.java:130) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.event.CommonEventsFabric.lambda$registerFabricAPIEvents$0(CommonEventsFabric.java:85) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents.lambda$static$0(ServerTickEvents.java:40) ~[fabric-lifecycle-events-v1-2.2.10+23a79c8a85.jar:?]
at net.minecraft.server.MinecraftServer.handler$zij000$fabric-lifecycle-events-v1$onStartTick(MinecraftServer.java:4839) ~[minecraft-merged-project-root-1.19.3-net.fabricmc.yarn.1_19_3.1.19.3+build.5-v2.jar:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:830) ~[minecraft-merged-project-root-1.19.3-net.fabricmc.yarn.1_19_3.1.19.3+build.5-v2.jar:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:99) ~[minecraft-merged-project-root-1.19.3-net.fabricmc.yarn.1_19_3.1.19.3+build.5-v2.jar:?]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:676) ~[minecraft-merged-project-root-1.19.3-net.fabricmc.yarn.1_19_3.1.19.3+build.5-v2.jar:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:264) ~[minecraft-merged-project-root-1.19.3-net.fabricmc.yarn.1_19_3.1.19.3+build.5-v2.jar:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ExceptionInInitializerError
at xaero.pac.common.event.CommonEvents.onServerTick(CommonEvents.java:160) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.event.CommonEventsFabric.onServerTick(CommonEventsFabric.java:128) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
... 8 more
Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldException: isInsidePortal
at xaero.pac.common.reflect.Reflection.getFieldReflection(Reflection.java:44) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.reflect.Reflection.getFieldReflection(Reflection.java:31) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.server.core.ServerCore.<clinit>(ServerCore.java:376) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.event.CommonEvents.onServerTick(CommonEvents.java:160) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.event.CommonEventsFabric.onServerTick(CommonEventsFabric.java:128) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
... 8 more
Caused by: java.lang.NoSuchFieldException: isInsidePortal
at java.lang.Class.getDeclaredField(Class.java:2610) ~[?:?]
at xaero.pac.common.reflect.Reflection.getFieldReflection(Reflection.java:42) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.reflect.Reflection.getFieldReflection(Reflection.java:31) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.server.core.ServerCore.<clinit>(ServerCore.java:376) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.event.CommonEvents.onServerTick(CommonEvents.java:160) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
at xaero.pac.common.event.CommonEventsFabric.onServerTick(CommonEventsFabric.java:128) ~[open-parties-and-claims-636608-4428272-sources-4428279.jar:?]
... 8 more
Possible solutions
Forge (ObfuscationReflectionHelper.findField
) and Fabric (FabricLoader.getInstance().getMappingResolver().mapFieldName
) both have methods for getting the actual runtime name of an SRG/Intermediary field.
Alternatively, these usages could be replaced with @Accessor
Mixins.