Open Loader

Open Loader

21M Downloads

[BUG] `ModResourcePackCreator` class loading earlier than `OpenLoaderFabric` initialization, causing NPE

Snownee opened this issue ยท 1 comments

commented

Minecraft Version

1.20.1

Mod Version

19.0.4

Mod Loader

Fabric

What environment are you running the mod in?

Client

Issue Description

I added some mixin-code to the PackRepository which contains class-loading of ModResourcePackCreator, causing it to not work with OpenLoader:

java.lang.ExceptionInInitializerError
	at net.minecraft.class_3283.handler$bjg000$kiwi$init(class_3283.java:3059)
	at net.minecraft.class_3283.<init>(class_3283.java:28)
	at net.minecraft.class_310.<init>(class_310.java:436)
	at net.minecraft.client.main.Main.main(Main.java:211)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:480)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
Caused by: java.lang.NullPointerException: Cannot read field "resourcePacks" because "net.darkhax.openloader.OpenLoaderFabric.config" is null
	at net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator.handler$cba000$openloader$onConstruction(ModResourcePackCreator.java:539)
	at net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator.<init>(ModResourcePackCreator.java:52)
	at net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator.<clinit>(ModResourcePackCreator.java:47)
	... 7 more

I think a possible solution would be to initialize the fields in OpenLoaderFabric immediately during the class loading:

public class OpenLoaderFabric {

    public static final Path configDir = FabricLoader.getInstance().getConfigDir().resolve("openloader");
    public static final ConfigSchema config = ConfigSchema.load(configDir);

}
commented

I can confirm this issue -- Open Loader does not work when used with Aurora's Decorations, crash log shows this:

Caused by: java.lang.NullPointerException: Cannot read field "resourcePacks" because "net.darkhax.openloader.OpenLoaderFabric.config" is null at net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator.handler$bec000$openloader$onConstruction(ModResourcePackCreator.java:539) at net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator.<init>(ModResourcePackCreator.java:48) at net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator.<clinit>(ModResourcePackCreator.java:43) ... 37 more