Skip to content

Commit

Permalink
Initial Commit (maybe)
Browse files Browse the repository at this point in the history
  • Loading branch information
LopyMine committed Jul 11, 2024
1 parent 505fa1c commit 53fe99d
Show file tree
Hide file tree
Showing 163 changed files with 4,250 additions and 528 deletions.
168 changes: 31 additions & 137 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,139 +1,33 @@
<img src="src/main/resources/icon/icon.png" align="right" width="190px" alt="mod logo"/>

### Mossy - Template Fabric Mod

---

Mossy is a template Fabric mod with some additional tweaks and code templates.

### Tweaks and templates
---
### Done
1) Multi-version modding by [Stonecutter](https://stonecutter.kikugie.dev/) plugin
2) Easy player setting (uuid and nickname)
3) Mod Menu Integration
4) Fast YACL configuration for config screen (WIP)
5) Mod Config template
6) Versioned AWs and Mixins
7) Fast `gradle.properties`, AWs and mixins generation for each version (for 1st point)
8) Split run folder for `runs/client` and `runs/server`
### Planned
9) Add support for multi-loaders

# How to set up it
Basically, there are two ways:
1) You can fork this template mod and make your mod
2) You can integrate Mossy build system into your ready-made mod

But we will focus on the second way. In this way you will need to copy files `stonecutter.gradle`, `settings.gradle`, `gradle.properties`, `build.gradle`, `LICENSE`, `Mossy/src/main/resources/fabric.mod.json` and optional `.gitignore`.

Then you will need to set up `gradle.properties`.

## About `gradle.properties`
- `Mod Properties` contains mod info
- `Main Dependencies` like `Build Dependencies`, but not versioned
- `Build Dependencies` contains build properties, usually they versioned
- `Multi-Versions` basically contains only one property, it's a `multi_versions`, versions in it should be separated with space ' '
- `Additional Dependencies` contains additional depends, and you can add it easily:
```properties
# If you want to have it versioned, just write:
dep.MOD_ID=[VERSIONED]
# and add this property to every `Mossy/versions/[MINECRAFT VERSION]/gradle.properties`, if it's boring for you, just remove `gradle.properties` and reload gradle, each `gradle.properties` with last versions of depends will be generated.
#
# If you want to have static version, just write:
dep.MOD_ID=MOD_VERSION
#
# READ ME
# MOD_ID should be taken from Modrinth.
# `dep.` part is important.
```

After you can reload gradle and check all updates.

Also don't forgot to add your dependency in `build.gradle` with this value

## About Mixins and AWs

After reloading gradle, in your `resources` folder you will find `mixins` and `aws` folders. In them, you will find generated mixins and AWs for each minecraft version. What version they are for is indicated in their name.

