diff --git a/README.md b/README.md index d927abd..d86bde4 100644 --- a/README.md +++ b/README.md @@ -35,14 +35,23 @@ A template to allow easy usage of the Meteor Addon API. To update this template to a newer Minecraft version, follow these steps: 1. Ensure a Meteor Client snapshot is available for the new Minecraft version. -2. Update `gradle.properties`: - - Set `minecraft_version`, `yarn_mappings` and `loader_version` to the new version. - - Update any additional dependencies accordingly. +2. Update `gradle/libs.versions.toml` (the versions catalog): + - Set the version entries to the new versions. Common keys to update are: + - `versions.minecraft` - Minecraft version + - `versions.yarn-mappings` - Yarn mappings + - `versions.fabric-loader` - Fabric loader version + - `versions.meteor` - Meteor Client snapshot version + - If your addon depends on other libraries listed under the `[libraries]` section, update their versions there as + needed. + - After editing, refresh Gradle dependencies and rebuild your project in the IDE. 3. Update Loom: - - Change the `loom_version` in `build.gradle.kts` to the latest version compatible with the new Minecraft version. + - Change the `loom` version in `gradle/libs.versions.toml` (the `versions.loom` entry) to the latest version + compatible with the new Minecraft version. 4. Update the Gradle wrapper: - - You can find the latest Gradle version [here](https://gradle.org/releases/). - - Run the `./gradlew wrapper --gradle-version ; ./gradlew wrapper` command to update the wrapper script. + - Run the wrapper update command for your platform. Examples: + - Unix / macOS / Windows (Powershell): `./gradlew wrapper --gradle-version && ./gradlew wrapper` + - Windows (cmd.exe): `gradlew.bat wrapper --gradle-version && gradlew.bat wrapper` + - This updates and regenerates the Gradle Wrapper scripts (`gradlew`, `gradlew.bat`, etc.) for the specified version. 5. Update your source code: - Adjust for Minecraft or Yarn mapping changes: method names, imports, mixins, etc. - Check for Meteor Client API changes that may affect your addon by comparing against the @@ -60,6 +69,7 @@ To update this template to a newer Minecraft version, follow these steps: │ │── dev_build.yml │ ╰── pull_request.yml │── gradle +│ │── libs.versions.toml │ ╰── wrapper │ │── gradle-wrapper.jar │ ╰── gradle-wrapper.properties @@ -97,8 +107,10 @@ This is the default project structure. Each folder/file has a specific purpose. Here is a brief explanation of the ones you might need to modify: - `.github/workflows`: Contains the GitHub Actions configuration files. -- `gradle`: Contains the Gradle wrapper files. - Edit the `gradle.properties` file to change the version of the Gradle wrapper. +- `gradle`: Contains the Gradle wrapper files and the versions catalog. + - `libs.versions.toml`: Defines version numbers for Minecraft, Loom, Meteor, and other dependencies. + - `wrapper`: Contains the Gradle wrapper executable files. + To update the Gradle wrapper executable itself, run the wrapper update command (examples are shown above). - `src/main/java/com/example/addon`: Contains the main class of the addon. Here you can register your custom commands, modules, and HUDs. Edit the `getPackage` method to reflect the package of your addon. @@ -115,8 +127,9 @@ Here is a brief explanation of the ones you might need to modify: - `build.gradle.kts`: Contains the Gradle build script. You can manage the dependencies of the addon here. Remember to keep the `fabric-loom` version up-to-date. -- `gradle.properties`: Contains the properties of the Gradle build. - These will be used by the build script. +- `gradle.properties`: Contains additional build properties used by the build script + (for example `maven_group` and `archives_base_name`). + Dependency and platform version numbers are stored in `gradle/libs.versions.toml`. - `LICENSE`: Contains the license of the addon. You can edit this file to change the license of your addon. - `README.md`: Contains the documentation of the addon. diff --git a/build.gradle.kts b/build.gradle.kts index 1e7d88d..9bc4bcb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,10 @@ plugins { - id("fabric-loom") version "1.11-SNAPSHOT" + alias(libs.plugins.fabric.loom) } base { archivesName = properties["archives_base_name"] as String - version = properties["mod_version"] as String + version = libs.versions.mod.version.get() group = properties["maven_group"] as String } @@ -21,19 +21,19 @@ repositories { dependencies { // Fabric - minecraft("com.mojang:minecraft:${properties["minecraft_version"] as String}") - mappings("net.fabricmc:yarn:${properties["yarn_mappings"] as String}:v2") - modImplementation("net.fabricmc:fabric-loader:${properties["loader_version"] as String}") + minecraft(libs.minecraft) + mappings(variantOf(libs.yarn) { classifier("v2") }) + modImplementation(libs.fabric.loader) // Meteor - modImplementation("meteordevelopment:meteor-client:${properties["minecraft_version"] as String}-SNAPSHOT") + modImplementation(libs.meteor.client) } tasks { processResources { val propertyMap = mapOf( "version" to project.version, - "mc_version" to project.property("minecraft_version"), + "mc_version" to libs.versions.minecraft.get() ) inputs.properties(propertyMap) diff --git a/gradle.properties b/gradle.properties index d48077f..fb7c215 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,6 @@ org.gradle.jvmargs=-Xmx2G org.gradle.configuration-cache=false -# Fabric Properties (https://fabricmc.net/develop) -minecraft_version=1.21.10 -yarn_mappings=1.21.10+build.2 -loader_version=0.17.3 - # Mod Properties -mod_version=0.1.0 maven_group=com.example archives_base_name=addon-template - -# Dependencies diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..122642d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,29 @@ +[versions] +mod-version = "0.1.0" + +# Fabric (https://fabricmc.net/develop) +minecraft = "1.21.10" +yarn-mappings = "1.21.10+build.2" +fabric-loader = "0.17.3" + +# Loom (https://github.com/FabricMC/fabric-loom) +loom = "1.12-SNAPSHOT" + +# Meteor (https://github.com/MeteorDevelopment/meteor-client/) +meteor = "1.21.10-SNAPSHOT" + +# Mods + +[libraries] +# Fabric base +minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } +yarn = { module = "net.fabricmc:yarn", version.ref = "yarn-mappings" } +fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" } + +# Meteor client +meteor-client = { module = "meteordevelopment:meteor-client", version.ref = "meteor" } + +# Mods + +[plugins] +fabric-loom = { id = "fabric-loom", version.ref = "loom" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60..f8e1ee3 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e11132..bad7c24 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index a7f3f56..3cb0b33 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,3 +8,5 @@ pluginManagement { gradlePluginPortal() } } + +rootProject.name = "addon-template"