Rework the template mod

This commit is contained in:
Ennui Langeweile 2022-04-20 16:02:00 -03:00
parent e7f3fd5a55
commit e9bb036ba0
No known key found for this signature in database
GPG key ID: 688A9E714BCD13B2
14 changed files with 165 additions and 96 deletions

31
.gitignore vendored
View file

@ -1,4 +1,27 @@
.idea # Gradle
.gradle .gradle/
build build/
run out/
classes/
# Quilt Loom
run/
# Eclipse
*.launch
# IntelliJ Idea
.idea/
*.iml
*.ipr
*.iws
# Visual Studio Code
.settings/
.vscode/
bin/
.classpath
.project
# MacOS
*.DS_Store

View file

@ -1,12 +1,24 @@
# quilt-example-mod # Quilt Example Mod
Official Quilt example mod.
The official Quilt example mod. You can use it as a template for you own mods!
## To use this template ## To use this template
1. Click on `Use this Template`
2. Clone the resulted repo on your pc 1. Create a new repository from this template with `Use this Template`
3. Enjoy! 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 `com.github.<Your_Username_Here>`
- Update `quilt.mod.json` in order to reflect your mod's metadata
- If you are planning to include 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!
- Update the Java sub-directory structure so it reflects your Maven group
4. The mod is now ready to be worked on!
## License ## 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. 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.

View file

@ -1,76 +1,87 @@
plugins { plugins {
id 'org.quiltmc.loom' version '0.12-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
alias(libs.plugins.quilt.loom)
} }
group = maven_group // Still required by IDEs such as Eclipse and Visual Studio Code
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.version version = project.version
archivesBaseName = archives_base_name group = project.maven_group
repositories { 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.<id>"
// See https://docs.gradle.org/current/userguide/platforms.html for information on how version catalogs work.
dependencies { dependencies {
// To change the versions see the gradle.properties file minecraft libs.minecraft
minecraft "com.mojang:minecraft:$minecraft_version" mappings loom.layered {
mappings( loom.layered { addLayer quiltMappings.mappings("org.quiltmc:quilt-mappings:${libs.versions.quilt.mappings.get()}:v2")
addLayer quiltMappings.mappings( "org.quiltmc:quilt-mappings:$minecraft_version+build.$quilt_mappings:v2" ) // addLayer loom.officialMojangMappings() // Uncomment if you want to use Mojang Mappings as a fallback
// addLayer loom.officialMojangMappings() // uncomment if you want mojmap too }
}) modImplementation libs.quilt.loader
modImplementation "org.quiltmc:quilt-loader:$loader_version"
modImplementation "org.quiltmc:qsl:$qsl_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.
// QSL is not a complete API; you need Quilted Fabric API to fill in the gaps. modImplementation libs.quilted.fabric.api
modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:$quilted_fapi_version-$minecraft_version"
} }
processResources { processResources {
inputs.property 'version', version inputs.property "version", version
inputs.property 'maven_group', maven_group inputs.property "group", group
inputs.property 'loader_version', loader_version
inputs.property 'minecraft_version', minecraft_version
filesMatching('quilt.mod.json') { filesMatching('quilt.mod.json') {
expand([ expand(
'version': version, "version": version,
'maven_group': maven_group, "group": group
'loader_version': loader_version, )
'minecraft_version': minecraft_version,
'quilted_fabric_api_version': quilted_fapi_version
])
} }
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
it.sourceCompatibility = 17 // for the IDE support it.options.encoding = "UTF-8"
it.options.encoding = 'UTF-8' // Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release.set(17) it.options.release.set(17)
} }
java { java {
// if this mod is gonna be a library, its better to generate javadocs too, uncomment this line to generate them
//withJavadocJar()
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task if it is present. // 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. // If you remove this line, sources will not be generated.
withSourcesJar() 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 { jar {
from('LICENSE') { from("LICENSE") {
rename { "$it_$archivesBaseName"} rename { "${it}_${archivesBaseName}" }
} }
} }
// Configure the maven publication
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
group 'com.examplemod'
from components.java from components.java
} }
} }
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories { 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.
} }
} }

View file