You might be surprised that all mixins have a `.json5` extension instead of `.json`. This is needed to support comments which are needed for the [Stonecutter](https://stonecutter.kikugie.dev/) plugin. In build all mixins will be converted to `.json` by [j52j](https://github.com/kikugie/j52j).

To understand how comments work, I recommend to check the [Stonecutter docs](https://stonecutter.kikugie.dev/stonecutter/introduction).

AWs, in turn, have nothing unusual.

## About `fabric.mod.json`
In Mossy, `fabric.mod.json` has some features you should know, here are the main ones:
```json5
// ...
// Other code
"depends": {
"fabricloader": ">=${fabric_loader}",
"minecraft": ">=${minecraft}",
"java": ">=${java}",
"fabric-api": ">=${fabric_api}"
}, // needs because we have multi-versions
"accessWidener": "aws/${minecraft}.accesswidener", // needs to get path to AW for current minecraft version
"mixins": [
"mixins/${minecraft}-${modId}.mixins.json" // needs to get path to mixing config for current minecraft version
]
// Other code
// ...
```

## About `player/player.properties`

`Mossy/player/player.properties` is just a properties file, which uses to set up minecraft runs config with properties, to set up your nickname and uuid if they are present. If you want to add it, just create `player` folder in your project, and file `player.properties` with this content:

```properties
# Player properties
# If you don't want to change any properties, just remove it
player_nickname=Cool boy
player_uuid=Your UUID here
# After changes, you need to delete "/.idea/runConfigurations" folder and reopen project and reload gradle
```

## About `.json5` files
At now plugin j52j will convert all `.json5` files in `Mossy/src/main/resources/` to `.json` in build, check [this](https://github.com/kikugie/j52j?tab=readme-ov-file#configuring-the-plugin) if you wanna to safe some files from converting.

# How to use it

## Switching current minecraft version

After settings and reloading gradle, you should have gradle tasks in the `stonecutter` category, select the one and you will switch the active minecraft version of the game to the selected one.
- `Refresh active project` will refresh project and update comments.
- `Reset active project` will switch current minecraft version to first of the `multi_versions` in main `gradle.properties` file.

You can check current minecraft version in `stonecutter.gradle` file.
For more info check the [Stonecutter docs](https://stonecutter.kikugie.dev/stonecutter/introduction).

<details>
<summary>Showcase</summary>
<br>
<img src="img/switching_version.gif" width="400" alt="Showcase"/>
</details>

## Launching current minecraft version
To run current minecraft version with your mod you will need to execute run configuration with the same version, that in `stonecutter.gradle`, to switch it, read previous text above.

Also, your game folder is now split to `Mossy/runs/client` and `Mossy/runs/server`, boop.

<details>
<summary>Showcase</summary>
<br>
<img src="img/launching_minecraft.gif" width="600" alt="Showcase"/>
<img src="img/launched_mod.png" width="600" alt="Showcase"/>
</details>

## Building mod
To build your mod for each minecraft version which you write in main `gradle.properties`, you can just start specified gradle task `chiseledBuild` in `project` group, after execution you can go to `Mossy/versions/[MINECRAFT VERSION]/build/libs/your_builded_mod.jar`.

<details>
<summary>Showcase</summary>
<br>
<img src="img/building_mod.gif" width="400" alt="Showcase"/>

And after executing `chiseledBuild` task you can check your mods, here is example for minecraft 1.20.1:

<img src="img/mod.png" width="500" alt="Showcase"/>
</details>
[![Discord link to the "LopyMine's Project" discrod server](https://cdn.modrinth.com/data/cached_images/219842bdb5bbef9c2038ec2cc67a350a3fa092fd.png)](https://discord.gg/NZzxdkrV4s)


## My Totem Doll
### Description

My Totem Doll — Simple Client-Side Fabric mod which replaces all totems with player dolls. You can rename your totem to player's nickname to use it's skin. Also supports capes!

![Dolls](img/dolls.png)

## Configuration

You can configure the rendering of totems in first person. Open My Totem Doll configuration screen from Mod Menu and go to the `Rendering` tab, there you will find options for configruing the left and right hand:

![Showcase](img/configuration.png)

## Refresh Player Skins

My Totem Doll also has some commands for refreshing the totem skins:

`/my-totem-doll refresh all` - To refresh skins for all loaded players.

`/my-totem-doll refresh player [<NICKNAME>]` - To refresh skin for specific player.

![Showcase](img/refreshing_skins.webp)

## Multiplayer Support

You can also see other players' totems! **Without mod on the server.**

![Demonstration of how player "Lime_Krip_" holds a totem with the player nickname "_MrDragon_"](img/multiplayer.png)
33 changes: 28 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.6-SNAPSHOT"
id "fabric-loom" version "1.7-SNAPSHOT"
id "dev.kikugie.j52j" version "1.0.2"
}

Expand Down Expand Up @@ -40,6 +40,10 @@ repositories {
name 'Xander Maven' // YACL
url 'https://maven.isxander.dev/releases'
}
maven {
url "https://maven.nucleoid.xyz/"
name "Nucleoid"
} // For Mod Menu, because at 1.20.4 it needs PlaceHolder API, see https://github.com/TerraformersMC/ModMenu/issues/752
}

dependencies {
Expand All @@ -52,10 +56,13 @@ dependencies {
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"

// Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabricAPI}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabricAPI}"

// Mod Menu
modImplementation "com.terraformersmc:modmenu:${findProperty("dep.modmenu")}"
if (stonecutter.compare(minecraftVersion, "1.20.4") == 0) {
modImplementation "eu.pb4:placeholder-api:2.4.0-pre.1+1.20.4"
} // For Mod Menu, because at 1.20.4 it needs PlaceHolder API, see https://github.com/TerraformersMC/ModMenu/issues/752

// YACL
def minecraftVersionsWithOldYACLMaven = Set.of("1.19.4", "1.20", "1.20.2", "1.20.3")
Expand All @@ -76,14 +83,14 @@ loom {
defaultRefmapName.set("${modId}.refmap.json")
}

def accessWidenerFile = project.rootProject.file("src/main/resources/aws/${minecraftVersion}-${modId}.accesswidener")
def accessWidenerFile = project.rootProject.file("src/main/resources/aws/${minecraftVersion}.accesswidener")
if (accessWidenerFile.exists()) {
accessWidenerPath = accessWidenerFile
}

def playerProperties = getPlayerProperties()
def playerNickname = playerProperties.contains("player_nickname") ? playerProperties.get("player_nickname") : null // Your in-game nickname
def playerUuid = playerProperties.contains("player_uuid") ? playerProperties.get("player_uuid") : null // Your in-game uuid
def playerNickname = playerProperties.get("player_nickname") // Your in-game nickname
def playerUuid = playerProperties.get("player_uuid") // Your in-game uuid

runConfigs.configureEach { config ->
config.setIdeConfigGenerated(true) // generate IDE tasks for running client, server and testmod, datagen if those are present
Expand Down Expand Up @@ -132,18 +139,34 @@ processResources {
it.exclude()
}
}

filesMatching("mixins/yacl/*.mixins.json5") {
if (!it.getName().startsWith(minecraftVersion)) {
it.exclude()
}
}
}

stonecutter {
swap("mod_version", "\"${findProperty("mod_version")}\";")
swap("mod_id", "\"${findProperty("mod_id")}\";")
swap("mod_name", "\"${findProperty("mod_name")}\";")

def yaclVersion = findProperty("dep.yacl").toString()
swap("yacl_version", "\"${yaclVersion.substring(0, yaclVersion.indexOf("+"))}\";")
}

tasks.withType(JavaCompile).configureEach {
it.options.release = (javaVersion as int)
}

tasks.register('buildAndCollect', Copy) {
group = 'build'
from(tasks.remapJar.archiveFile)
into(rootProject.layout.buildDirectory.file("libs/"))
dependsOn('build')
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ org.gradle.jvmargs=-Xmx5G
org.gradle.parallel=true

# Mod Properties
mod_id = mossy
mod_name = Mossy
mod_id = my_totem_doll
mod_name = My Totem Doll
mod_version = 1.0.0
mod_group = net.lopymine.mossy
mod_group = net.lopymine.mtd

mod_description = Template Fabric mod with some additional tweaks and templates for my projects
mod_authors = LopyMine
mod_description = Simple Fabric mod which replaces all totems with player dolls.
mod_authors = LopyMine, KlashRaick
mod_license = GPL-2.0

# Main Dependencies
lombok_version = 1.18.32

# Multi-Versions
# Verified version: 1.20 1.20.1 1.20.2 1.20.3 1.20.4 1.20.5 1.20.6
multi_versions = 1.20.6 1.20.1
multi_versions = 1.20 1.20.1 1.20.2 1.20.3 1.20.4 1.20.5 1.20.6 1.21

# Build Dependencies
build.yarn = [VERSIONED]
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Binary file added img/banner.webp
Binary file not shown.
Binary file removed img/building_mod.gif
Binary file not shown.
Binary file added img/configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/dolls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/launched_mod.png
Binary file not shown.
Binary file removed img/launching_minecraft.gif
Binary file not shown.
Binary file removed img/mod.png
Binary file not shown.
Binary file added img/multiplayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/refreshing_skins.webp
Binary file not shown.
Binary file removed img/switching_version.gif
Binary file not shown.
5 changes: 0 additions & 5 deletions player/player.properties

This file was deleted.

4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pluginManagement {
}

plugins {
id "dev.kikugie.stonecutter" version "0.4"
id "dev.kikugie.stonecutter" version "0.4.2"
}

def multiVersions = multi_versions.split(" ")
Expand All @@ -47,7 +47,7 @@ if (additionalDepends.isEmpty()) {
stonecutter {
shared {
versions(multiVersions)
vcsVersion = multiVersions.first()
vcsVersion = multiVersions.last()
}

create(rootProject)
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/net/lopymine/mossy/Mossy.java

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/java/net/lopymine/mossy/client/MossyClient.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/net/lopymine/mossy/mixin/ExampleMixin.java

This file was deleted.

Loading

0 comments on commit 53fe99d

Please sign in to comment.