From 8839033f552d72baf6955173294453ca9e240927 Mon Sep 17 00:00:00 2001 From: Uraneptus Date: Mon, 9 Sep 2024 23:55:58 +0200 Subject: [PATCH] config to disable entity name --- .../main/java/vazkii/neat/NeatFiberConfig.java | 10 ++++++++++ .../main/java/vazkii/neat/NeatForgeConfig.java | 7 +++++++ .../main/java/vazkii/neat/HealthBarRenderer.java | 15 ++++++++++----- Xplat/src/main/java/vazkii/neat/NeatConfig.java | 1 + 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java b/Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java index e83161b..ffdbfd3 100644 --- a/Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java +++ b/Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java @@ -77,6 +77,7 @@ private static class Client implements NeatConfig.ConfigAccess { private final PropertyMirror showOnlyFocused = PropertyMirror.create(BOOLEAN); private final PropertyMirror showFullHealth = PropertyMirror.create(BOOLEAN); private final PropertyMirror enableDebugInfo = PropertyMirror.create(BOOLEAN); + private final PropertyMirror showEntityName = PropertyMirror.create(BOOLEAN); private final PropertyMirror> blacklist = PropertyMirror.create(ConfigTypes.makeList(STRING)); public ConfigTree configure(ConfigTreeBuilder builder) { @@ -176,6 +177,10 @@ public ConfigTree configure(ConfigTreeBuilder builder) { .withComment("Show extra debug info on the bar when F3 is enabled") .finishValue(enableDebugInfo::mirror) + .beginValue("showEntityName", BOOLEAN, true) + .withComment("Show entity name") + .finishValue(showEntityName::mirror) + .beginValue("blacklist", ConfigTypes.makeList(STRING), NeatConfig.DEFAULT_DISABLED) .withComment("Entity ID's that should not have bars rendered") .finishValue(blacklist::mirror); @@ -303,6 +308,11 @@ public boolean enableDebugInfo() { return enableDebugInfo.getValue(); } + @Override + public boolean showEntityName() { + return showEntityName.getValue(); + } + @Override public List blacklist() { return blacklist.getValue(); diff --git a/Forge/src/main/java/vazkii/neat/NeatForgeConfig.java b/Forge/src/main/java/vazkii/neat/NeatForgeConfig.java index d46679e..cd984f7 100644 --- a/Forge/src/main/java/vazkii/neat/NeatForgeConfig.java +++ b/Forge/src/main/java/vazkii/neat/NeatForgeConfig.java @@ -41,6 +41,7 @@ private static class ForgeNeatConfig implements NeatConfig.ConfigAccess { private final ConfigValue showOnlyFocused; private final ConfigValue showFullHealth; private final ConfigValue enableDebugInfo; + private final ConfigValue showEntityName; private final ConfigValue> blacklist; public ForgeNeatConfig(ForgeConfigSpec.Builder builder) { @@ -70,6 +71,7 @@ public ForgeNeatConfig(ForgeConfigSpec.Builder builder) { showOnlyFocused = builder.define("Only show the health bar for the entity looked at", false); showFullHealth = builder.define("Show entities with full health", true); enableDebugInfo = builder.define("Show Debug Info with F3", true); + showEntityName = builder.define("show_entity_name", true); blacklist = builder.comment("Blacklist uses entity IDs, not their display names. Use F3 to see them in the Neat bar.") .defineList("Blacklist", NeatConfig.DEFAULT_DISABLED, a -> true); @@ -196,6 +198,11 @@ public boolean enableDebugInfo() { return enableDebugInfo.get(); } + @Override + public boolean showEntityName() { + return showEntityName.get(); + } + @SuppressWarnings("unchecked") @Override public List blacklist() { diff --git a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java index 365128e..c0b1090 100644 --- a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java +++ b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java @@ -242,6 +242,9 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou if (NeatConfig.instance.drawBackground()) { float padding = NeatConfig.instance.backgroundPadding(); int bgHeight = NeatConfig.instance.backgroundHeight(); + if (!NeatConfig.instance.showEntityName()) { + bgHeight -= (int) 4F; + } VertexConsumer builder = buffers.getBuffer(NeatRenderType.BAR_TEXTURE_TYPE); builder.vertex(poseStack.last().pose(), -halfSize - padding, -bgHeight, 0.01F).color(0, 0, 0, 64).uv(0.0F, 0.0F).uv2(light).endVertex(); builder.vertex(poseStack.last().pose(), -halfSize - padding, barHeight + padding, 0.01F).color(0, 0, 0, 64).uv(0.0F, 0.5F).uv2(light).endVertex(); @@ -282,11 +285,13 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou // Name { - poseStack.pushPose(); - poseStack.translate(-halfSize, -4.5F, 0F); - poseStack.scale(textScale, textScale, textScale); - mc.font.drawInBatch(name, 0, 0, textColor, false, poseStack.last().pose(), buffers, Font.DisplayMode.NORMAL, black, light); - poseStack.popPose(); + if (NeatConfig.instance.showEntityName()) { + poseStack.pushPose(); + poseStack.translate(-halfSize, -4.5F, 0F); + poseStack.scale(textScale, textScale, textScale); + mc.font.drawInBatch(name, 0, 0, textColor, false, poseStack.last().pose(), buffers, Font.DisplayMode.NORMAL, black, light); + poseStack.popPose(); + } } // Health values (and debug ID) diff --git a/Xplat/src/main/java/vazkii/neat/NeatConfig.java b/Xplat/src/main/java/vazkii/neat/NeatConfig.java index 33bead3..4aa1b4c 100644 --- a/Xplat/src/main/java/vazkii/neat/NeatConfig.java +++ b/Xplat/src/main/java/vazkii/neat/NeatConfig.java @@ -32,6 +32,7 @@ public interface ConfigAccess { boolean showOnlyFocused(); boolean showFullHealth(); boolean enableDebugInfo(); + boolean showEntityName(); List blacklist(); }