Jump to content

How to apply relocate for intellij runs or runServer?


MinecraftXwinP

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • SGP4D merupakan situs online sgp 4d yang resmi & terpercaya #1 di seluruh Indonesia, dimana kamu bisa menemukan berbagai macam game paling gacor disini. Setiap game yang disediakan oleh sgp4d merupakan permainan dengan rtp yang bisa mencapai hingga di atas 90%, menandakan bahwa bermain di sgp4d akan sangat gampang menang baik anda seorang pemula sekali pun. Kamu tidak perlu khawatir jika bermain di sgp4d karena sgp4d akan memberikan anda kemenangan dengan mudah, lebih mudah daripada yang terbayangkan di benakmu, jadi bergabung lah dengan sgp4d sekarang juga melalui link yang tersedia di bawah ini. Β  ----- DAFTAR & LOGIN AKUN PRO SGP4D >>> KLIK DISINI ----- Β 
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
    • Situs slot gacor hari ini resmi terupdate
    • BabaΒ  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

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