Huan Sheng Tew
Huan Sheng Tew

Reputation: 22

How to add in third party API/library to Minecraft Fabric project?

I just starting learning minecraft modding today.

I had successfully added a custom items into minecraft, now I want to start learning how to use third party API like trinkets and cloth config to my project.

But I can't seem to find any online tutorials that tell you how to do that.

For now I added this into my build.gradle:

repositories {
// Trinkets API
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/releases"
}
maven {
name = "Ladysnake Libs"
url = 'https://maven.ladysnake.org/releases'
}
// Cloth Config
maven {
url "https://maven.shedaniel.me/"
}
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
// Trinkets API
modImplementation "dev.emi:trinkets:${trinkets_version}"
// Cloth Config
modApi "me.shedaniel.cloth:cloth-config-fabric:11.1.106" {
exclude(group: "net.fabricmc.fabric-api")
}
}

That's all the things I had done to my project, just adding these lines to the build.gradle.

I also had tried to add the .jar files for cloth config and trinkets inside my mod-id/build/libs folders, but still does works.

This is my output error:

[error] FAILURE: Build failed with an exception.
* Where:
Build file 'E:\MinecraftModProject\Fabric\shengs-wearable\shengs-wearable-template-1.20.1\build.gradle' line: 83
* What went wrong:
A problem occurred evaluating root project 'shengs-wearable-template-1.20.1'.
> Could not get unknown property 'trinkets_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
CONFIGURE FAILED in 6s
[error] [gradle-server] The supplied build action failed with an exception.
[error] Error getting build for e:\MinecraftModProject\Fabric\shengs-wearable\shengs-wearable-template-1.20.1: The supplied build action failed with an exception.
[info] Java Home: C:\Program Files\Java\jdk-17
[info] JVM Args: --add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx1G,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant
[info] Gradle User Home: C:\Users\sheng\.gradle
[info] Gradle Version: 8.3
[info] > Configure project :
Fabric Loom: 1.4.4
[error] FAILURE: Build failed with an exception.
* Where:
Build file 'E:\MinecraftModProject\Fabric\shengs-wearable\shengs-wearable-template-1.20.1\build.gradle' line: 83
* What went wrong:
A problem occurred evaluating root project 'shengs-wearable-template-1.20.1'.
> Could not get unknown property 'trinkets_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
CONFIGURE FAILED in 181ms
[error] [gradle-server] The supplied build action failed with an exception.
[error] Error getting build for e:\MinecraftModProject\Fabric\shengs-wearable\shengs-wearable-template-1.20.1: The supplied build action failed with an exception.
[info] Found 0 tasks
[info] Build file opened: e:\MinecraftModProject\Fabric\shengs-wearable\shengs-wearable-template-1.20.1\build.gradle

Upvotes: 0

Views: 807

Answers (1)

zly2006
zly2006

Reputation: 21

You should add trinkets_version=<your version> into your gradle.properties file.

You can see all available versions at https://maven.terraformersmc.com/releases/dev/emi/trinkets/

Upvotes: 1

Related Questions