Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LopyMine authored Jun 23, 2024
0 parents commit 505fa1c
Show file tree
Hide file tree
Showing 41 changed files with 1,866 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.

name: build
on: [pull_request, push]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
21, # Current Java LTS
]
runs-on: ubuntu-22.04
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# gradle

.gradle/
build/
out/
classes/

# eclipse

*.launch

# idea

.idea/
*.iml
*.ipr
*.iws

# vscode

.settings/
.vscode/
bin/
.classpath
.project

# macos

*.DS_Store

# fabric

runs/
player/

# java

hs_err_*.log
replay_*.log
*.hprof
*.jfr
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

139 changes: 139 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<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>
Loading

0 comments on commit 505fa1c

Please sign in to comment.