Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Snownee opened this issue Aug 5, 2024 · 1 comment
Labels
bug Something is not working as intended. unverified The contents of this issue have not yet been verified.

Comments

@Snownee
Copy link

Snownee commented Aug 5, 2024

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);

}
@Snownee Snownee added bug Something is not working as intended. unverified The contents of this issue have not yet been verified. labels Aug 5, 2024
@ElectroArtifex
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working as intended. unverified The contents of this issue have not yet been verified.
Projects
None yet
Development

No branches or pull requests

2 participants