Skip to content

Instantly share code, notes, and snippets.

@SizableShrimp
Last active May 9, 2024 13:59
Show Gist options
  • Save SizableShrimp/66b22f1b24c255e1491c8d98d3f11f83 to your computer and use it in GitHub Desktop.
Save SizableShrimp/66b22f1b24c255e1491c8d98d3f11f83 to your computer and use it in GitHub Desktop.
How to fix Java libraries not loading in Minecraft Forge 1.17+

How to fix Java libraries not loading in Minecraft Forge 1.17+

By default, Minecraft Forge does not load dependencies from the classpath unless they are explicitly declared as mods. These steps outline how to remedy this. This guide assumes that:

  1. You are on ForgeGradle 5 or higher.
  2. You are on Forge 1.17.1 (37.0.13) or higher.

Using Java libraries

To configure your Java libraries to be loaded by Forge, you should use the minecraftLibrary configuration provided by ForgeGradle. You now must make sure to declare your dependencies using minecraftLibrary configuration. For example, you may have a line in dependencies {} that looks something like this:

    minecraftLibrary 'com.example:examplething:1.0.0'

A note on production differences

When using regular Java libraries not provided by Minecraft Forge, it is important to keep in mind that these libraries will disappear when you build your mod jar by default. This means the libraries will no longer exist when we try to use them from a normal Minecraft Forge installation. To fix this, you must set up either shading or Jar-in-Jar.

Shading

This can be done by configuring the gradle shadow plugin. See this guide which is specific to Minecraft Forge.

Jar-in-Jar

See this article on the Forge Community Wiki and consult the Forge discord for help.

@SizableShrimp
Copy link
Author

@Hades32 Please use the forge discord at https://discord.gg/forge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment