Skip to content
Closed
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
35 changes: 20 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
# 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:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- mc: "1.21"
java: "21"
- mc: "1.21.9"
java: "21"
- mc: "26.1"
java: "25"
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/actions/wrapper-validation@v6
- name: setup jdk
uses: actions/setup-java@v5
uses: gradle/actions/wrapper-validation@v4
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
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: build mc${{ matrix.mc }}
run: ./gradlew :${{ matrix.mc }}:build --stacktrace
- name: capture build artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
name: Artifacts-mc${{ matrix.mc }}
path: versions/${{ matrix.mc }}/build/libs/
116 changes: 72 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,113 @@ plugins {
id 'maven-publish'
}

version = project.mod_version
def mc = project.minecraft_version
def isOldMC = mc.startsWith("1.") // 1.21.x → Yarn mappings, Java 21
def is121 = mc == "1.21" // Only 1.21 needs lifecycle-events as explicit module

stonecutter.dependency "mc", mc

version = "${project.mod_version}+mc${project.minecraft_version}"
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'
if (!isOldMC) {
configurations.configureEach {
if (name.toLowerCase().contains('annotationprocessor')) {
exclude group: 'org.ow2.asm'
}
}
}

def javaVersion = isOldMC ? 21 : 25

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 (isOldMC) {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation include(fabricApi.module("fabric-api-base", project.fabric_version))
modImplementation include(fabricApi.module("fabric-rendering-v1", project.fabric_version))
if (is121) {
modImplementation include(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_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 {
mappings loom.officialMojangMappings()
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 {
def minecraftReq = isOldMC ? "~1.21" : ">=26"
def loaderReq = isOldMC ? ">=0.15.11" : ">=0.19"
def javaReq = isOldMC ? ">=21" : ">=25"
def javaCompat = isOldMC ? "JAVA_21" : "JAVA_25"
def mixinClasses = isOldMC ? '"MinecraftClientAccessor"' : ''

inputs.property "version", project.version
inputs.property "minecraftReq", minecraftReq
inputs.property "loaderReq", loaderReq
inputs.property "javaReq", javaReq
inputs.property "javaCompat", javaCompat
inputs.property "mixinClasses", mixinClasses

filesMatching("fabric.mod.json") {
expand "version": inputs.properties.version
expand(
"version": project.version,
"minecraftReq": minecraftReq,
"loaderReq": loaderReq,
"javaReq": javaReq
)
}
filesMatching("betterhud.mixins.json") {
expand(
"javaCompat": javaCompat,
"mixinClasses": mixinClasses
)
}
}

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

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 = JavaVersion.toVersion(javaVersion)
targetCompatibility = JavaVersion.toVersion(javaVersion)
}

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

from("LICENSE") {
rename { "${it}_${project.name}"}
rename { "${it}_${project.name}" }
}
}

// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
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.
}
}
repositories {}
}
13 changes: 1 addition & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@ 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
# Shared across all versions
loom_version=1.16-SNAPSHOT

# Mod Properties
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.
18 changes: 17 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,26 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Stonecutter'
url = 'https://maven.kikugie.dev/releases'
}
mavenCentral()
gradlePluginPortal()
}
}

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

stonecutter {
create(rootProject) {
vers("1.21", "1.21")
vers("1.21.9", "1.21.9")
vers("26.1", "26.1")
vcsVersion = "26.1"
}
}

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

@Environment(EnvType.CLIENT)
public class BetterHUD implements ClientModInitializer {

// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("betterhud");

public static ArrayList<BaseMod> mods = new ArrayList<>(
Expand All @@ -39,10 +40,14 @@ public void onInitializeClient() {

BetterHUDGUI betterHUDGUI = new BetterHUDGUI();

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