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
build
run
# 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

View File

@ -1,12 +1,24 @@
# quilt-example-mod
Official Quilt example mod.
# Quilt Example Mod
The official Quilt example mod. You can use it as a template for you own mods!
## To use this template
1. Click on `Use this Template`
2. Clone the resulted repo on your pc
3. Enjoy!
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 `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
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.

View File

@ -1,76 +1,87 @@
plugins {
id 'org.quiltmc.loom' version '0.12-SNAPSHOT'
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
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.<id>"
// 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")
// addLayer loom.officialMojangMappings() // Uncomment if you want to use Mojang Mappings as a fallback
}
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
inputs.property "group", group
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,
"group": group
)
}
}
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)
}
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.
// 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.
}
}

View File

@ -1,18 +1,9 @@
# 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
org.gradle.caching = 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

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
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

10
gradlew vendored
View File

@ -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:
#

View File

@ -1,9 +1,23 @@
pluginManagement {
repositories {
maven { url 'https://maven.fabricmc.net' }
maven { url 'https://maven.quiltmc.org/repository/release' }
maven { url 'https://maven.quiltmc.org/repository/snapshot' }
gradlePluginPortal()
mavenCentral()
}
repositories {
maven {
name = 'Quilt'
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()
}
}

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.Logger;
@ -6,10 +6,13 @@ 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");
// 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
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 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!");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

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

View File

@ -1,8 +1,8 @@
{
"schema_version": 1,
"quilt_loader": {
"group": "${maven_group}",
"id": "examplemod",
"group": "${group}",
"id": "example_mod",
"version": "${version}",
"metadata": {
"name": "Mod Name",
@ -10,33 +10,27 @@
"contributors": {
"Me!": "Owner"
},
"icon": "assets/examplemod/icon.png"
"license": "ARR",
"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"
}