Skip to content

Commit

Permalink
h
Browse files Browse the repository at this point in the history
  • Loading branch information
Stereo528 committed Aug 9, 2023
1 parent 2335b49 commit 0446b1c
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 121 deletions.
48 changes: 20 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
# 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]
on: [ pull_request, push ]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
17, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-22.04, windows-2022]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

env:
PUBLISH_SUFFIX: snapshots
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}

steps:
- name: checkout repository
- name: Checkout Repository
uses: actions/checkout@v3
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}

- name: Setup JDK (Java 17)
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
java-version: 17

- name: gradlew Permission Grant
run: chmod +x gradlew

- name: Build w/ Gradle
run: ./gradlew buildOrPublish

- name: Capture Build Artifacts
uses: actions/upload-artifact@v3
with:
name: Artifacts
Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
# Fabric Example Mod

## Setup

For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the IDE that you are using.

## License

This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.
# Fabric Nautical Template
Team Nautical's take on the Fabric Example Mod
113 changes: 69 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,27 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'maven-publish'
id 'org.ajoberstar.grgit' version '5.2.0'
}

version = project.mod_version
archivesBaseName = "${project.archives_base_name}+mc${libs.versions.minecraft.get()}"
version = getVersion()
group = project.maven_group

base {
archivesName = project.archives_base_name
}

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.
maven { url "https://api.modrinth.com/maven" }
maven { url "https://maven.terraformersmc.com/" }
}

loom {
splitEnvironmentSourceSets()

mods {
"modid" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
dependencies {
minecraft libs.minecraft

}
mappings loom.officialMojangMappings()
modImplementation libs.fabric.loader

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
modImplementation libs.fabric.api
modImplementation libs.bundles.dependencies
modLocalRuntime(libs.bundles.dev.mods)
}

processResources {
Expand Down Expand Up @@ -73,19 +52,65 @@ jar {
}
}

// configure the maven publication
task buildOrPublish {
group = "build"
String mavenUser = System.getenv().MAVEN_USER
if (mavenUser != null && !mavenUser.isEmpty()) {
dependsOn(tasks.getByName("publish"))
println("prepared for publish")
} else {
dependsOn(tasks.getByName("build"))
println("prepared for build")
}
}

// TODO: Uncomment for a non template mod!
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
// publications {
// mavenJava(MavenPublication) {
// groupId = project.maven_group
// artifactId = project.archives_base_name
// version = "${project.mod_version}-rev.${grgit.head().abbreviatedId}"
//
// from components.java
// }
// }
//
// // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
// repositories {
// maven {
// url = "https://mvn.devos.one/${System.getenv().PUBLISH_SUFFIX}/"
// credentials {
// username = System.getenv().MAVEN_USER
// password = System.getenv().MAVEN_PASS
// }
// authentication { basic(BasicAuthentication) }
// }
// }
}

String getVersion() {
def mod_version = project.mod_version
def build_id = System.getenv("GITHUB_RUN_NUMBER")

// CI builds only
if (build_id != null) {
return "${mod_version}+build.${build_id}"
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// 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.
if (grgit != null) {
def head = grgit.head()
def id = head.abbreviatedId

// Flag the build if the build tree is not clean
if (!grgit.status().clean) {
id += "-dirty"
}

return "${mod_version}+rev.${id}"
}

// No tracking information could be found about the build
return "${mod_version}+unknown"

}
11 changes: 2 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21

# Mod Properties
mod_version=1.0.0
maven_group=com.example
maven_group=one.devos.nautical
archives_base_name=modid

# Dependencies
fabric_version=0.85.0+1.20.1
# Dependencies are handled in ./gradle/libs.versions.toml
29 changes: 29 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[versions]
# The latest versions are available at https://fabricmc.net/develop
minecraft = "1.20.1"
fabric-loader = "0.14.21"

fabric-api = "0.85.0+1.20.1"

sodium_version = "mc1.20.1-0.5.0"
mod_menu_version = "7.2.0"
joml_version = "1.10.5"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" }

fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" }

sodium = { module = "maven.modrinth:sodium", version.ref = "sodium_version" }
joml = { module = "org.joml:joml", version.ref = "joml_version" }
mod_menu = { module = "com.terraformersmc:modmenu", version.ref = "mod_menu_version" }

# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example".
[bundles]
fabric_api = ["fabric-api"]
dev_mods = [ "joml", "sodium" ]
dependencies = [ "fabric-loader", "fabric-api", "mod_menu" ]

[plugins]
fabric_loom = { id = "com.fabricmc.loom", version = "1.3-SNAPSHOT" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example;
package one.devos.nautical;

import net.fabricmc.api.ClientModInitializer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mixin.client;
package one.devos.nautical.mixin.client;

import net.minecraft.client.MinecraftClient;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
2 changes: 1 addition & 1 deletion src/client/resources/modid.client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"package": "com.example.mixin.client",
"compatibilityLevel": "JAVA_17",
"client": [
"ExampleClientMixin"
"one.devos.nautical.mixin.client.ExampleClientMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/com/example/mixin/ExampleMixin.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example;
package one.devos.nautical;

import net.fabricmc.api.ModInitializer;

Expand Down
13 changes: 3 additions & 10 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,19 @@
"environment": "*",
"entrypoints": {
"main": [
"com.example.ExampleMod"
"one.devos.nautical.ExampleMod"
],
"client": [
"com.example.ExampleModClient"

]
},
"mixins": [
"modid.mixins.json",
{
"config": "modid.client.mixins.json",
"environment": "client"
}
"modid.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.21",
"minecraft": "~1.20.1",
"java": ">=17",
"fabric-api": "*"
},
"suggests": {
"another-mod": "*"
}
}
7 changes: 5 additions & 2 deletions src/main/resources/modid.mixins.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"required": true,
"package": "com.example.mixin",
"package": "one.devos.nautical.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"ExampleMixin"

],
"client": [

],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 0446b1c

Please sign in to comment.