From b092bf662d095bd75dc7ef618dc5553fd43a1ab8 Mon Sep 17 00:00:00 2001 From: Grayray75 <69988482+Grayray75@users.noreply.github.com> Date: Tue, 25 Jul 2023 22:42:16 +0200 Subject: [PATCH] Improve the readme a lot --- README.md | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 153 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 539a73b9e..11bfa673d 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,163 @@ # Fabric Example Mod -## Setup +- [Quick start guide](#quick-start-guide) + - [Introduction to the folder structure](#introduction-to-the-folder-structure) + - [Creating your mod](#creating-your-mod) + - [Useful gradle commands](#useful-gradle-commands) + - [More info](#more-info) +- [Useful gradle plugins](#useful-gradle-plugins) + - [Automated Modrinth publication](#automated-modrinth-publication) + - [Improved source decompilation](#improved-source-decompilation) + - [Adding mod dependencies](#adding-mod-dependencies) +- [License](#license) -1. Edit gradle.properties, build.gradle and mod.json to suit your needs. - * The "mixins" object can be removed from mod.json if you do not need to use mixins. - * Please replace all occurences of "modid" with your own mod ID - sometimes, a different string may also suffice. -2. Run the following command: +## Quick start guide + +### Introduction to the folder structure + +**Build files:** + +| File | Description | +| ------------------- | -------------------------------------------------------- | +| `build.gradle` | Configures the compilation process. | +| `gradle.properties` | Contains properties for Minecraft, fabric, and your mod. | +| `settings.gradle` | Configures the plugin repositories. | + +**Fabric files:** + +These files are located at `src/main/resources`. + +| File | Description | Additional information | +| ----------------------- | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | +| `fabric.mod.json` | Contains metadata about your mod. | [wiki:fabric_mod_json_spec](https://fabricmc.net/wiki/documentation:fabric_mod_json_spec) | +| `modid.mixins.json` | Contains a list of all your mixin files. | [wiki:mixin_registration](https://fabricmc.net/wiki/tutorial:mixin_registration) | +| `assets/modid/icon.png` | The icon of your mod. | [wiki:fabric_mod_json_spec#icon](https://fabricmc.net/wiki/documentation:fabric_mod_json_spec?s[]=icon#custom_fields) | + + +### Creating your mod + +First of you must replace all occurrences of `modid` with the id of your mod. + +If your mod doesn't use mixins you can safely remove the mixin entry in your `fabric.mod.json` as well as delete any `*.mixin.json` files. + +This template has the legacy fabric api included in it's build script, more info about the api can be found at it's [github repo](https://github.com/Legacy-Fabric/fabric). \ +If you know what you are doing you can also safely remove the api from the build script as it isn't required. + +### Useful gradle commands + +```sh +# Compile your mod +./gradlew build + +# Remove old build files +./gradlew clean + +# Generate Minecraft sources +./gradlew genSources + +# Launch a modded Minecraft client +./gradlew runClient + +# Kill gradle if it's doing stupid things +./gradlew --stop ``` -./gradlew + +### More info + +For more detailed setup instructions please see the [fabric wiki](https://fabricmc.net/wiki/tutorial:setup). + +If you are new to fabric or Minecraft modding in general then [this wiki page](https://fabricmc.net/wiki/tutorial:primer) may help you. + + +## Useful gradle plugins + +### Automated Modrinth publication + +The [minotaur](https://github.com/modrinth/minotaur) gradle plugin is a tool gradle plugin for deploying build artifacts to Modrinth. + +**Usage example:** + +`build.gradle` +```groovy +plugins { + id "com.modrinth.minotaur" version "2.+" +} + +modrinth { + token = System.getenv("MODRINTH_TOKEN") + + projectId = "my-mod" + + versionNumber = "${project.mod_version}" + versionName = "my-mod v${project.mod_version}" + versionType = "release" + + uploadFile = remapJar + gameVersions = ["1.8.9"] + loaders = ["fabric"] + dependencies { + required.project "legacy-fabric-api" + } +} ``` +To publish to Modrinth run: +```sh +./gradlew build modrinth +``` + +### Improved source decompilation + +By default the `genSources` task uses the fabric [cfr](https://github.com/FabricMC/cfr) decompiler to generate Minecraft sources. +Vineflower is a fork of the FernFlower decompiler which contains many enhancements and bug fixes, and generally produces much better source code. \ +With the [loom-vineflower](https://github.com/Juuxel/loom-vineflower) plugin it is possible to integrate it directly into your project. + +**Usage example:** + +`build.gradle` +```diff +plugins { ++ id 'io.github.juuxel.loom-vineflower' version "1.11.0" +} +``` + +Instead of `genSources`, you can now run: +```sh +./gradlew genSourcesWithVineflower +``` + +### Adding mod dependencies + +In oder to implement the api of a mod, for example to add your mod settings to [Mod Menu](https://modrinth.com/mod/legacy-mod-menu), it is required that you add that mod to your build script as a dependency with `modImplementation`. To simplify this setup Modrinth allows you to load mods directly from there maven. + +**Usage example:** + +`build.gradle` +```groovy +repositories { + exclusiveContent { + forRepository { + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + } + } + filter { + includeGroup "maven.modrinth" + } + } +} + +dependencies { + modImplementation "maven.modrinth:legacy-mod-menu:1.1.0" +} +``` + +More info about this can be found in the [Modrinth docs](https://docs.modrinth.com/docs/tutorials/maven/). \ +For more info about loom dependencies see the [fabric wiki](https://fabricmc.net/wiki/documentation:fabric_loom?s[]=dependencies#options). + + ## License This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.