Skip to content

Commit

Permalink
config to disable vanilla name tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Sep 9, 2024
1 parent 8839033 commit 73e62b8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 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 @@ -78,6 +78,7 @@ private static class Client implements NeatConfig.ConfigAccess {
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<Boolean> disableNameTag = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<List<String>> blacklist = PropertyMirror.create(ConfigTypes.makeList(STRING));

public ConfigTree configure(ConfigTreeBuilder builder) {
Expand Down Expand Up @@ -181,6 +182,10 @@ public ConfigTree configure(ConfigTreeBuilder builder) {
.withComment("Show entity name")
.finishValue(showEntityName::mirror)

.beginValue("disableNameTag", BOOLEAN, false)
.withComment("Disables the rendering of the vanilla name tag")
.finishValue(disableNameTag::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 @@ -313,6 +318,11 @@ public boolean showEntityName() {
return showEntityName.getValue();
}

@Override
public boolean disableNameTag() {
return disableNameTag.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 @@ -42,6 +42,7 @@ private static class ForgeNeatConfig implements NeatConfig.ConfigAccess {
private final ConfigValue<Boolean> showFullHealth;
private final ConfigValue<Boolean> enableDebugInfo;
private final ConfigValue<Boolean> showEntityName;
private final ConfigValue<Boolean> disableNameTag;
private final ConfigValue<List<? extends String>> blacklist;

public ForgeNeatConfig(ForgeConfigSpec.Builder builder) {
Expand Down Expand Up @@ -72,6 +73,7 @@ public ForgeNeatConfig(ForgeConfigSpec.Builder builder) {
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);
disableNameTag = builder.comment("Disables the rendering of the vanilla name tag").define("disable_name_tag", false);
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 @@ -203,6 +205,11 @@ public boolean showEntityName() {
return showEntityName.get();
}

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

@SuppressWarnings("unchecked")
@Override
public List<String> blacklist() {
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 @@ -33,6 +33,7 @@ public interface ConfigAccess {
boolean showFullHealth();
boolean enableDebugInfo();
boolean showEntityName();
boolean disableNameTag();
List<String> blacklist();
}

Expand Down
23 changes: 23 additions & 0 deletions Xplat/src/main/java/vazkii/neat/mixin/EntityRendererMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package vazkii.neat.mixin;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import vazkii.neat.HealthBarRenderer;
import vazkii.neat.NeatConfig;

@Mixin(EntityRenderer.class)
public class EntityRendererMixin {

@Inject(method = "render(Lnet/minecraft/world/entity/Entity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;renderNameTag(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"), cancellable = true)
private void neat_disableNameTag(Entity $$0, float $$1, float $$2, PoseStack $$3, MultiBufferSource $$4, int $$5, CallbackInfo ci) {
if (NeatConfig.instance.disableNameTag()) {
ci.cancel();
}
}
}
1 change: 1 addition & 0 deletions Xplat/src/main/resources/neat.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"package": "vazkii.neat.mixin",
"mixins": [
"EntityRendererMixin"
],
"client": [
"AccessorRenderType",
Expand Down

0 comments on commit 73e62b8

Please sign in to comment.