Skip to content
Open
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
4 changes: 1 addition & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/nrojb/elytrakeybind/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
42 changes: 42 additions & 0 deletions src/main/java/com/nrojb/elytrakeybind/HudOverlay.java
Original file line number Diff line number Diff line change
@@ -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);
}
})
);

}

}
4 changes: 4 additions & 0 deletions src/main/resources/assets/elytrakeybind/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -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"
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.