Skip to content

Commit ad35b8a

Browse files
committed
Support for 1.19.4 (infinite durability)
1 parent c4bdde4 commit ad35b8a

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
This is a Minecraft mod that overlays a timer on the Vanilla status effect HUD icons.
88

9-
This mod requires Minecraft 1.16.5-1.19 and the Fabric loader.
9+
This mod requires Minecraft 1.16.5-1.19.4 and the Fabric loader.
1010

1111
This mod overlays the number of seconds left of the status effect, or the number of minutes (followed by "m") if it is more than 60 seconds, on the vanilla status effect indicator. If the effect has an amplifier (as in "Haste II"), the amplifier is also overlaid. That's it. This is a very minimalistic mod. No settings are required nor provided.
1212

@@ -25,7 +25,7 @@ This is what it looks like when you are using the mod.
2525

2626
The latest version is 1.2.0.
2727

28-
Direct download links for Minecraft 1.19:
28+
Direct download links for Minecraft 1.19.4:
2929

3030
* Download from GitHub: [statuseffecttimer-1.2.0+1.19.jar](https://github.com/magicus/statuseffecttimer/releases/download/v1.2.0%2B1.19/statuseffecttimer-1.2.0+1.19.jar)
3131
* Download from Modrinth: [statuseffecttimer-1.2.0+1.19.jar](https://cdn.modrinth.com/data/T9FDHbY5/versions/uJH5bLJ1/statuseffecttimer-1.2.0%2B1.19.jar)

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/develop
6-
minecraft_version=1.19
7-
yarn_mappings=1.19+build.2
8-
loader_version=0.14.11
6+
minecraft_version=1.19.4
7+
yarn_mappings=1.19.4+build.2
8+
loader_version=0.15.6
99

1010
# Mod Properties
11-
mod_version = 1.2.0+1.19
11+
mod_version = 1.2.0+1.19.4
1212
maven_group = se.icus.mag
1313
archives_base_name = statuseffecttimer
1414

1515
# Dependencies
1616
# Fabric api
17-
fabric_version=0.56.0+1.19
17+
fabric_version=0.87.2+1.19.4
1818
mixinextras_version=0.2.2

src/main/java/se/icus/mag/statuseffecttimer/mixin/StatusEffectTimerMixin.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// Set priority to 500, to load before default at 1000. This is to better cooperate with HUDTweaks.
2323
@Environment(EnvType.CLIENT)
2424
@Mixin(value = InGameHud.class, priority = 500)
25-
public abstract class StatusEffectTimerMixin extends DrawableHelper {
25+
public abstract class StatusEffectTimerMixin {
2626
@Shadow @Final
2727
private MinecraftClient client;
2828

@@ -39,25 +39,28 @@ private void appendOverlayDrawing(MatrixStack matrices, CallbackInfo c,
3939
private void drawStatusEffectOverlay(MatrixStack matrices, StatusEffectInstance statusEffectInstance, int x, int y) {
4040
String duration = getDurationAsString(statusEffectInstance);
4141
int durationLength = client.textRenderer.getWidth(duration);
42-
drawStringWithShadow(matrices, client.textRenderer, duration, x + 13 - (durationLength / 2), y + 14, 0x99FFFFFF);
42+
DrawableHelper.drawTextWithShadow(matrices, client.textRenderer, duration, x + 13 - (durationLength / 2), y + 14, 0x99FFFFFF);
4343

4444
int amplifier = statusEffectInstance.getAmplifier();
4545
if (amplifier > 0) {
46-
// Most langages has "translations" for amplifier 1-5, converting to roman numerals
47-
String amplifierString = (amplifier < 6) ? I18n.translate("potion.potency." + amplifier) : "**";
48-
int amplifierLength = client.textRenderer.getWidth(amplifierString);
49-
drawStringWithShadow(matrices, client.textRenderer, amplifierString, x + 22 - amplifierLength, y + 3, 0x99FFFFFF);
46+
// Convert to roman numerals if possible
47+
String amplifierString = (amplifier < 10) ? I18n.translate("enchantment.level." + (amplifier + 1)) : "**";
48+
int amplifierLength = client.textRenderer.getWidth(amplifierString);
49+
DrawableHelper.drawTextWithShadow(matrices, client.textRenderer, amplifierString, x + 22 - amplifierLength, y + 3, 0x99FFFFFF);
5050
}
5151
}
5252

5353
private String getDurationAsString(StatusEffectInstance statusEffectInstance) {
54+
if (statusEffectInstance.isInfinite()) {
55+
return I18n.translate("effect.duration.infinite");
56+
}
57+
5458
int ticks = MathHelper.floor((float) statusEffectInstance.getDuration());
5559
int seconds = ticks / 20;
5660

57-
if (ticks > 32147) {
58-
// Vanilla considers everything above this to be infinite
59-
return "**";
60-
} else if (seconds > 60) {
61+
if (seconds >= 3600) {
62+
return seconds / 3600 + "h";
63+
} else if (seconds >= 60) {
6164
return seconds / 60 + "m";
6265
} else {
6366
return String.valueOf(seconds);

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525

2626
"depends": {
2727
"fabricloader": ">=0.7.4",
28-
"minecraft": "~1.19"
28+
"minecraft": "1.19.4"
2929
}
3030
}

0 commit comments

Comments
 (0)