Skip to content

Commit

Permalink
config to disable entity name
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Sep 9, 2024
1 parent b47fbc7 commit 8839033
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private static class Client implements NeatConfig.ConfigAccess {
private final PropertyMirror<Boolean> showOnlyFocused = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showFullHealth = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> enableDebugInfo = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showEntityName = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<List<String>> blacklist = PropertyMirror.create(ConfigTypes.makeList(STRING));

public ConfigTree configure(ConfigTreeBuilder builder) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -303,6 +308,11 @@ public boolean enableDebugInfo() {
return enableDebugInfo.getValue();
}

@Override
public boolean showEntityName() {
return showEntityName.getValue();
}

@Override
public List<String> blacklist() {
return blacklist.getValue();
Expand Down
7 changes: 7 additions & 0 deletions Forge/src/main/java/vazkii/neat/NeatForgeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private static class ForgeNeatConfig implements NeatConfig.ConfigAccess {
private final ConfigValue<Boolean> showOnlyFocused;
private final ConfigValue<Boolean> showFullHealth;
private final ConfigValue<Boolean> enableDebugInfo;
private final ConfigValue<Boolean> showEntityName;
private final ConfigValue<List<? extends String>> blacklist;

public ForgeNeatConfig(ForgeConfigSpec.Builder builder) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -196,6 +198,11 @@ public boolean enableDebugInfo() {
return enableDebugInfo.get();
}

@Override
public boolean showEntityName() {
return showEntityName.get();
}

@SuppressWarnings("unchecked")
@Override
public List<String> blacklist() {
Expand Down
15 changes: 10 additions & 5 deletions Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Xplat/src/main/java/vazkii/neat/NeatConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface ConfigAccess {
boolean showOnlyFocused();
boolean showFullHealth();
boolean enableDebugInfo();
boolean showEntityName();
List<String> blacklist();
}

Expand Down

0 comments on commit 8839033

Please sign in to comment.