diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0908154 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,34 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +tab_width = 4 +trim_trailing_whitespace = true + +[*.gradle] +indent_style = tab + +[*.java] +indent_style = tab + +[*.json] +indent_style = space +indent_size = 2 + +[quilt.mod.json] +indent_style = tab +tab_width = 2 + +[*.toml] +indent_style = tab +tab_width = 2 + +[*.properties] +indent_style = space +indent_size = 2 + +[.editorconfig] +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore index a7ded9c..785c6a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,27 @@ -.idea -.gradle -build -run \ No newline at end of file +# Gradle +.gradle/ +build/ +out/ +classes/ + +# Quilt Loom +run/ + +# Eclipse +*.launch + +# IntelliJ Idea +.idea/ +*.iml +*.ipr +*.iws + +# Visual Studio Code +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macOS +*.DS_Store diff --git a/README.md b/README.md index b2eeb28..022f983 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,29 @@ -# quilt-example-mod -Official Quilt example mod. +# Quilt Example Mod +The official Quilt example mod. You can use it as a template for your own mods! -## To use this template -1. Click on `Use this Template` -2. Clone the resulted repo on your pc -3. Enjoy! +## Usage + +In order to use this mod as a template: + +1. Create a new repository from this template with `Use this template` +2. Clone the recently-created repo on your PC +3. Make the necessary changes in order to make it yours: + - Update `gradle.properties` in order to use your Maven group and mod ID + - If you don't know which Maven group to use, and you are planning to host the mod's source code on GitHub, use `io.github.` + - Update `quilt.mod.json` in order to reflect your mod's metadata + - If you are planning to include (jar-in-jar) a mod, don't forget to declare its dependency on it! + - The icon provided here is a placeholder one. If you aren't able to replace it yet, you can delete it and remove the "icon" property + - Create a LICENSE file for this mod! If you don't know which license to use, check out [here](https://choosealicense.com/). + - If you use `LICENSE.md`, don't forget to update the buildscript in order to use that file name! + - On `quilt.mod.json`, don't forget to put in `"metadata"` a `"license"` property that contains the license's [SPDX identifier](https://spdx.org/licenses/). + - The GPLv3 and AGPLv3 are not valid mod licenses, so you can use almost any license except for those. + - Update the Java sub-directory structure so it reflects your Maven group + - If the dependencies on `gradle/libs.versions.toml` isn't up-to-date, feel free to update them! The linked utility should help you in this easy and quick process. +4. The mod is now ready to be worked on! ## License -This template on the QuiltMC GitHub is licensed under the CC0 license. + +This template on the QuiltMC GitHub is licensed under the [Creative Common Zero v1.0 license](./LICENSE-TEMPLATE.md). + Mods created with this template are not automatically licensed under the CC0, and are not required to give any kind of credit back to QuiltMC for this template. diff --git a/build.gradle b/build.gradle index def6136..c4826ff 100644 --- a/build.gradle +++ b/build.gradle @@ -1,76 +1,83 @@ plugins { - id 'org.quiltmc.loom' version '0.12-SNAPSHOT' id 'maven-publish' + alias(libs.plugins.quilt.loom) } -group = maven_group +archivesBaseName = project.archives_base_name version = project.version -archivesBaseName = archives_base_name +group = project.maven_group repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. } +// All the dependencies are declared at gradle/libs.version.toml and referenced with "libs." +// See https://docs.gradle.org/current/userguide/platforms.html for information on how version catalogs work. dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:$minecraft_version" - mappings( loom.layered { - addLayer quiltMappings.mappings( "org.quiltmc:quilt-mappings:$minecraft_version+build.$quilt_mappings:v2" ) -// addLayer loom.officialMojangMappings() // uncomment if you want mojmap too - }) - modImplementation "org.quiltmc:quilt-loader:$loader_version" + minecraft libs.minecraft + mappings loom.layered { + addLayer quiltMappings.mappings("org.quiltmc:quilt-mappings:${libs.versions.quilt.mappings.get()}:v2") + // officialMojangMappings() // Uncomment if you want to use Mojang mappings as your primary mappings, falling back on QM for parameters and Javadocs + } + modImplementation libs.quilt.loader - modImplementation "org.quiltmc:qsl:$qsl_version" - - // QSL is not a complete API; you need Quilted Fabric API to fill in the gaps. - modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:$quilted_fapi_version-$minecraft_version" + // QSL is not a complete API; You will need Quilted Fabric API to fill in the gaps. + // Quilted Fabric API will automatically pull in the correct QSL version. + modImplementation libs.quilted.fabric.api } processResources { - inputs.property 'version', version - inputs.property 'maven_group', maven_group - inputs.property 'loader_version', loader_version - inputs.property 'minecraft_version', minecraft_version + inputs.property "version", version filesMatching('quilt.mod.json') { - expand([ - 'version': version, - 'maven_group': maven_group, - 'loader_version': loader_version, - 'minecraft_version': minecraft_version, - 'quilted_fabric_api_version': quilted_fapi_version - ]) + expand "version": version } } tasks.withType(JavaCompile).configureEach { - it.sourceCompatibility = 17 // for the IDE support - it.options.encoding = 'UTF-8' - it.options.release.set(17) + it.options.encoding = "UTF-8" + // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. + it.options.release = 17 } java { - // if this mod is gonna be a library, its better to generate javadocs too, uncomment this line to generate them - //withJavadocJar() + // Still required by IDEs such as Eclipse and Visual Studio Code + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task if it is present. // If you remove this line, sources will not be generated. withSourcesJar() + + // If this mod is going to be a library, then it should also generate Javadocs in order to aid with developement. + // Uncomment this line to generate them. + // withJavadocJar() } +// If you plan to use a different file for the license, don't forget to change the file name here! jar { - from('LICENSE') { - rename { "$it_$archivesBaseName"} + from("LICENSE") { + rename { "${it}_${archivesBaseName}" } } } +// Configure the maven publication publishing { publications { mavenJava(MavenPublication) { - group 'com.examplemod' from components.java } } + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - mavenLocal() + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. } } diff --git a/gradle.properties b/gradle.properties index cdb28e7..0f3bd13 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,10 @@ -# gradle stuff - org.gradle.jvmargs=-Xmx3G - org.gradle.parallel=true - org.gradle.caching=true - # uncomment this is gradle doesn't want to use more workers - #org.gradle.workers.max=4 -# Quilt Properties - # check these on https://lambdaurora.dev/tools/import_quilt.html - minecraft_version=1.18.2 - quilt_mappings=22 - loader_version=0.16.0-beta.7 +# Gradle Properties +org.gradle.jvmargs = -Xmx1G +org.gradle.parallel = true + # Mod Properties - version=1.0.0 - maven_group=com.example - archives_base_name=example-mod -# Dependencies - qsl_version=1.1.0-beta.2+1.18.2 - quilted_fapi_version=1.0.0-beta.5+0.48.0 +version = 1.0.0 +maven_group = com.example +archives_base_name = example_mod + +# Dependencies are managed at gradle/libs.versions.toml diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..ed1a21e --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,21 @@ +[versions] +# The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html +minecraft = "1.18.2" +quilt_mappings = "1.18.2+build.22" +quilt_loader = "0.16.0-beta.7" + +quilted_fabric_api = "1.0.0-beta.6+0.51.1-1.18.2" + +[libraries] +minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } +quilt_mappings = { module = "org.quiltmc:quilt-mappings", version.ref = "quilt_mappings" } +quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" } + +quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" } + +# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example". +# [bundles] +# example = ["example-a", "example-b", "example-c"] + +[plugins] +quilt_loom = { id = "org.quiltmc.loom", version = "0.12.+" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..41d9927 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 ffed3a2..aa991fc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index c53aefa..1b6c787 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # diff --git a/settings.gradle b/settings.gradle index ba90265..d969e34 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1,14 @@ pluginManagement { repositories { - maven { url 'https://maven.fabricmc.net' } - maven { url 'https://maven.quiltmc.org/repository/release' } - maven { url 'https://maven.quiltmc.org/repository/snapshot' } + maven { + name = 'Quilt' + url = 'https://maven.quiltmc.org/repository/release' + } + // Currently needed for Intermediary and other temporary dependencies + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } gradlePluginPortal() - mavenCentral() } } diff --git a/src/main/java/com/example/example_mod/ExampleMod.java b/src/main/java/com/example/example_mod/ExampleMod.java new file mode 100644 index 0000000..27b6648 --- /dev/null +++ b/src/main/java/com/example/example_mod/ExampleMod.java @@ -0,0 +1,18 @@ +package com.example.example_mod; + +import org.quiltmc.loader.api.ModContainer; +import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExampleMod implements ModInitializer { + // This logger is used to write text to the console and the log file. + // It is considered best practice to use your mod name as the logger's name. + // That way, it's clear which mod wrote info, warnings, and errors. + public static final Logger LOGGER = LoggerFactory.getLogger("Example Mod"); + + @Override + public void onInitialize(ModContainer mod) { + LOGGER.info("Hello Quilt world from {} v{}!", mod.metadata().name(), mod.metadata().version().raw()); + } +} diff --git a/src/main/java/com/examplemod/mixin/TitleScreenMixin.java b/src/main/java/com/example/example_mod/mixin/TitleScreenMixin.java similarity index 77% rename from src/main/java/com/examplemod/mixin/TitleScreenMixin.java rename to src/main/java/com/example/example_mod/mixin/TitleScreenMixin.java index c76ceed..070f855 100644 --- a/src/main/java/com/examplemod/mixin/TitleScreenMixin.java +++ b/src/main/java/com/example/example_mod/mixin/TitleScreenMixin.java @@ -1,6 +1,6 @@ -package com.examplemod.mixin; +package com.example.example_mod.mixin; -import com.examplemod.ExampleMod; +import com.example.example_mod.ExampleMod; import net.minecraft.client.gui.screen.TitleScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(TitleScreen.class) public class TitleScreenMixin { - @Inject( method = "init", at = @At("TAIL") ) + @Inject(method = "init", at = @At("TAIL")) public void onInit(CallbackInfo ci) { ExampleMod.LOGGER.info("This line is printed by an example mod mixin!"); } diff --git a/src/main/java/com/examplemod/ExampleMod.java b/src/main/java/com/examplemod/ExampleMod.java deleted file mode 100644 index e7fb014..0000000 --- a/src/main/java/com/examplemod/ExampleMod.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.examplemod; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; - -public class ExampleMod implements ModInitializer { - public static final Logger LOGGER = LogManager.getLogger("ExampleMod"); - - @Override - public void onInitialize(ModContainer mod) { - LOGGER.info( "Hello Quilt world from ExampleMod v{}!", mod.metadata().version().raw() ); - } -} diff --git a/src/main/resources/assets/example_mod/icon.png b/src/main/resources/assets/example_mod/icon.png new file mode 100644 index 0000000..4c539a4 Binary files /dev/null and b/src/main/resources/assets/example_mod/icon.png differ diff --git a/src/main/resources/examplemod.mixins.json b/src/main/resources/example_mod.mixins.json similarity index 71% rename from src/main/resources/examplemod.mixins.json rename to src/main/resources/example_mod.mixins.json index dca976c..a92cc78 100644 --- a/src/main/resources/examplemod.mixins.json +++ b/src/main/resources/example_mod.mixins.json @@ -1,13 +1,13 @@ { "required": true, "minVersion": "0.8", - "package": "com.examplemod.mixin", + "package": "com.example.example_mod.mixin", "compatibilityLevel": "JAVA_17", - "mixins": [ ], + "mixins": [], "client": [ "TitleScreenMixin" ], "injectors": { "defaultRequire": 1 } -} \ No newline at end of file +} diff --git a/src/main/resources/quilt.mod.json b/src/main/resources/quilt.mod.json index 10ee51f..5206e5a 100644 --- a/src/main/resources/quilt.mod.json +++ b/src/main/resources/quilt.mod.json @@ -1,8 +1,8 @@ { "schema_version": 1, "quilt_loader": { - "group": "${maven_group}", - "id": "examplemod", + "group": "com.example", + "id": "example_mod", "version": "${version}", "metadata": { "name": "Mod Name", @@ -10,33 +10,26 @@ "contributors": { "Me!": "Owner" }, - "icon": "assets/examplemod/icon.png" + "icon": "assets/example_mod/icon.png" }, "intermediate_mappings": "net.fabricmc:intermediary", "entrypoints": { - "init": [ - "com.examplemod.ExampleMod" - ] + "init": "com.example.example_mod.ExampleMod" }, "depends": [ { "id": "quilt_loader", - "versions": ">=${loader_version}" + "versions": ">=0.16.0-" }, { "id": "quilted_fabric_api", - "versions": "${quilted_fabric_api_version}" + "versions": ">=1.0.0-" }, { "id": "minecraft", - "versions": ">=${minecraft_version}" + "versions": ">=1.18.2" } ] }, - "mixin": [ - "examplemod.mixins.json" - ], - "minecraft": { - "environment": "*" - } + "mixin": "example_mod.mixins.json" }