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.

Featured Replies

Posted

Hello,

I have a mod that use a external library Discord4j. I read posts about using external libraries with mods and successfully used the Gradle shadow plugin to shade the library into my mod.

Discord4j seems to use a newer version of Netty. So I shaded newer version of netty and relocate the package to avoid conflict with Minecraft/Forge. The built mod (shadow jar) can run on the server.

However, I still cannot run the server through my IDE directly, neither through generated Intellij run configurations or the runServer task (./gradlew runServer)

Running the server through IDE will throw this exception:

[15:43:59] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
java.lang.NoSuchMethodError: 'boolean io.netty.handler.ssl.SslProvider.isAlpnSupported(io.netty.handler.ssl.SslProvider)'
        at reactor.netty.http.client.HttpClientSecure.<clinit>(HttpClientSecure.java:79) ~[reactor-netty-0.9.15.RELEASE.jar:0.9.15.RELEASE] {}
        at reactor.netty.http.client.HttpClient.secure(HttpClient.java:1073) ~[reactor-netty-0.9.15.RELEASE.jar:0.9.15.RELEASE] {}
        at discord4j.common.ReactorResources.lambda$static$0(ReactorResources.java:41) ~[discord4j-common-3.1.3.jar:3.1.3] {}
        at discord4j.common.ReactorResources.<init>(ReactorResources.java:54) ~[discord4j-common-3.1.3.jar:3.1.3] {}
        at discord4j.rest.RestClientBuilder.initReactorResources(RestClientBuilder.java:262) ~[discord4j-rest-3.1.3.jar:3.1.3] {}
        at discord4j.rest.RestClientBuilder.build(RestClientBuilder.java:243) ~[discord4j-rest-3.1.3.jar:3.1.3] {}
        at discord4j.core.DiscordClientBuilder.build(DiscordClientBuilder.java:85) ~[discord4j-core-3.1.3.jar:3.1.3] {}
        at discord4j.core.DiscordClientBuilder.build(DiscordClientBuilder.java:73) ~[discord4j-core-3.1.3.jar:3.1.3] {}
        at discord4j.core.DiscordClient.create(DiscordClient.java:59) ~[discord4j-core-3.1.3.jar:3.1.3] {re:classloading}
        at com.github.tony84727.xptweak.XpTweakConfig.getDiscordClient(XpTweakConfig.java:19) ~[main/:?] {re:classloading}
        at com.github.tony84727.xptweak.ModEventListener.onModConfig(ModEventListener.java:42) ~[main/:?] {re:classloading}

Which means Discord4j is using the older version shipped with Minecraft and isAlpnSupported method isn't available.

Is there any way to do shading and relocation in the IDE runs?

Here's the gradle file of the mod: https://github.com/tony84727/xp-tweak/blob/7f24df8f46f78840d145605db1d2cfdd988ef66b/build.gradle

Any help or pointer is appreciated. Thanks!

There's no evidence that you use a newer version of netty within the buildscript. You indeed shadow the version during building, but you do not compile it for use within the game. You still need to require a dependency on it such that it is used within runtime.

  • Author

Hello @ChampionAsh5357, thank you for your reply!

On 4/12/2021 at 12:27 AM, ChampionAsh5357 said:

There's no evidence that you use a newer version of netty within the buildscript.

I do not use the newer version of netty directly. It's a transitive dependency of Discord4j:

+--- com.discord4j:discord4j-core:3.1.3
|    +--- io.projectreactor:reactor-bom:Dysprosium-SR15
|    |    ...
|    +--- com.discord4j:discord-json:1.5.6
|    |    ...
|    +--- com.discord4j:discord4j-rest:3.1.3
|    |    ...
|    |    \--- com.discord4j:discord4j-common:3.1.3
|    |         +--- io.projectreactor:reactor-bom:Dysprosium-SR15 (*)
|    |         +--- com.discord4j:discord-json:1.5.6 (*)
|    |         +--- io.projectreactor.netty:reactor-netty:0.9.15.RELEASE
|    |         |    +--- io.netty:netty-codec-http:4.1.54.Final

(BTW, Minecraft is using io.netty:netty-all:4.1.25.Final)

 

On 4/12/2021 at 12:27 AM, ChampionAsh5357 said:

You indeed shadow the version during building, but you do not compile it for use within the game

I thought those line will extend "compile" by "shadow" configuration, making "compile" inherit dependencies from "shaodw":

https://github.com/tony84727/xp-tweak/blob/7f24df8f46f78840d145605db1d2cfdd988ef66b/build.gradle#L114-L117

But anyway, I tried. I added netty dependency to the buildscript and found out that ./gradlew runServer is working!🎉 (the PR)

However, for intellij runs, still no luck. (I've run ./gradlew genIntellijRuns again after updating the buildscript). Starting server by IDE runs will still throw java.lang.NoSuchMethodError, indicating those runs are still using old version of netty.

 

I still wish I can launch server by IDE runs so I can use IDE's debug utilities.

  • Author
On 4/13/2021 at 1:08 PM, MinecraftXwinP said:

However, for intellij runs, still no luck. (I've run ./gradlew genIntellijRuns again after updating the buildscript). Starting server by IDE runs will still throw java.lang.NoSuchMethodError, indicating those runs are still using old version of netty.

My bad, after modifying a build script, IDE need to sync with gradle again to rebuild the model or module(?). After syncing, the IDE runs works.

Although, I'm still not sure what happened. I guess it's because when explicitly adding the netty dependency into the dependencies block, gradle will prefer newer version over the original version used by Minecraft?

 

The final working buildscript for me is: https://github.com/tony84727/xp-tweak/blob/14c629e3e582beed0d620313a291cd2b54273220/build.gradle

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.