diff --git a/README.md b/README.md index 22b9543..1dadccc 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,12 @@ Transports included: Examples: - Elytra ![Elytra example](./images/ElytraExample.png) -- Boat ![Elytra example](./images/BoatExample.png) -- Minecart ![Elytra example](./images/MinecartExample.png) +- Boat ![Boat example](./images/BoatExample.png) +- Minecart ![Minecart example](./images/MinecartExample.png) +- Horse ![Horse example](./images/HorseExample.png) +- Happy Ghast ![Happy Ghast example](./images/HappyGhastExample.png) +- Nautilus ![Nautilus Example](./images/NautilusExample.png) +- Strider ![Strider Example](./images/StriderExample.png) # Looking for a server? Get BisectHosting and save 25% off for new customers using code Lukas at checkout. diff --git a/gradle.properties b/gradle.properties index d3e12c4..595c5dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G minecraft_version=1.21.11 loader_version=0.18.4 # Mod Properties -mod_version=0.2+1.21.11 +mod_version=1.0+1.21.11 versionType=beta maven_group=com.lukasabbe archives_base_name=SimpleTransportHud diff --git a/images/HappyGhastExample.png b/images/HappyGhastExample.png new file mode 100644 index 0000000..54e6ac9 Binary files /dev/null and b/images/HappyGhastExample.png differ diff --git a/images/HorseExample.png b/images/HorseExample.png new file mode 100644 index 0000000..95c5e04 Binary files /dev/null and b/images/HorseExample.png differ diff --git a/images/NautilusExample.png b/images/NautilusExample.png new file mode 100644 index 0000000..a0a2b4e Binary files /dev/null and b/images/NautilusExample.png differ diff --git a/images/StriderExample.png b/images/StriderExample.png new file mode 100644 index 0000000..24d198e Binary files /dev/null and b/images/StriderExample.png differ diff --git a/src/main/java/com/lukasabbe/simpletransporthud/Constants.java b/src/main/java/com/lukasabbe/simpletransporthud/Constants.java index 6ebc2f4..49b229d 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/Constants.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/Constants.java @@ -14,6 +14,9 @@ public class Constants { public final static Identifier BoatHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "boat_hud"); public final static Identifier MinecartHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "minecart_hud"); public final static Identifier HorseHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "horse_hud"); + public final static Identifier HappyGhastIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "happy_ghast_hud"); + public final static Identifier NautilusHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "nautilus_hud"); + public final static Identifier StriderHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "strider_hud"); - public final static List HudIdentifiers = Arrays.asList(ElytraHudIdentifier, BoatHudIdentifier, MinecartHudIdentifier, HorseHudIdentifier); + public final static List HudIdentifiers = Arrays.asList(ElytraHudIdentifier, BoatHudIdentifier, MinecartHudIdentifier, HorseHudIdentifier, HappyGhastIdentifier, NautilusHudIdentifier, StriderHudIdentifier); } diff --git a/src/main/java/com/lukasabbe/simpletransporthud/SimpleTransportHudMod.java b/src/main/java/com/lukasabbe/simpletransporthud/SimpleTransportHudMod.java index 6852c0b..53f4af7 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/SimpleTransportHudMod.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/SimpleTransportHudMod.java @@ -19,7 +19,10 @@ public class SimpleTransportHudMod implements ClientModInitializer { new ElytraHud(), new BoatHud(), new MinecartHud(), - new HorseHud() + new HorseHud(), + new HappyGhastHud(), + new NautilusHud(), + new StriderHud() ); @Override diff --git a/src/main/java/com/lukasabbe/simpletransporthud/config/Config.java b/src/main/java/com/lukasabbe/simpletransporthud/config/Config.java index e390189..73e60a5 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/config/Config.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/config/Config.java @@ -39,6 +39,12 @@ public class Config { public HudPosition hudPositionMinecart = HudPosition.CENTER; @SerialEntry public HudPosition hudPositionHorse = HudPosition.CENTER; + @SerialEntry + public HudPosition hudPositionHappyGhast = HudPosition.CENTER; + @SerialEntry + public HudPosition hudPositionNautilus = HudPosition.CENTER; + @SerialEntry + public HudPosition hudPositionStrider = HudPosition.CENTER; //Hud speed unit @@ -50,6 +56,13 @@ public class Config { public SpeedEnum speedEnumMinecart = SpeedEnum.kmh; @SerialEntry public SpeedEnum speedEnumHorse = SpeedEnum.kmh; + @SerialEntry + public SpeedEnum speedEnumHappyGhast = SpeedEnum.kmh; + @SerialEntry + public SpeedEnum speedEnumNautilus = SpeedEnum.kmh; + @SerialEntry + public SpeedEnum speedEnumStrider = SpeedEnum.kmh; + //Display speed @SerialEntry @@ -60,6 +73,12 @@ public class Config { public int minecartHudDelay = 0; @SerialEntry public int horseHudDelay = 0; + @SerialEntry + public int happyGhastHudDelay = 0; + @SerialEntry + public int nautilusHudDelay = 0; + @SerialEntry + public int striderHudDelay = 0; private Map getActiveHuds() { Map activatedHuds = new IdentityHashMap<>(); diff --git a/src/main/java/com/lukasabbe/simpletransporthud/config/ModMenu.java b/src/main/java/com/lukasabbe/simpletransporthud/config/ModMenu.java index 6ad6089..e1b9a81 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/config/ModMenu.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/config/ModMenu.java @@ -117,6 +117,106 @@ public class ModMenu implements ModMenuApi { .controller(opt -> IntegerSliderControllerBuilder.create(opt).range(0, 30).step(1)) .build()) .build()) + .category(ConfigCategory + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.minecart_hud.name")) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.speed_enum.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.speed_enum.description"))) + .binding(SpeedEnum.kmh, () -> instance.speedEnumMinecart, newVal -> instance.speedEnumMinecart = newVal) + .customController(opt -> new EnumController<>(opt, SpeedEnum.class)) + .build()) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.hud_position.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.hud_position.description"))) + .binding(HudPosition.CENTER, () -> instance.hudPositionMinecart, newVal -> instance.hudPositionMinecart = newVal) + .customController(opt -> new EnumController<>(opt, HudPosition.class)) + .build()) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.delay_hud.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.delay_hud.description"))) + .binding(0, () -> instance.minecartHudDelay, newVal -> instance.minecartHudDelay = newVal) + .controller(opt -> IntegerSliderControllerBuilder.create(opt).range(0, 30).step(1)) + .build()) + .build()) + .category(ConfigCategory + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.horse_hud.name")) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.speed_enum.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.speed_enum.description"))) + .binding(SpeedEnum.kmh, () -> instance.speedEnumHorse, newVal -> instance.speedEnumHorse = newVal) + .customController(opt -> new EnumController<>(opt, SpeedEnum.class)) + .build()) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.hud_position.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.hud_position.description"))) + .binding(HudPosition.CENTER, () -> instance.hudPositionHorse, newVal -> instance.hudPositionHorse = newVal) + .customController(opt -> new EnumController<>(opt, HudPosition.class)) + .build()) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.delay_hud.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.delay_hud.description"))) + .binding(0, () -> instance.horseHudDelay, newVal -> instance.horseHudDelay = newVal) + .controller(opt -> IntegerSliderControllerBuilder.create(opt).range(0, 30).step(1)) + .build()) + .build()) + .category(ConfigCategory + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.happy_ghast_hud.name")) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.speed_enum.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.speed_enum.description"))) + .binding(SpeedEnum.kmh, () -> instance.speedEnumHappyGhast, newVal -> instance.speedEnumHappyGhast = newVal) + .customController(opt -> new EnumController<>(opt, SpeedEnum.class)) + .build()) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.hud_position.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.hud_position.description"))) + .binding(HudPosition.CENTER, () -> instance.hudPositionHappyGhast, newVal -> instance.hudPositionHappyGhast = newVal) + .customController(opt -> new EnumController<>(opt, HudPosition.class)) + .build()) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.delay_hud.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.delay_hud.description"))) + .binding(0, () -> instance.happyGhastHudDelay, newVal -> instance.happyGhastHudDelay = newVal) + .controller(opt -> IntegerSliderControllerBuilder.create(opt).range(0, 30).step(1)) + .build()) + .build()) + .category(ConfigCategory + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.strider.name")) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.speed_enum.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.speed_enum.description"))) + .binding(SpeedEnum.kmh, () -> instance.speedEnumStrider, newVal -> instance.speedEnumStrider = newVal) + .customController(opt -> new EnumController<>(opt, SpeedEnum.class)) + .build()) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.hud_position.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.hud_position.description"))) + .binding(HudPosition.CENTER, () -> instance.hudPositionStrider, newVal -> instance.hudPositionStrider = newVal) + .customController(opt -> new EnumController<>(opt, HudPosition.class)) + .build()) + .option(Option + .createBuilder() + .name(Component.translatable("simple_transport_hud.config.category.elytra_options.option.delay_hud.name")) + .description(OptionDescription.of(Component.translatable("simple_transport_hud.config.category.elytra_options.option.delay_hud.description"))) + .binding(0, () -> instance.striderHudDelay, newVal -> instance.striderHudDelay = newVal) + .controller(opt -> IntegerSliderControllerBuilder.create(opt).range(0, 30).step(1)) + .build()) + .build()) .save(() -> Config.HANDLER.save()) .build().generateScreen(parent); } diff --git a/src/main/java/com/lukasabbe/simpletransporthud/huds/HappyGhastHud.java b/src/main/java/com/lukasabbe/simpletransporthud/huds/HappyGhastHud.java index dfd2033..80df2ae 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/huds/HappyGhastHud.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/huds/HappyGhastHud.java @@ -1,16 +1,40 @@ package com.lukasabbe.simpletransporthud.huds; +import com.lukasabbe.simpletransporthud.Constants; +import com.lukasabbe.simpletransporthud.config.Config; import com.lukasabbe.simpletransporthud.config.HudPosition; +import com.lukasabbe.simpletransporthud.config.SpeedEnum; +import com.lukasabbe.simpletransporthud.tools.EntityTools; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.resources.Identifier; +import net.minecraft.world.entity.animal.happyghast.HappyGhast; public class HappyGhastHud extends RideableHud{ + + @Override + public void render(GuiGraphics graphics, DeltaTracker tracker) { + if(!EntityTools.isRidingEntity(HappyGhast.class)) return; + super.render(graphics, tracker); + } + + @Override + public SpeedEnum getSpeedEnum() { + return Config.HANDLER.instance().speedEnumHappyGhast; + } + + @Override + public int getDelay() { + return Config.HANDLER.instance().happyGhastHudDelay; + } + @Override public Identifier getIdentifier() { - return null; + return Constants.HappyGhastIdentifier; } @Override public HudPosition getHudPosition() { - return null; + return Config.HANDLER.instance().hudPositionHappyGhast; } } diff --git a/src/main/java/com/lukasabbe/simpletransporthud/huds/HorseHud.java b/src/main/java/com/lukasabbe/simpletransporthud/huds/HorseHud.java index 5d81db2..b5de5ed 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/huds/HorseHud.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/huds/HorseHud.java @@ -3,6 +3,7 @@ package com.lukasabbe.simpletransporthud.huds; import com.lukasabbe.simpletransporthud.Constants; import com.lukasabbe.simpletransporthud.config.Config; import com.lukasabbe.simpletransporthud.config.HudPosition; +import com.lukasabbe.simpletransporthud.config.SpeedEnum; import com.lukasabbe.simpletransporthud.tools.EntityTools; import net.minecraft.client.DeltaTracker; import net.minecraft.client.gui.GuiGraphics; @@ -17,6 +18,16 @@ public class HorseHud extends RideableHud { super.render(graphics, tracker); } + @Override + public SpeedEnum getSpeedEnum() { + return Config.HANDLER.instance().speedEnumHorse; + } + + @Override + public int getDelay() { + return Config.HANDLER.instance().horseHudDelay; + } + @Override public Identifier getIdentifier() { return Constants.HorseHudIdentifier; diff --git a/src/main/java/com/lukasabbe/simpletransporthud/huds/NautilusHud.java b/src/main/java/com/lukasabbe/simpletransporthud/huds/NautilusHud.java index 984e964..48873e7 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/huds/NautilusHud.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/huds/NautilusHud.java @@ -1,16 +1,40 @@ package com.lukasabbe.simpletransporthud.huds; +import com.lukasabbe.simpletransporthud.Constants; +import com.lukasabbe.simpletransporthud.config.Config; import com.lukasabbe.simpletransporthud.config.HudPosition; +import com.lukasabbe.simpletransporthud.config.SpeedEnum; +import com.lukasabbe.simpletransporthud.tools.EntityTools; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.resources.Identifier; +import net.minecraft.world.entity.animal.nautilus.AbstractNautilus; public class NautilusHud extends RideableHud { + + @Override + public void render(GuiGraphics graphics, DeltaTracker tracker) { + if(!EntityTools.isRidingEntity(AbstractNautilus.class)) return; + super.render(graphics, tracker); + } + + @Override + public SpeedEnum getSpeedEnum() { + return Config.HANDLER.instance().speedEnumNautilus; + } + + @Override + public int getDelay() { + return Config.HANDLER.instance().nautilusHudDelay; + } + @Override public Identifier getIdentifier() { - return null; + return Constants.NautilusHudIdentifier; } @Override public HudPosition getHudPosition() { - return null; + return Config.HANDLER.instance().hudPositionNautilus; } } diff --git a/src/main/java/com/lukasabbe/simpletransporthud/huds/RideableHud.java b/src/main/java/com/lukasabbe/simpletransporthud/huds/RideableHud.java index 07bbbe6..ef6e155 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/huds/RideableHud.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/huds/RideableHud.java @@ -1,6 +1,6 @@ package com.lukasabbe.simpletransporthud.huds; -import com.lukasabbe.simpletransporthud.config.Config; +import com.lukasabbe.simpletransporthud.config.SpeedEnum; import com.lukasabbe.simpletransporthud.tools.EntityTools; import net.minecraft.client.DeltaTracker; import net.minecraft.client.gui.GuiGraphics; @@ -13,7 +13,7 @@ public abstract class RideableHud implements SimpleHud { if(!isHudActivated()) return; if(client.noRender) return; if(client.player == null) return; - if(EntityTools.getTime() < Config.HANDLER.instance().boatHudDelay) return; + if(EntityTools.getTime() < getDelay()) return; int[] pos = getCornerPos(); int x = pos[0]; int y = pos[1]; @@ -26,7 +26,7 @@ public abstract class RideableHud implements SimpleHud { //Draw speed int speedTextY = 5; - renderCenteredScaledText(graphics, getSpeed(Config.HANDLER.instance().speedEnumBoat), x + textX, y + speedTextY, whiteColor, textScale); + renderCenteredScaledText(graphics, getSpeed(getSpeedEnum()), x + textX, y + speedTextY, whiteColor, textScale); //Draw coordinates int coordinatesTextY = 15; @@ -185,4 +185,7 @@ public abstract class RideableHud implements SimpleHud { drawLine(graphics, centerX, centerY, endX, endY, (int) radius, compass_pointer); } + + public abstract SpeedEnum getSpeedEnum(); + public abstract int getDelay(); } diff --git a/src/main/java/com/lukasabbe/simpletransporthud/huds/StriderHud.java b/src/main/java/com/lukasabbe/simpletransporthud/huds/StriderHud.java index e80f368..9053df8 100644 --- a/src/main/java/com/lukasabbe/simpletransporthud/huds/StriderHud.java +++ b/src/main/java/com/lukasabbe/simpletransporthud/huds/StriderHud.java @@ -1,16 +1,39 @@ package com.lukasabbe.simpletransporthud.huds; +import com.lukasabbe.simpletransporthud.Constants; +import com.lukasabbe.simpletransporthud.config.Config; import com.lukasabbe.simpletransporthud.config.HudPosition; +import com.lukasabbe.simpletransporthud.config.SpeedEnum; +import com.lukasabbe.simpletransporthud.tools.EntityTools; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.resources.Identifier; +import net.minecraft.world.entity.monster.Strider; public class StriderHud extends RideableHud{ + @Override + public void render(GuiGraphics graphics, DeltaTracker tracker) { + if(!EntityTools.isRidingEntity(Strider.class)) return; + super.render(graphics, tracker); + } + @Override public Identifier getIdentifier() { - return null; + return Constants.StriderHudIdentifier; } @Override public HudPosition getHudPosition() { - return null; + return Config.HANDLER.instance().hudPositionStrider; + } + + @Override + public SpeedEnum getSpeedEnum() { + return Config.HANDLER.instance().speedEnumStrider; + } + + @Override + public int getDelay() { + return Config.HANDLER.instance().striderHudDelay; } } diff --git a/src/main/resources/assets/simpletransporthud/lang/en_us.json b/src/main/resources/assets/simpletransporthud/lang/en_us.json index a9a57b8..c39fba7 100644 --- a/src/main/resources/assets/simpletransporthud/lang/en_us.json +++ b/src/main/resources/assets/simpletransporthud/lang/en_us.json @@ -24,11 +24,22 @@ "simple_transport_hud.config.category.general.option.scale.name": "Scale", "simple_transport_hud.config.category.general.group.activated_huds.option.minecart_hud.name": "Minecart HUD", "simple_transport_hud.config.category.general.group.activated_huds.option.minecart_hud.description": "Minecart Hud toggle", + "simple_transport_hud.config.category.general.group.activated_huds.option.horse_hud.name": "Horse/Donky HUD", + "simple_transport_hud.config.category.general.group.activated_huds.option.horse_hud.description": "Horse/Donky Hud toggle", + "simple_transport_hud.config.category.general.group.activated_huds.option.happy_ghast_hud.name": "Happy Ghast HUD", + "simple_transport_hud.config.category.general.group.activated_huds.option.happy_ghast_hud.description": "Happy Ghast Hud toggle", + "simple_transport_hud.config.category.general.group.activated_huds.option.nautilus_hud.name": "Nautilus HUD", + "simple_transport_hud.config.category.general.group.activated_huds.option.nautilus_hud.description": "Nautilus Hud toggle", + "simple_transport_hud.config.category.general.group.activated_huds.option.strider_hud.name": "Strider HUD", + "simple_transport_hud.config.category.general.group.activated_huds.option.strider_hud.description": "Strider Hud toggle", "simple_transport_hud.config.category.general.option.safe_area.name": "Ignore Safe Area", "simple_transport_hud.config.category.general.option.safe_area.description": "Move HUD to screen edges, ignoring GUI safe area margins", "simple_transport_hud.config.category.elytra_options.option.hud_position.name": "HUD Position", "simple_transport_hud.config.category.elytra_options.option.hud_position.description": "Change the position of the HUD on screen", "simple_transport_hud.config.category.elytra_options.option.delay_hud.name": "Delay HUD displaying", "simple_transport_hud.config.category.elytra_options.option.delay_hud.description": "Change the time it takes for the HUD to appear", - "simple_transport_hud.config.category.minecart_hud.name": "Minecart HUD options" + "simple_transport_hud.config.category.minecart_hud.name": "Minecart HUD options", + "simple_transport_hud.config.category.horse_hud.name": "Horse HUD options", + "simple_transport_hud.config.category.happy_ghast_hud.name": "Happy Ghast HUD opptions", + "simple_transport_hud.config.category.strider.name": "Strider HUD options" } \ No newline at end of file