From c0cc6166c15b047f56860a00213a4a5e5cec82f3 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 11 Mar 2020 23:32:37 +0100 Subject: [PATCH] added a config to move the aura cache bar Closes #88 --- src/main/java/de/ellpeck/naturesaura/ModConfig.java | 5 +++++ .../java/de/ellpeck/naturesaura/events/ClientEvents.java | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java index 0d288a92..e3bc07ee 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -45,6 +45,7 @@ public final class ModConfig { public ForgeConfigSpec.ConfigValue respectVanillaParticleSettings; public ForgeConfigSpec.ConfigValue excessParticleAmount; public ForgeConfigSpec.ConfigValue auraBarLocation; + public ForgeConfigSpec.ConfigValue cacheBarLocation; public ForgeConfigSpec.ConfigValue debugText; public ForgeConfigSpec.ConfigValue debugWorld; @@ -148,6 +149,10 @@ public final class ModConfig { .comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right") .translation("config." + NaturesAura.MOD_ID + ".auraBarLocation") .defineInRange("auraBarLocation", 0, 0, 3); + this.cacheBarLocation = builder + .comment("The location of the aura cache bar, where 0 is to the left of the hotbar and 1 is to the right of the hotbar") + .translation("config." + NaturesAura.MOD_ID + ".cacheBarLocation") + .defineInRange("cacheBarLocation", 0, 0, 1); this.debugText = builder .comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode") .translation("config." + NaturesAura.MOD_ID + ".debugText") diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 355a2524..f48d5a41 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -294,7 +294,9 @@ public class ClientEvents { if (!heldCache.isEmpty()) { IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80); - int x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29); + + int conf = ModConfig.instance.cacheBarLocation.get(); + int x = res.getScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29) : 93); int y = res.getScaledHeight() - 8; RenderSystem.pushMatrix(); @@ -310,7 +312,7 @@ public class ClientEvents { float scale = 0.75F; RenderSystem.scalef(scale, scale, scale); String s = heldCache.getDisplayName().getFormattedText(); - mc.fontRenderer.drawStringWithShadow(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color); + mc.fontRenderer.drawStringWithShadow(s, conf == 1 ? x / scale : (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color); RenderSystem.color4f(1F, 1F, 1F, 1); RenderSystem.popMatrix();