Jump to content

Gradle fails to download net.minecraftforge and net.minecraft artefacts for MC1.18.2


RedNicStone

Recommended Posts

Hey there!

I'm experiencing issues when setting up ForgeGradle for a MC1.18.2, FORGE40.1.0. The issues seems to be that gradle is unable to locate certain artefacts reliably due to DNS resolution failure.

I've tried fixing this issue for about 8 hours straight now and I've come to accept that I wont be able to fix it myself. I was reluctant to post on the forge due to prior hostility against me when asking for support in the past, but I've decided to give the forums another try. Id appreciate it if my issue does not get removed.

The issue I'm facing is that java fails to resolve mojang/minecraft related addresses like `libraries.minecraft.net`, `piston-meta.mojang.com` or `launchermeta.mojang.com` resulting in an `java.net.UnknownHostException` similar to [MCL-14985]. This appears to only be happening in openjdk version 11 and not 1.8, 17 or 19. I've faced this exact issue before but in that case I was able to mitigate it bu using an alternative java version, which due to the restrictions imposed by gradle is no possible.
The error does not occur consistently and at times resolving the dns does work temporarily. I am convinced that this does not relate to my os configuration or my dns service (I can resolve the dns just fine using `host`).

I would post a log here but due to the randomness of the issue I dont think this is suited here. If you still require a complete log please reply and I will send one. The log sniplets below are gradle error I am getting when building the **official** MDK.

Typical java error message:

Error getting artifact: net.minecraft:client:1.18.2:null@pom from  MinecraftRepo
java.net.UnknownHostException: piston-meta.mojang.com
        at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.base/java.net.Socket.connect(Socket.java:609)

Typical gradle error message:

* What went wrong:
A problem occurred configuring root project 'forge-1.18.2-40.1.0-mdk'.
> Could not resolve all files for configuration ':_compileJava_1'.
   > Could not find net.minecraft:client:1.18.2.
     Searched in the following locations:
       - https://maven.minecraftforge.net/net/minecraft/client/1.18.2/client-1.18.2.module
       - https://maven.minecraftforge.net/net/minecraft/client/1.18.2/client-1.18.2.pom
       - https://maven.minecraftforge.net/net/minecraft/client/1.18.2/client-1.18.2-extra.jar
       - file:/home/nic/.gradle/caches/forge_gradle/bundeled_repo/net/minecraft/client/1.18.2/client-1.18.2.pom
       - file:/home/nic/.gradle/caches/forge_gradle/bundeled_repo/net/minecraft/client/1.18.2/client-1.18.2-extra.jar
       - https://libraries.minecraft.net/net/minecraft/client/1.18.2/client-1.18.2-extra.jar
       - https://repo.maven.apache.org/maven2/net/minecraft/client/1.18.2/client-1.18.2.pom
     Required by:
         project :

More system details:

OS: Fedora Linux 36 running kernel 5.19.16-200
Java: OpenJDK 11.0.16.1 w/ integrated runtime and server VM
Gradle: [Project default] 7.4
Kotlin: 1.5.31
Groovy: 3.0.9
Build command: ./gradlew build
IDE: none

 

Thanks in advance for your help!

Link to comment
Share on other sites

Quote

java.net.UnknownHostException: piston-meta.mojang.com

This is some issue with your network connection.

This recent thread (for a related error) rehearses some of the likely causes.

https://forums.minecraftforge.net/topic/117671-forge-1181-mdk-error-building-the-project-could-not-find-netminecraftclient1181/#comment-518295

But we don't in general provide PC support in this forum.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Quote

I am convinced that this does not relate to my os configuration or my dns service (I can resolve the dns just fine using `host`).

As mentioned in the post this issues it no related to my PCs connection or anything of the sorts. I would not post in the forums if that was the case. The post you linked to should only prove this.

Of course I thought the same thing at first but I wrote a simple java program before making this post to disprove this. This is the code:

import java.net.InetAddress;
import java.net.UnknownHostException;
public class connectiontest {
  public static void main(String[] args) throws UnknownHostException {
    InetAddress address = InetAddress.getByName("piston-meta.mojang.com");
    System.out.println(address.getHostAddress());
  }
}

Which, as expected, outputs an IP address (13.107.246.64). This program ran in the same jvm, parallel to gradle which was throwing the same errors are before. To me this shows that the issue lies with ForgeGradle rather than java or my system configuration.

EDIT: After some more extensive testing I could also consistently show that the first time I ran my program after a gradle build It would result in an error:

Exception in thread "main" java.net.UnknownHostException: piston-meta.mojang.com: Name or service not known
	at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
	at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:52)
	at java.base/java.net.InetAddress$PlatformResolver.lookupByName(InetAddress.java:1059)
	at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1668)
	at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:1003)
	at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1658)
	at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1524)
	at java.base/java.net.InetAddress.getByName(InetAddress.java:1413)
	at connectiontest.main(connectiontest.java:5)

However this is solely limited to the first run, and would never occur again even after running it dozens of times. This only proves that the culprit must be ForgeGradle. To investigate this further I will attempt and look at the dns resolutions in detail using a network logger next, but this might take some time.

Edited by RedNicStone
Link to comment
Share on other sites

Update: I've used Wireshark to analyse the incoming and outgoing dns packets. This shows that the DNS resolution itself if working just fine, all the while ForgeGradle still fails with:

Setting up MCP environment
Initializing steps
Executing steps
 > Running 'downloadManifest'
Error getting artifact: net.minecraft:joined:1.18.2-20220404.173914:srg@jar from  MCPRepo
java.net.UnknownHostException: piston-meta.mojang.com

Here is a screenshot of the Wireshark viewer where the domain name resolution request returns the expected IP address (For some reason this also requests IPv6, not sure why):
download

Link to comment
Share on other sites

How can this be a bug in forge gradle if your standalone program is also giving you the same error?

 

This is the code that forge gradle uses. It's just a URL.openStream()

https://github.com/MinecraftForge/ForgeGradle/blob/1fce46ef54e42adb69176edb0e8c3401a707b39c/src/common/java/net/minecraftforge/gradle/common/tasks/DownloadMCMeta.java#L53

All the details are handled by java or beneath that your OS.

 

I can only suggest you check your OS is up-to-date. And try a different more recent java, e.g. https://adoptium.net/

You can also ask on fedora's support forum to see if there are known issues in this area. Something like changing a dns cache setting may fix it?

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Quote

How can this be a bug in forge gradle if your standalone program is also giving you the same error?

This could happen if URL.openStream() notifies the OS about this invalid dns result. I am using systemd-resolved on my system so this is possible. Calling URL.openStream() on the same URI does not result in a UnknownHostException in my test program.

I was able to get the issue resolved just now by downloading ForgeGradle from github, changing the bytecode version from 1.8 to java 17 and building the plugin myself. Therefore the issue is probably not related to the project itself but instead that the bytecode included with the prebuilt binaries is incompatible with my java version.

While I would love to analyse why this error occurs this is kind of where my knowledge about java ends. Just building ForgeGradle turned out to be a pain since there are absolutely no build instruction and it wouldn't compile with the default configuration. If anyone has and idea how I could test why this error occurs in more detail please dont hesitate to tell me. I've tried attaching a debugger to the running instance of gradle but unfortunately the bytecode I generated is to different to the prebuilt binary to debug.

Edited by RedNicStone
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.



×
×
  • Create New...

Important Information

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