Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.17.1] Custom Language Provider is not loaded due to NPE

Featured Replies

Posted

Minecraft 1.17.1, Forge 37.0.2

I'm developing a custom language provider for Scala. I created the jar as the same way as 1.16.5, but Minecraft crashes with this error.

Spoiler

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "net.minecraftforge.forgespi.language.IModFileInfo.moduleName()" because the return value of "net.minecraftforge.forgespi.locating.IModFile.getModFileInfo()" is null
    at MC-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.moddiscovery.ModJarMetadata.name(ModJarMetadata.java:53)
    at [email protected]/cpw.mods.jarhandling.impl.Jar.name(Jar.java:212)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:550)
    at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
    at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
    at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
    at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
    at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.ModuleLayerHandler.buildLayer(ModuleLayerHandler.java:69)
    at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.ModuleLayerHandler.buildLayer(ModuleLayerHandler.java:82)
    at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:93)
    at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)
    at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)
    at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)
    at [email protected]/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:84)

NPE happens in the call of SecureJar#name, which calls JarMetadata#name.

The default lang loaders(javafml, mclangage, etc.) is provided with SimpleJarMetadata or ModuleJarMetadata, where JarMetadata#name must return valid value.

But jars in mods dir have ModJarMetadata. In the class, JarMetadata#name fails if modFile.getModFileInfo() is null. For mod jar(FMLModType is MOD), the field(modFile.modFileInfo) is set in construction but for LANGPROVIDER the field remains null.

 

What I did

  • Created a class that implements `IModLanguageProvider`
  • Made a service provider file at META-INF/services/net.minecraftforge.forgespi.language.IModLanguageProvider
    • It contains the class name that implements `net.minecraftforge.forgespi.language.IModLanguageProvider`
  • Created other classes such as Mod Container, Language Target.
  • Then, I made a jar file.

Content of MANIFEST.MF in jar. I know "Main-Class" is not needed for Minecraft. It's for my test. I think "FMLModType" must be "LANGPROVIDER" if I want to create language provider, as the same way in 1.16.5.

Spoiler

Manifest-Version: 1.0
FMLModType: LANGPROVIDER
Specification-Title: SLP
Specification-Vendor: Kotori316
Specification-Version: 1
Implementation-Title: SLP
Implementation-Version: 2.13.6-build-1
Implementation-Vendor: Kotori316
Implementation-Timestamp: 2021-07-27T15:07:10.803099700Z
Main-Class: com.kotori316.scala_lib.Main

 

EDIT: The PR https://github.com/MinecraftForge/MinecraftForge/pull/7947 will solve this problem.

Edited by Kotori316

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.