Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
# 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.
# Build the mod against every Minecraft variant Stonecutter is configured for.
# Each matrix job builds one variant and uploads its jar.
# Running `./gradlew build` from the root builds all four in one go.

name: build
on: push

jobs:
build:
name: build mc${{ matrix.mc }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- mc: '1.21'
java: '21'
- mc: '1.21.6'
java: '21'
- mc: '26.1'
java: '25'
- mc: '26.2'
java: '25'
steps:
- name: checkout repository
uses: actions/checkout@v6

- name: validate gradle wrapper
uses: gradle/actions/wrapper-validation@v6
- name: setup jdk

- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v5
with:
java-version: '25'
java-version: ${{ matrix.java }}
distribution: 'microsoft'

- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts

- name: build :${{ matrix.mc }}:build
run: ./gradlew :${{ matrix.mc }}:build --stacktrace

- name: upload jar
uses: actions/upload-artifact@v7
with:
name: Artifacts
path: build/libs/
name: betterhud-mc${{ matrix.mc }}
path: versions/${{ matrix.mc }}/build/libs/*.jar
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ bin/

run/

# stonecutter

versions/*/.gradle/
versions/*/build/
versions/*/run/
versions/*/src/
*.stonecutter.tmp

# java

hs_err_*.log
Expand Down
128 changes: 83 additions & 45 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,85 +1,123 @@
plugins {
id 'net.fabricmc.fabric-loom' version "${loom_version}"
// Loom 1.14+ splits into two sibling plugins:
// - `net.fabricmc.fabric-loom-remap` handles obfuscated MC (1.21.x with intermediary)
// - `net.fabricmc.fabric-loom` handles unobfuscated MC (26.1+, Mojang names native)
// We declare both with `apply false` and pick the right one for the current variant.
id 'net.fabricmc.fabric-loom-remap' version "${loom_version}" apply false
id 'net.fabricmc.fabric-loom' version "${loom_version}" apply false
id 'maven-publish'
}

version = project.mod_version
def mcVersion = stonecutter.current.version
def isLegacy = stonecutter.eval(mcVersion, '<26') // 1.21.x family
def hasHudElementRegistry = stonecutter.eval(mcVersion, '>=1.21.6') // 1.21.6+ and 26+

apply plugin: isLegacy ? 'net.fabricmc.fabric-loom-remap' : 'net.fabricmc.fabric-loom'

// Per-MC Java version (21 for 1.21.x, 25 for 26.1+).
def javaVersionInt = Integer.parseInt(project.java_version)
def javaLang = JavaVersion.toVersion(javaVersionInt)
def mixinJavaCompat = "JAVA_${javaVersionInt}"

version = "${project.mod_version}+mc${mcVersion}"
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://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url 'https://maven.shedaniel.me/' }
maven { url 'https://maven.terraformersmc.com/releases/' }
}

configurations.configureEach {
if (name.toLowerCase().contains('annotationprocessor')) {
exclude group: 'org.ow2.asm'
// MC 26+ uses fabric-rendering-v1's transitive deps but rejects ASM coming from
// annotation processors; matches main's existing build.
if (!isLegacy) {
configurations.configureEach {
if (name.toLowerCase().contains('annotationprocessor')) {
exclude group: 'org.ow2.asm'
}
}
}

// Every variant declares fabric-api, modmenu, and cloth-config as runtime deps
// (not bundled). 1.21.x uses modImplementation for intermediary remapping; 26.x
// uses plain implementation against unobfuscated MC.
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"

implementation "net.fabricmc:fabric-loader:${project.loader_version}"

implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
if (isLegacy) {
mappings loom.officialMojangMappings()

implementation "com.terraformersmc:modmenu:${project.modmenu_version}"
implementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: 'net.fabricmc.fabric-api')
}
} else {
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
implementation "com.terraformersmc:modmenu:${project.modmenu_version}"
implementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: 'net.fabricmc.fabric-api')
}
}
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": inputs.properties.version
def dependsExtra = ''',
"fabric-api": "*",
"modmenu": "*",
"cloth-config2": "*"'''

def expansion = [
version : project.version,
minecraftReq : project.mc_dep,
loaderReq : project.loader_dep,
javaReq : ">=${javaVersionInt}",
javaCompat : mixinJavaCompat,
dependsExtra : dependsExtra
]
inputs.properties expansion

filesMatching('fabric.mod.json') {
expand expansion
}
filesMatching('betterhud.mixins.json') {
expand expansion
}
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 25
it.options.release = javaVersionInt
}

java {
// 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()

sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
sourceCompatibility = javaLang
targetCompatibility = javaLang
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersionInt)
}
}

jar {
inputs.property "projectName", project.name

from("LICENSE") {
rename { "${it}_${project.name}"}
def archiveName = base.archivesName.get()
from('../../LICENSE') {
rename { "${it}_${archiveName}" }
}
}

// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
create('mavenJava', MavenPublication) {
artifactId = "${project.archives_base_name}-mc${mcVersion}"
from components.java
}
}

// 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.
// Add publish repos here if/when needed.
}
}
}
18 changes: 7 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

# IntelliJ IDEA is not yet fully compatible with configuration cache, see: https://github.com/FabricMC/fabric-loom/issues/1349
org.gradle.configuration-cache=false

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=26.2
loader_version=0.19.3
# Acknowledge using Groovy DSL with Stonecutter (Kotlin DSL is recommended but Groovy works).
dev.kikugie.stonecutter.hard_mode=true

# Single loom version covers all MC variants. The `fabric-loom-remap` plugin id
# handles obfuscated MC (1.21.x), while `fabric-loom` handles unobfuscated MC (26.2+).
loom_version=1.17-SNAPSHOT

# Mod Properties
# Mod Properties (shared)
mod_version=2.1.1
maven_group=dsns.betterhud
archives_base_name=betterhud

# Dependencies
fabric_api_version=0.154.0+26.2
modmenu_version=18.0.0-alpha.8
cloth_config_version=26.1.154
Empty file modified gradlew
100644 → 100755
Empty file.
25 changes: 24 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,33 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Stonecutter Releases'
url = 'https://maven.kikugie.dev/releases'
}
maven {
name = 'Stonecutter Snapshots'
url = 'https://maven.kikugie.dev/snapshots'
}
mavenCentral()
gradlePluginPortal()
}
}

// Should match your modid
plugins {
id 'dev.kikugie.stonecutter' version '0.9.3'
}

stonecutter {
create(rootProject) {
// Each entry is one buildable variant. The string is both the subproject name
// and the MC version. These cover 1.21-1.21.5, 1.21.6-1.21.11, 26.1, and 26.2.
versions('1.21', '1.21.6', '26.1', '26.2')

// vcsVersion is the variant whose form is used as the canonical (active) version
// in source. We pick 26.2 so `git diff main` stays small.
vcsVersion = '26.2'
}
}

rootProject.name = 'betterhud'
17 changes: 17 additions & 0 deletions src/main/java/dsns/betterhud/BetterHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
//? if >=1.21.6 {
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
//?} else {
/*import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
*///?}
//? if >=26 {
import net.minecraft.resources.Identifier;
//?} else if >=1.21.6 {
/*import net.minecraft.resources.ResourceLocation;*/
//?}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -39,10 +47,19 @@ public void onInitializeClient() {

BetterHUDGUI betterHUDGUI = new BetterHUDGUI();

//? if >=26 {
HudElementRegistry.addLast(
Identifier.fromNamespaceAndPath("betterhud", "hud"),
betterHUDGUI::onHudRender
);
//?} else if >=1.21.6 {
/*HudElementRegistry.addLast(
ResourceLocation.fromNamespaceAndPath("betterhud", "hud"),
betterHUDGUI::onHudRender
);*/
//?} else {
/*HudRenderCallback.EVENT.register(betterHUDGUI);
*///?}
ClientTickEvents.START_CLIENT_TICK.register(betterHUDGUI);
}
}
Loading