Skip to content
Draft
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
41 changes: 30 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
# 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 (1.21, 1.21.6, 26.1) and uploads its jar.
# Running `./gradlew build` from the root would also work but the matrix gives
# clearer failure attribution and parallel execution.

name: build
on: [pull_request, 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'
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'

# Stonecutter's `build.gradle` uses Java toolchains, so loom can compile
# against an older JDK even when Gradle itself runs on a newer one. We
# still set the matrix Java as the daemon JVM for simplicity.
- 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
140 changes: 92 additions & 48 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,87 +1,131 @@
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'

// `stonecutter` is injected into each version subproject. `stonecutter.current.version`
// is the MC string, e.g. "1.21", "1.21.6", "26.1".
// 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'
}
}
}

// MC 26+ ships with Mojang official names baked into the runtime, so loom skips
// the intermediary remap entirely - mods link directly via `implementation`
// and `mappings` must NOT be declared.
// 1.21.x uses intermediary at runtime, so deps must go through `modImplementation`
// for loom to remap them, and `mappings loom.officialMojangMappings()` is required.
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}"

// Fabric API. This is technically optional, but you probably want it anyway.
implementation include(fabricApi.module("fabric-api-base", project.fabric_api_version))
implementation include(fabricApi.module("fabric-rendering-v1", project.fabric_api_version))

implementation include("com.terraformersmc:modmenu:${project.modmenu_version}")
implementation include("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}

if (isLegacy) {
mappings loom.officialMojangMappings()

modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation include(fabricApi.module('fabric-api-base', project.fabric_api_version))
modImplementation include(fabricApi.module('fabric-rendering-v1', project.fabric_api_version))

// 1.21 (pre-1.21.6) needs lifecycle-events as an explicit module; later versions
// pull it transitively through rendering-v1.
if (!hasHudElementRegistry) {
modImplementation include(fabricApi.module('fabric-lifecycle-events-v1', project.fabric_api_version))
}

modImplementation include("com.terraformersmc:modmenu:${project.modmenu_version}")
modImplementation include("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 include(fabricApi.module('fabric-api-base', project.fabric_api_version))
implementation include(fabricApi.module('fabric-rendering-v1', project.fabric_api_version))

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

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

filesMatching("fabric.mod.json") {
expand "version": inputs.properties.version
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.1
loader_version=0.19.2
# 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.1+).
loom_version=1.16-SNAPSHOT

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

# Dependencies
fabric_api_version=0.145.1+26.1
modmenu_version=18.0.0-alpha.8
cloth_config_version=26.1.154
Empty file modified gradlew
100644 → 100755
Empty file.
26 changes: 25 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,34 @@ 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 support/1.21-1.21.5, support/1.21.6-1.21.11,
// and main 26.1.
versions('1.21', '1.21.6', '26.1')

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

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