diff --git a/gradle.properties b/gradle.properties index 5e92b69..1233f6a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,8 +10,6 @@ org.gradle.configuration-cache=true # The Minecraft version must agree with the Neo version to get a valid artifact minecraft_version=1.21.1 -caelus_version=7.0.1 - # The Minecraft version range can use any release version of Minecraft as bounds. # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # as they do not follow standard versioning conventions. @@ -31,7 +29,7 @@ mod_name=ElytraKeybind # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GLGPL-3.0 # The mod version. See https://semver.org/ -mod_version=1.0.1 +mod_version=1.1.0 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/nrojb/elytrakeybind/Config.java b/src/main/java/com/nrojb/elytrakeybind/Config.java index 264f9ba..59da951 100644 --- a/src/main/java/com/nrojb/elytrakeybind/Config.java +++ b/src/main/java/com/nrojb/elytrakeybind/Config.java @@ -9,5 +9,21 @@ public class Config { .comment("Toggle the \"Elytra Toggle: true\" messages") .define("disableChatMessages", false); + public static final ModConfigSpec.BooleanValue showEnabledIcon = BUILDER + .comment("Show an icon on the HUD when Elytra are enabled.") + .define("showEnabledIcon", true); + + public static final ModConfigSpec.BooleanValue showDisabledIcon = BUILDER + .comment("Show an icon on the HUD when Elytra are disabled.") + .define("showDisabledIcon", true); + + public static final ModConfigSpec.IntValue xOffset = BUILDER + .comment("X Position for the Enabled/Disabled icon.") + .defineInRange("iconXPosition", 0, Integer.MIN_VALUE, Integer.MAX_VALUE); + + public static final ModConfigSpec.IntValue yOffset = BUILDER + .comment("Y Position for the Enabled/Disabled icon.") + .defineInRange("iconYPosition", 0, Integer.MIN_VALUE, Integer.MAX_VALUE); + static final ModConfigSpec SPEC = BUILDER.build(); } diff --git a/src/main/java/com/nrojb/elytrakeybind/HudOverlay.java b/src/main/java/com/nrojb/elytrakeybind/HudOverlay.java new file mode 100644 index 0000000..5bd3591 --- /dev/null +++ b/src/main/java/com/nrojb/elytrakeybind/HudOverlay.java @@ -0,0 +1,42 @@ +package com.nrojb.elytrakeybind; + +import net.minecraft.client.Minecraft; +import net.minecraft.resources.ResourceLocation; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.client.event.RegisterGuiLayersEvent; +import net.neoforged.neoforge.client.gui.VanillaGuiLayers; + +@EventBusSubscriber(modid = ElytraKeybind.MODID, value = Dist.CLIENT) +public class HudOverlay +{ + private static final ResourceLocation LOCKED_ICON = ResourceLocation.fromNamespaceAndPath(ElytraKeybind.MODID, "textures/locked.png"); + private static final ResourceLocation UNLOCKED_ICON = ResourceLocation.fromNamespaceAndPath(ElytraKeybind.MODID, "textures/unlocked.png"); + + private static final ResourceLocation ICON_ID = ResourceLocation.fromNamespaceAndPath(ElytraKeybind.MODID, "status_icon"); + + @SubscribeEvent + public static void registerGuiLayers(RegisterGuiLayersEvent event) { + + event.registerAbove(VanillaGuiLayers.HOTBAR, ICON_ID, + ((guiGraphics, deltaTracker) -> { + + // Base location is to the right of the hotbar. + int x = Config.xOffset.getAsInt() + Minecraft.getInstance().getWindow().getGuiScaledWidth() / 2 + 100; + int y = Config.yOffset.getAsInt() + Minecraft.getInstance().getWindow().getGuiScaledHeight() - 20; + + if (ElytraKeybind.elytraToggleEnabled && Config.showEnabledIcon.getAsBoolean()) + { + guiGraphics.blit(UNLOCKED_ICON, x, y, 0, 0, 16, 16, 16, 16); + } + else if (!ElytraKeybind.elytraToggleEnabled && Config.showDisabledIcon.getAsBoolean()) + { + guiGraphics.blit(LOCKED_ICON, x, y, 0, 0, 16, 16, 16, 16); + } + }) + ); + + } + +} diff --git a/src/main/resources/assets/elytrakeybind/lang/en_us.json b/src/main/resources/assets/elytrakeybind/lang/en_us.json index 3155fa1..d6cad48 100644 --- a/src/main/resources/assets/elytrakeybind/lang/en_us.json +++ b/src/main/resources/assets/elytrakeybind/lang/en_us.json @@ -1,4 +1,8 @@ { "elytrakeybind.configuration.disableChatMessages": "Disable Chat Messages", + "elytrakeybind.configuration.showEnabledIcon": "Show Enabled Icon", + "elytrakeybind.configuration.showDisabledIcon": "Show Disabled Icon", + "elytrakeybind.configuration.iconXPosition": "X Position", + "elytrakeybind.configuration.iconYPosition": "Y Position", "key.elytrakeybind.category": "ElytraKeybind" } \ No newline at end of file diff --git a/src/main/resources/assets/elytrakeybind/textures/ElytraIcon.psd b/src/main/resources/assets/elytrakeybind/textures/ElytraIcon.psd new file mode 100644 index 0000000..78ec27d Binary files /dev/null and b/src/main/resources/assets/elytrakeybind/textures/ElytraIcon.psd differ diff --git a/src/main/resources/assets/elytrakeybind/textures/locked.png b/src/main/resources/assets/elytrakeybind/textures/locked.png new file mode 100644 index 0000000..e294cf0 Binary files /dev/null and b/src/main/resources/assets/elytrakeybind/textures/locked.png differ diff --git a/src/main/resources/assets/elytrakeybind/textures/unlocked.png b/src/main/resources/assets/elytrakeybind/textures/unlocked.png new file mode 100644 index 0000000..766906c Binary files /dev/null and b/src/main/resources/assets/elytrakeybind/textures/unlocked.png differ