Curios API (Forge/NeoForge)

Curios API (Forge/NeoForge)

140M Downloads

Plea for help

Aizistral opened this issue ยท 3 comments

commented

I am trying to add your lib to my project, and it just doesn't work. I followed the tip at the end of api's description on CurseForge and tried to add given code, but after running gradlew build/runClient/somethingelse it doesn't seem to be able to find the api. This is the output I got in the console, something very wrong apparently: Click

I actually managed to add it within Eclipse environment by directly adding it to build path, but it only works within Eclipse, yet I still need gradle to compile the mod or at least launch testing client.

It wasn't a big deal on 1.7.10 I got used to, where I just manually put dependencies within .classpath file and everything worked perfectly. But here gradle just refuses to see the Curios or any other library - whether it's declared within build.gradle, or dropped into libs folder inside the project as deobfuscated version, or this same version pointed to via .classpath, or literally anything I've tried over the whole last day.

I give up. Help me please

commented

Show me your build.gradle file.

commented

So, I'll try to explain it the best I can from the top, so apologies if you know some of this already. If you want to add a dependency, there are a few ways to do it.

One way is through repositories. These can be local or remote, but you'll generally probably be dealing with remote repositories. These will require you to put a repository code block in your build.gradle, like so:

repositories {
}

Of course, that's just empty, it's not going to do anything. You need to specify which repositories you want to add, that way Gradle will know where to try and look for the files that you want. So, in this case, the Curios file exists in the https://maven.theillusivec4.top/ repository. You can browse through it in your browser to verify. Now you just add that url to your repository block, like so:

repositories {
    maven {
        url = "https://maven.theillusivec4.top/"
    }
}

This will add the specified url as a maven repository to our repositories, which is what we want since we want to look for Curios there. For any dependency you want to add from a maven repository, you'll need to find the appropriate maven url.

Next step, actually finding it. This is where we need to declare a dependency on Curios, so that gradle knows to try and look for it. We need to place that in the dependencies code block in our build.gradle, like so:

dependencies {
	minecraft 'net.minecraftforge:forge:1.14.4-28.0.24'
        compile fg.deobf('top.theillusivec4.curios:curios:FORGE-1.14.4-0.18')
}

Let's parse that out a bit. compile just tells Gradle that you'll need this dependency at compilation time. fg.deobf is a fairly new way of basically declaring that you want to deobfuscate the jar, which is necessary in order to re-map obfuscated jars to your particular mappings.

As far as the package naming goes, you can read about the naming scheme here. It's split up into group:artifactId:version. In Curios's case, it's:

  • group: top.theillusivec4.curios
  • artifactId: curios
  • version: FORGE-1.14.4-0.18

I don't have a lot of experience with adding local files, I tend to use remote repositories as much as I can. I believe the syntax would be something like compile fg.deobf(files([FILENAME])), but don't quote me on that.

That's basically the gist of it. If you'd like working examples of mods that implement Curios, feel free to explore the source code of some of my other mods:

commented

I've actually managed to get it to work after another hour of tortures yesterday - by reading through this issue and copying few strings from the build.gradle file you fixed for the guy there.
But I don't quite understand how it works, nor I know how to add dependency on a specific jar file on my hard drive rather than adding a repositories and specifying packages and versions. I know it's not your job or something, but I would really appreciate an understandable explanation and/or a working example I could follow.

Here is the build.gradle: Click