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
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/actions/wrapper-validation@v6
uses: gradle/actions/wrapper-validation@v4
- name: setup jdk
uses: actions/setup-java@v5
uses: actions/setup-java@v4
with:
java-version: '25'
java-version: '21'
distribution: 'microsoft'
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
38 changes: 19 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
plugins {
id 'net.fabricmc.fabric-loom' version "${loom_version}"
id 'fabric-loom' version "${loom_version}"
id 'maven-publish'
}

version = project.mod_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.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
}

configurations.configureEach {
if (name.toLowerCase().contains('annotationprocessor')) {
exclude group: 'org.ow2.asm'
}
}

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}"
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.
implementation include(fabricApi.module("fabric-api-base", project.fabric_api_version))
implementation include(fabricApi.module("fabric-rendering-v1", project.fabric_api_version))
modImplementation include(fabricApi.module("fabric-api-base", project.fabric_version))
modImplementation include(fabricApi.module("fabric-rendering-v1", project.fabric_version))

implementation include("com.terraformersmc:modmenu:${project.modmenu_version}")
implementation include("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_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")
}

}

processResources {
Expand All @@ -48,7 +47,7 @@ processResources {
}

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

java {
Expand All @@ -57,22 +56,23 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

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

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

// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
Expand Down
18 changes: 8 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
org.gradle.jvmargs=-Xmx1G
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
loom_version=1.16-SNAPSHOT
minecraft_version=1.21.9
yarn_mappings=1.21.9+build.1
loader_version=0.17.3
loom_version=1.11-SNAPSHOT

# Mod Properties
mod_version=2.1.0
mod_version=2.0.1
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
fabric_version=0.134.0+1.21.9
modmenu_version=15.0.2
cloth_config_version=19.0.147
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
}
}

// Should match your modid
rootProject.name = 'betterhud'
}
4 changes: 2 additions & 2 deletions src/main/java/dsns/betterhud/BetterHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.minecraft.resources.Identifier;
import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -40,7 +40,7 @@ public void onInitializeClient() {
BetterHUDGUI betterHUDGUI = new BetterHUDGUI();

HudElementRegistry.addLast(
Identifier.fromNamespaceAndPath("betterhud", "hud"),
Identifier.of("betterhud", "hud"),
betterHUDGUI::onHudRender
);
ClientTickEvents.START_CLIENT_TICK.register(betterHUDGUI);
Expand Down
56 changes: 28 additions & 28 deletions src/main/java/dsns/betterhud/BetterHUDGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderTickCounter;

public class BetterHUDGUI implements ClientTickEvents.StartTick {

Expand All @@ -20,15 +20,15 @@ public class BetterHUDGUI implements ClientTickEvents.StartTick {

public static int lineHeight = 1;

private final Minecraft client = Minecraft.getInstance();
private final MinecraftClient client = MinecraftClient.getInstance();
private final List<CustomText> topLeftText = new ObjectArrayList<>();
private final List<CustomText> topRightText = new ObjectArrayList<>();
private final List<CustomText> bottomLeftList = new ObjectArrayList<>();
private final List<CustomText> bottomRightText = new ObjectArrayList<>();
private final List<CustomText> customPositionText = new ObjectArrayList<>();

@Override
public void onStartTick(Minecraft client) {
public void onStartTick(MinecraftClient client) {
this.topLeftText.clear();
this.topRightText.clear();
this.bottomLeftList.clear();
Expand Down Expand Up @@ -68,11 +68,11 @@ public void onStartTick(Minecraft client) {
}

public void onHudRender(
GuiGraphicsExtractor drawContext,
DeltaTracker tickCounter
DrawContext drawContext,
RenderTickCounter tickCounter
) {
if (client.getDebugOverlay().showDebugScreen()) return;
if (client.options.hideGui) return;
if (client.getDebugHud().shouldShowDebugHud()) return;
if (client.options.hudHidden) return;

int x = horizontalMargin;
int y = verticalMargin;
Expand All @@ -81,43 +81,43 @@ public void onHudRender(
drawString(drawContext, text, x, y);

y +=
(client.font.lineHeight - 1) +
(client.textRenderer.fontHeight - 1) +
(verticalPadding * 2) +
lineHeight;
}

y = client.getWindow().getGuiScaledHeight() - verticalMargin;
y = client.getWindow().getScaledHeight() - verticalMargin;

for (CustomText text : bottomLeftList) {
y -= (client.font.lineHeight - 1) + (verticalPadding * 2);
y -= (client.textRenderer.fontHeight - 1) + (verticalPadding * 2);
drawString(drawContext, text, x, y);
y -= lineHeight;
}

y = verticalMargin;
for (CustomText text : topRightText) {
int offset =
(client.font.width(text.text) - 1) +
(client.textRenderer.getWidth(text.text) - 1) +
(horizontalPadding * 2) +
horizontalMargin;
x = client.getWindow().getGuiScaledWidth() - offset;
x = client.getWindow().getScaledWidth() - offset;
drawString(drawContext, text, x, y);

y +=
(client.font.lineHeight - 1) +
(client.textRenderer.fontHeight - 1) +
(verticalPadding * 2) +
lineHeight;
}

y = client.getWindow().getGuiScaledHeight() - verticalMargin;
y = client.getWindow().getScaledHeight() - verticalMargin;
for (CustomText text : bottomRightText) {
int offset =
(client.font.width(text.text) - 1) +
(client.textRenderer.getWidth(text.text) - 1) +
(horizontalPadding * 2) +
horizontalMargin;
x = client.getWindow().getGuiScaledWidth() - offset;
x = client.getWindow().getScaledWidth() - offset;

y -= (client.font.lineHeight - 1) + (verticalPadding * 2);
y -= (client.textRenderer.fontHeight - 1) + (verticalPadding * 2);

drawString(drawContext, text, x, y);

Expand All @@ -129,13 +129,13 @@ public void onHudRender(
float yPercent = text.customY / 100.0f;

int maxX =
client.getWindow().getGuiScaledWidth() -
client.getWindow().getScaledWidth() -
(horizontalPadding * 2) -
(client.font.width(text.text) - 1);
(client.textRenderer.getWidth(text.text) - 1);
int maxY =
client.getWindow().getGuiScaledHeight() -
client.getWindow().getScaledHeight() -
(verticalPadding * 2) -
(client.font.lineHeight - 1);
(client.textRenderer.fontHeight - 1);

int scaledX = (int) (xPercent * maxX);
int scaledY = (int) (yPercent * maxY);
Expand All @@ -145,7 +145,7 @@ public void onHudRender(
}

private void drawString(
GuiGraphicsExtractor drawContext,
DrawContext drawContext,
CustomText text,
int x,
int y
Expand All @@ -154,14 +154,14 @@ private void drawString(
x,
y,
x +
(client.font.width(text.text) - 1) +
(client.textRenderer.getWidth(text.text) - 1) +
(horizontalPadding * 2),
y + (client.font.lineHeight - 1) + (verticalPadding * 2),
y + (client.textRenderer.fontHeight - 1) + (verticalPadding * 2),
text.backgroundColor
);

drawContext.text(
client.font,
drawContext.drawText(
client.textRenderer,
text.text,
x + horizontalPadding,
y + verticalPadding,
Expand Down
Loading
Loading