Patchouli (Fabric/Quilt)

Patchouli (Fabric/Quilt)

28M Downloads

NeoForge FMLCommonSetupEvent error at game launch

huskago opened this issue · 12 comments

commented

Mod loader

NeoForge

Minecraft version

1.21.1

Patchouli version

1.21-88

Modloader version

NeoForge: 21.1.133

Modpack info

https://gist.github.com/Huskago/13fe1d383784a9d071286a7b04cf83cd

The latest.log file

https://gist.github.com/Huskago/2d13e5a89e900c1fda86f14334313199

Issue description

Sometimes when I start the game, before I get to the main menu, I have a problem that prevents me from playing.

Image

Steps to reproduce

  • Launch the game
  • If this does not appear, restart the game

Other information

Information on the others can be found in the custom modpack link

commented

Wouldn't it be better if it used architectury setup instead of service loaders? that code there seems very brittle. To my understanding this happens when another mod ends up being the one that classloads that class, which could happen through many indirect ways. Then its classloader will be used there and the service won't be found.
Still take this with a grain of salt, my understanding here isnt as thorough as id like it to be.

commented

or use ServiceLoader.load(clazz, clazz.getClassLoader());
Also this affects Botania too since it has same code

commented

Wouldn't it be better if it used architectury setup instead of service loaders?

Neither Patchouli not Botania depend on Architectury. That's an entirely different way to set up a multi-loader build system.

commented

I also wonder about this line:

var providers = ServiceLoader.load(IXplatAbstractions.class).stream().toList();

The Java API docs say:

Creates a new service loader for the given service type, using the current thread's context class loader.

An invocation of this convenience method of the form

 ServiceLoader.load(service)

is equivalent to

 ServiceLoader.load(service,
                    Thread.currentThread().getContextClassLoader())

To me that sounds like we (as in Patchouli and Botania) are rolling the dice on whether the XplatAbstraction.INSTANCE gets initialized in a thread with a class loader that was responsible for loading the mod's jar file. Should definitely try specifying the interface's actual class loader.

commented

i got the same error

commented

Your .minecraft/patchouli_data.json got corrupted, delete it.
i find it you gotta delete patchouli_data.json in your minecraft folder its corrupted it worked for me

commented

Your .minecraft/patchouli_data.json got corrupted, delete it. i find it you gotta delete patchouli_data.json in your minecraft folder its corrupted it worked for me

not work, same error

commented

Same error

[263��2025 17:02:56.427] [Worker-Main-14/ERROR] [net.neoforged.fml.javafmlmod.FMLModContainer/]: Exception caught during firing event: null
	Index: 0
	Listeners:
		0: net.neoforged.bus.EventListenerFactory$onInitialize/0x0000022802559c00@57a258bd
java.lang.ExceptionInInitializerError
	at TRANSFORMER/[email protected]/vazkii.patchouli.common.book.BookRegistry.init(BookRegistry.java:42)
	at TRANSFORMER/[email protected]/vazkii.patchouli.neoforge.common.NeoForgeModInitializer.onInitialize(NeoForgeModInitializer.java:86)
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:350)
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:315)
	at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.ModContainer.acceptEvent(ModContainer.java:158)
	at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.ModLoader.lambda$dispatchParallelEvent$4(ModLoader.java:172)
	at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.ModLoader.lambda$dispatchParallelTask$7(ModLoader.java:231)
	at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
	at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
Caused by: java.lang.IllegalStateException: There should be exactly one IXplatAbstractions implementation on the classpath. Found: []
	at TRANSFORMER/[email protected]/vazkii.patchouli.xplat.IXplatAbstractions.find(IXplatAbstractions.java:51)
	at TRANSFORMER/[email protected]/vazkii.patchouli.xplat.IXplatAbstractions.<clinit>(IXplatAbstractions.java:45)
	... 15 more
commented

Another crash report via Discord

another patchy crash.txt

This one does NOT have any fabric/connector related mods in it, which is notable

commented

Another user on Discord reported that removing a mod called Basic Nether Ores [Forge / Fabric] fixed a Patchouli crash. It is likely not specifically caused by that mod (and I don't have a crashlog from this user so I don't know if it's the same bug)

commented

Another crash report via Discord

another patchy crash.txt

This one does NOT have any fabric/connector related mods in it, which is notable

The error log shows up as a bug reported here, interesting.

private static IXplatAbstractions find() {
var providers = ServiceLoader.load(IXplatAbstractions.class).stream().toList();
if (providers.size() != 1) {
var names = providers.stream().map(p -> p.type().getName()).collect(Collectors.joining(",", "[", "]"));
throw new IllegalStateException("There should be exactly one IXplatAbstractions implementation on the classpath. Found: " + names);
} else {
var provider = providers.get(0);
PatchouliAPI.LOGGER.debug("Instantiating xplat impl: " + provider.type().getName());
return provider.get();
}
}

commented

Also seeing this. Same patchouli, MineCraft and NeoForge versions. Attaching Crash Report and Log File in case they are helpful. This was AFTER deleting the patchouli_data.json file.

crash-2025-04-28_17.28.58-fml.txt
Patchouli - Crash Log 2.txt