@ -1,18 +1,9 @@
# gradle stuff # Gradle Properties
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs = -Xmx1G
org.gradle.parallel=true org.gradle.parallel = true
org.gradle.caching=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
# Mod Properties # Mod Properties
version=1.0.0 version = 1.0.0
maven_group=com.example maven_group = com.example
archives_base_name=example-mod 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

21
gradle/libs.versions.toml Normal file
View file

@ -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.5+0.48.0-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-SNAPSHOT" }

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

10
gradlew vendored
View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# Copyright © 2015-2021 the original authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with 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 # Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features: # requires all of these POSIX shell features:
# * functions; # * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»; # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»; # * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit». # * various built-in commands including «command», «set», and «ulimit».
# #
# Important for patching: # Important for patching:
# #

View file

@ -1,9 +1,23 @@
pluginManagement { pluginManagement {
repositories { repositories {
maven { url 'https://maven.fabricmc.net' } maven {
maven { url 'https://maven.quiltmc.org/repository/release' } name = 'Quilt'
maven { url 'https://maven.quiltmc.org/repository/snapshot' } url = 'https://maven.quiltmc.org/repository/release'
}
maven {
name = 'Quilt Snapshot'
url = 'https://maven.quiltmc.org/repository/snapshot'
}
// Currently needed for Intermediary and other temporary dependencies
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
// Temporarily required until we update Loom Quiltflower
maven {
name = 'Cotton'
url = 'https://server.bbkr.space/artifactory/libs-release/'
}
gradlePluginPortal() gradlePluginPortal()
mavenCentral()
} }
} }

View file

@ -1,4 +1,4 @@
package com.examplemod; package com.example.example_mod;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -6,10 +6,13 @@ import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger("ExampleMod"); // This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LogManager.getLogger("Example Mod");
@Override @Override
public void onInitialize(ModContainer mod) { public void onInitialize(ModContainer mod) {
LOGGER.info( "Hello Quilt world from ExampleMod v{}!", mod.metadata().version().raw() ); LOGGER.info("Hello Quilted world!");
} }
} }

View file

@ -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 net.minecraft.client.gui.screen.TitleScreen;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class) @Mixin(TitleScreen.class)
public class TitleScreenMixin { public class TitleScreenMixin {
@Inject( method = "init", at = @At("TAIL") ) @Inject(method = "init", at = @At("TAIL"))
public void onInit(CallbackInfo ci) { public void onInit(CallbackInfo ci) {
ExampleMod.LOGGER.info("This line is printed by an example mod mixin!"); ExampleMod.LOGGER.info("This line is printed by an example mod mixin!");
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -1,9 +1,9 @@
{ {
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "com.examplemod.mixin", "package": "com.example.example_mod.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"mixins": [ ], "mixins": [],
"client": [ "client": [
"TitleScreenMixin" "TitleScreenMixin"
], ],

View file

@ -1,8 +1,8 @@
{ {
"schema_version": 1, "schema_version": 1,
"quilt_loader": { "quilt_loader": {
"group": "${maven_group}", "group": "${group}",
"id": "examplemod", "id": "example_mod",
"version": "${version}", "version": "${version}",
"metadata": { "metadata": {
"name": "Mod Name", "name": "Mod Name",
@ -10,33 +10,27 @@
"contributors": { "contributors": {
"Me!": "Owner" "Me!": "Owner"
}, },
"icon": "assets/examplemod/icon.png" "license": "ARR",
"icon": "assets/example_mod/icon.png"
}, },
"intermediate_mappings": "net.fabricmc:intermediary", "intermediate_mappings": "net.fabricmc:intermediary",
"entrypoints": { "entrypoints": {
"init": [ "init": "com.example.example_mod.ExampleMod"
"com.examplemod.ExampleMod"
]
}, },
"depends": [ "depends": [
{ {
"id": "quilt_loader", "id": "quilt_loader",
"versions": ">=${loader_version}" "versions": ">=0.16.0-"
}, },
{ {
"id": "quilted_fabric_api", "id": "quilted_fabric_api",
"versions": "${quilted_fabric_api_version}" "versions": ">=1.0.0-"
}, },
{ {
"id": "minecraft", "id": "minecraft",
"versions": ">=${minecraft_version}" "versions": ">=1.18.2"
} }
] ]
}, },
"mixin": [ "mixin": "example_mod.mixins.json"
"examplemod.mixins.json"
],
"minecraft": {
"environment": "*"
}
} }