From bd682df87d865165bd1d5186da498146e08a560d Mon Sep 17 00:00:00 2001 From: lukasabbe <67807954+lukasabbe@users.noreply.github.com> Date: Wed, 11 Feb 2026 10:49:49 +0100 Subject: [PATCH] Fixed boat hud config --- .../java/com/lukasabbe/simplehud/config/Config.java | 3 +++ .../java/com/lukasabbe/simplehud/config/ModMenu.java | 11 +++++++++++ .../java/com/lukasabbe/simplehud/huds/BoatHud.java | 3 ++- .../java/com/lukasabbe/simplehud/huds/ElytraHud.java | 3 ++- .../java/com/lukasabbe/simplehud/huds/SimpleHud.java | 5 +++-- src/main/resources/assets/simplehud/lang/en_us.json | 5 ++++- 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/lukasabbe/simplehud/config/Config.java b/src/main/java/com/lukasabbe/simplehud/config/Config.java index 62f5fe9..10095c3 100644 --- a/src/main/java/com/lukasabbe/simplehud/config/Config.java +++ b/src/main/java/com/lukasabbe/simplehud/config/Config.java @@ -28,6 +28,9 @@ public class Config { @SerialEntry public SpeedEnum speedEnumElytra = SpeedEnum.kmh; + @SerialEntry + public SpeedEnum speedEnumBoat = SpeedEnum.kmh; + @SerialEntry public boolean ignoreSafeArea = false; diff --git a/src/main/java/com/lukasabbe/simplehud/config/ModMenu.java b/src/main/java/com/lukasabbe/simplehud/config/ModMenu.java index 97262ed..9928f7b 100644 --- a/src/main/java/com/lukasabbe/simplehud/config/ModMenu.java +++ b/src/main/java/com/lukasabbe/simplehud/config/ModMenu.java @@ -39,6 +39,17 @@ public class ModMenu implements ModMenuApi { .customController(opt -> new EnumController<>(opt, SpeedEnum.class)) .build()) .build()) + .category(ConfigCategory + .createBuilder() + .name(Component.translatable("simple_hud.config.category.boat_hud.name")) + .option(Option + .createBuilder() + .name(Component.translatable("simple_hud.config.category.elytra_options.option.speed_enum.name")) + .description(OptionDescription.of(Component.translatable("simple_hud.config.category.elytra_options.option.speed_enum.description"))) + .binding(SpeedEnum.kmh, () -> instance.speedEnumBoat, newVal -> instance.speedEnumBoat = newVal) + .customController(opt -> new EnumController<>(opt, SpeedEnum.class)) + .build()) + .build()) .save(() -> Config.HANDLER.save()) .build().generateScreen(parent); } diff --git a/src/main/java/com/lukasabbe/simplehud/huds/BoatHud.java b/src/main/java/com/lukasabbe/simplehud/huds/BoatHud.java index 65e6bf5..a52c99c 100644 --- a/src/main/java/com/lukasabbe/simplehud/huds/BoatHud.java +++ b/src/main/java/com/lukasabbe/simplehud/huds/BoatHud.java @@ -1,6 +1,7 @@ package com.lukasabbe.simplehud.huds; import com.lukasabbe.simplehud.Constants; +import com.lukasabbe.simplehud.config.Config; import com.lukasabbe.simplehud.tools.BoatTools; import net.minecraft.client.DeltaTracker; import net.minecraft.client.gui.GuiGraphics; @@ -45,7 +46,7 @@ public class BoatHud implements SimpleHud { //Draw speed int speedTextY = 15; - renderCenteredScaledText(graphics, getSpeed(), x + textX, y + speedTextY, whiteColor, textScale); + renderCenteredScaledText(graphics, getSpeed(Config.HANDLER.instance().speedEnumBoat), x + textX, y + speedTextY, whiteColor, textScale); //Draw coordinates int coordinatesTextY = 25; diff --git a/src/main/java/com/lukasabbe/simplehud/huds/ElytraHud.java b/src/main/java/com/lukasabbe/simplehud/huds/ElytraHud.java index 3568b05..df557de 100644 --- a/src/main/java/com/lukasabbe/simplehud/huds/ElytraHud.java +++ b/src/main/java/com/lukasabbe/simplehud/huds/ElytraHud.java @@ -1,6 +1,7 @@ package com.lukasabbe.simplehud.huds; import com.lukasabbe.simplehud.Constants; +import com.lukasabbe.simplehud.config.Config; import com.lukasabbe.simplehud.tools.ElytraTools; import net.minecraft.client.DeltaTracker; import net.minecraft.client.gui.GuiGraphics; @@ -43,7 +44,7 @@ public class ElytraHud implements SimpleHud { //Draw speed int speedTextY = 15; - renderCenteredScaledText(graphics, getSpeed(), x + textX, y + speedTextY, whiteColor, textScale); + renderCenteredScaledText(graphics, getSpeed(Config.HANDLER.instance().speedEnumElytra), x + textX, y + speedTextY, whiteColor, textScale); //Draw coordinates int coordinatesTextY = 25; diff --git a/src/main/java/com/lukasabbe/simplehud/huds/SimpleHud.java b/src/main/java/com/lukasabbe/simplehud/huds/SimpleHud.java index 768585d..792f7ed 100644 --- a/src/main/java/com/lukasabbe/simplehud/huds/SimpleHud.java +++ b/src/main/java/com/lukasabbe/simplehud/huds/SimpleHud.java @@ -4,6 +4,7 @@ import com.lukasabbe.simplehud.Constants; import com.lukasabbe.simplehud.SimpleHudMod; import com.lukasabbe.simplehud.config.Config; import com.lukasabbe.simplehud.config.HudPosition; +import com.lukasabbe.simplehud.config.SpeedEnum; import com.lukasabbe.simplehud.tools.ElytraTools; import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; @@ -117,8 +118,8 @@ public interface SimpleHud { } } - default String getSpeed(){ - return switch (Config.HANDLER.instance().speedEnumElytra){ + default String getSpeed(SpeedEnum configSpeedEnum){ + return switch (configSpeedEnum){ case kmh -> String.format("%.1f km/h", ElytraTools.getSpeedKmh()); case mph -> String.format("%.1f mph", ElytraTools.getSpeedMph()); case ms -> String.format("%.1f m/s", ElytraTools.getSpeedMs()); diff --git a/src/main/resources/assets/simplehud/lang/en_us.json b/src/main/resources/assets/simplehud/lang/en_us.json index d3659c4..c606048 100644 --- a/src/main/resources/assets/simplehud/lang/en_us.json +++ b/src/main/resources/assets/simplehud/lang/en_us.json @@ -11,5 +11,8 @@ "simple_hud.config.category.elytra_options.option.speed_enum.description": "You can change the speed unit to what you are used to", "simple_hud.config.speed_enum.kmh": "km/h", "simple_hud.config.speed_enum.mph": "MPH", - "simple_hud.config.speed_enum.ms": "m/s" + "simple_hud.config.speed_enum.ms": "m/s", + "simple_hud.config.category.boat_hud.name": "Boat HUD options", + "simple_hud.config.category.general.group.activated_huds.option.boat_hud.name": "Boat HUD", + "simple_hud.config.category.general.group.activated_huds.option.boat_hud.description": "Boat Hud toggle, if you don't want to see the an HUD when you boat around." } \ No newline at end of file