Adding Quilt to RestApi!


With this guide, you will be able to integrate Quilt with RestApi to reach a wider audience with your mod.
Keep in mind that we will require the Quilt QSL library.

Author: restonic4

Published on: 22/11/2023

What do we need?


As mentioned in the first post about RestApi, you will need a code editor, the two necessary plugins for the code editor (or a project template), integrated RestApi, and an already created project.

If you don't know how to do all this, you can read this post to prepare your mod.

Creating the Files


First, in the main folder of your project, you will need to create a folder called quilt. Inside the quilt folder, add another folder called src. Inside src, create a folder named main, and within main, create two more folders: one called java and another called resources.

Inside the java folder, you'll need to add several nested folders. The names and quantity will depend on how you have configured your project, so I recommend looking at the common, src, java folders and observing the structure they follow. In the end, you'll need to create a folder called quilt and inside it, a script. I recommend ending the name with Quilt to make it easier to differentiate.

Inside the resources folder, you only need to add a file named quilt.mod.json.

RestApi with quilt files

Now, we will add two files inside the quilt folder, build.gradle and gradle.properties.

Configuration and Programming of Files


Now it's time to program the files to integrate Quilt.

First, navigate to the main folder of your project and open settings.gradle. In that file, you'll need to put the following exactly as shown:

        
pluginManagement {
    repositories {
        maven { url "https://maven.fabricmc.net/" }
        maven { url "https://maven.architectury.dev/" }
        maven { url "https://maven.minecraftforge.net/" }
        mavenCentral()
        gradlePluginPortal()
    }
}

include("common")
include("fabric")
include("forge")
include("quilt")
        
    

Now, go to the quilt folder created earlier and edit build.gradle. It should look something like this:

        
plugins {
    id "com.github.johnrengelman.shadow" version "7.1.2"
}

repositories {
    maven { url "https://maven.quiltmc.org/repository/release/" }
}

architectury {
    platformSetupLoomIde()
    loader("quilt")
}

loom {
    accessWidenerPath = project(":common").loom.accessWidenerPath
}

configurations {
    common
    shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
    compileClasspath.extendsFrom common
    runtimeClasspath.extendsFrom common
    developmentQuilt.extendsFrom common
}

dependencies {
    modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}"
    modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}"
    // Remove the next few lines if you don't want to depend on the API
    modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") {
        // We must not pull Fabric Loader from Architectury Fabric
        exclude group: "net.fabricmc"
        exclude group: "net.fabricmc.fabric-api"
    }

    common(project(path: ":common", configuration: "namedElements")) { transitive false }
    shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false }
}

processResources {
    inputs.property "group", rootProject.maven_group
    inputs.property "version", project.version

    filesMatching("quilt.mod.json") {
        expand "group": rootProject.maven_group,
                "version": project.version
    }
}

shadowJar {
    exclude "architectury.common.json"

    configurations = [project.configurations.shadowCommon]
    archiveClassifier.set("dev-shadow")
}

remapJar {
    injectAccessWidener = true
    inputFile.set shadowJar.archiveFile
    dependsOn shadowJar
    archiveClassifier.set(null)
}

jar {
    archiveClassifier.set("dev")
}

sourcesJar {
    def commonSources = project(":common").sourcesJar
    dependsOn commonSources
    from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
    withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
        skip()
    }
}
        
    

Also, edit the gradle.properties file to look like this:

        
loom.platform=quilt
        
    

Now, go to quilt.mod.json, located in quilt/resources, and it should be similar to this:

        
{
  "schema_version": 1,

  "quilt_loader": {
    "group": "${group}",
    "id": "slimeboots",
    "version": "${version}",
    "metadata": {
      "name": "Slime boots",
      "description": "",
      "contributors": {},
      "contact": {},
      "icon": "icon.png"
    },

    "intermediate_mappings": "net.fabricmc:intermediary",
    "entrypoints": {
      "init": [
        "me.restonic4.slimeboots.quilt.SlimeBootsQuilt"
      ]
    },
    "depends": [
      {
        "id": "quilt_loader",
        "versions": ">=0.18.10"
      },
      {
        "id": "quilted_fabric_api",
        "versions": ">=4.0.0"
      },
      {
        "id": "minecraft",
        "versions": "=1.19.3"
      },
      {
        "id": "architectury",
        "version": ">=7.1.86"
      },
      {
        "id": "architectury",
        "version": ">=7.1.86"
      },
      {
        "id": "restapi",
        "version": "=0.10-1.19.3-quilt"
      }
    }
  }
}
        
    

In quilt.mod.json, you'll need to change the parameters id, name, description, contributors, contact, icon, entrypoints -> init, and the versions in depends.

Now, go to the script inside the java folder. It should be like this, but you'll need to modify the names to fit your mod:

        
package me.restonic4.slimeboots.quilt;

import me.restonic4.slimeboots.SlimeBoots;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;

public class SlimeBootsQuilt implements ModInitializer {
    @Override
    public void onInitialize(ModContainer mod) {
        SlimeBoots.init();
    }
}
        
    

With this, we finish with the quilt folder. Now, there's only one more file left, and everything will be ready.

Finally, go to common and then to build.gradle. You'll need to edit the file and include quilt in a function:

        
architectury {
    common("fabric", "forge", "quilt")//Add quilt here, you will see fabric and forge by default.
}
        
    

¡Fin!


And with this, you have Quilt configured with your project and with RestApi. I hope this post has been helpful!

Here is the documentation in case it helps you when using our API.