Jump to content

Recommended Posts

Posted

Hey there,

I have a mod I'd like to depend on, and I also have its sources jar file.
fg.deobf did not load it automatically as I expected, even though the jar has the "-sources" name suffix.

I then attempted the following inside of build.gradle:

dependencies {
    minecraft 'net.minecraftforge:forge:1.19.3-44.1.23'

    implementation fg.deobf("com.cstav.genshinstrument:genshinstrument:2.3")
    implementation "com.cstav.genshinstrument:genshinstrument:2.3:sources"
}

This results in a configure successful output, but an unresolved dependency issue of the same mod. VSCode does, indeed, load the sources, but Minecraft fails to load complaining that an unmapped (vanilla) method does not exist.

What am I missing? I've been stuck on this for a couple of good hours now.

Posted

That is not the correct way to do it.

"implementation" means adding the jar to the classpath for both compile and run. Since source jars don't contain any classes that's kind of pointless.

 

And posting small snippets out of context will just lead to your question getting ignored.

Nobody is going to waste their time trying to guess what the problem is from very incomplete information unless the problem is obvious from what you post.

 

 

I don't know much about how vscode works with gradle, but I am assuming you are using the plugin written by redhat/microsoft that repurposes some of the code used by eclipse?

The docs for that has a section on how to attach sources: https://code.visualstudio.com/docs/java/java-project

 

Why it isn't doing this automatically, you would have to ask the plugin authors.

Having a -sources.jar is usually enough for maven's "configuration by convention" - assuming you are using maven to download the jar?

Or maybe the plugin is confused by the jar getting deobfuscated when it is downloaded? https://forge.gemwire.uk/wiki/Dependencies, but that doesn't confuse eclipse which as I said above I think uses the same code.

 

 

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.

Posted

Hey there. Thank you very much for the fast reply.

  Quote

And posting small snippets out of context will just lead to your question getting ignored.

Nobody is going to waste their time trying to guess what the problem is from very incomplete information unless the problem is obvious from what you post.

Expand  

I sincerely apologize for lacking more details. I believed this snippet was enough to determine the problem, but I was mistaken.
So, allow me to expand on details:

The mod that I am attempting to reference is a mod that is present in the libs directory:

repositories {
    flatDir {
        dir 'libs'
    }
}

In there, the files genshinstrument-2.3.jar and genshinstrument-2.3-sources.jar are present - such that the mod and its sources are different jars.

I've seen a similar issue here (#736) - However, theirs revolved around a hosted dependency, whereas mine is a local one. I don't know if it makes the difference, though. That being said, the mod and its sources are also hosted on GitHub.

Other than that, I don't have much more details to share with you, as the rest is just the boilerplate build.gradle.

 

  Quote

I don't know much about how vscode works with gradle, but I am assuming you are using the plugin written by redhat/microsoft that repurposes some of the code used by eclipse?

The docs for that has a section on how to attach sources: https://code.visualstudio.com/docs/java/java-project

Expand  

Yes, I am. Thank you for the helpful article, too - however, their method is workspace-only, and does not apply to build tools such as Gradle.

However, even if the implementation method is absolutely not intended for loading source files; the fact is, it still did load them after I declared the statement. This heavily leads me to believe that Gradle (at least in VSCode) is responsible for handling this kind of stuff, but I'm simply not doing it properly.

 

  Quote

Or maybe the plugin is confused by the jar getting deobfuscated when it is downloaded?

Expand  

I do believe so, too. As per se, when loading Minecraft with the implementation on, it shows an error stating that an unmapped Minecraft class has been attempted to be called. The debug.log is attached below.

  Reveal hidden contents

Everything does, however, function normally without the source implementation statement.

 

I hope this information was of use to you. Please let me know if I missed anything else...
Thanks again.

Posted (edited)

Gradle flatdir is not a maven repository.

https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:repository-types

  Quote

This type of repository does not support any meta-data formats like Ivy XML or Maven POM files.

Instead, Gradle will dynamically generate a module descriptor (without any dependency information) based on the presence of artifacts.

Expand  

You need to ask wherever gradle provides support what it means by that.

Edited by warjort

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.

Posted (edited)

Sorry for the lack of response. I was occupied the whole week.

------

EDIT: I just ran the game (something that I should've done 🤦‍♂️), and the same unmapped vanilla method error occurred - exact same one. This time, though, it happened with even just the regular Jar files, with no sources attached. Any help with that will be appreciated...

More details below for when I blindly believed my IDE

------

I explored the link you provided, and I can say that it has indeed worked; both the sources and the Jar get picked up via this method! Thanks a bunch.

I ended up constructing a local Maven repository in my user directory, attaching the sources after the publish task was done. However, I'm quite certain this process could be automated as stated here; though, I didn't get this to work at all in this project. The following is what I tried:

java {
    withSourcesJar()
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file://${project.projectDir}/mcmodsrepo"
        }
    }
}

artifacts {
    archives sourcesJar
}

 

Also regarding the topic, I'd wager that if I want my mod to be easily extensible, then I should upload it to a remote Maven repository. According to the comment under the 'repositories' block, "ForgeGradle automatically adds the Forge maven and Maven Central for you". Should I, then, publish it to Maven Central? And, how would I go about doing this?

 

Please forgive my ignorance and lack of knowledge in this matter.
Thanks yet again.

Edited by Stav
After actually trying to run the game, I discovered that it was, in fact, not working.

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



×
×
  • Create New...

Important Information

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