diff --git a/Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java b/Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java index d0149d4..764fb9f 100644 --- a/Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java +++ b/Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java @@ -1,5 +1,6 @@ package vazkii.neat; +import net.minecraft.world.entity.MobCategory; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -72,6 +73,8 @@ private static class Client implements NeatConfig.ConfigAccess { private final PropertyMirror showMaxHP = PropertyMirror.create(BOOLEAN); private final PropertyMirror showCurrentHP = PropertyMirror.create(BOOLEAN); private final PropertyMirror showPercentage = PropertyMirror.create(BOOLEAN); + private final PropertyMirror showOnPassive = PropertyMirror.create(BOOLEAN); + private final PropertyMirror showOnHostile = PropertyMirror.create(BOOLEAN); private final PropertyMirror showOnPlayers = PropertyMirror.create(BOOLEAN); private final PropertyMirror showOnBosses = PropertyMirror.create(BOOLEAN); private final PropertyMirror showOnlyFocused = PropertyMirror.create(BOOLEAN); @@ -80,6 +83,7 @@ private static class Client implements NeatConfig.ConfigAccess { private final PropertyMirror showEntityName = PropertyMirror.create(BOOLEAN); private final PropertyMirror disableNameTag = PropertyMirror.create(BOOLEAN); private final PropertyMirror> blacklist = PropertyMirror.create(ConfigTypes.makeList(STRING)); + private final PropertyMirror mobCategoryBlacklist = PropertyMirror.create(ConfigTypes.makeEnum(MobCategory.class)); public ConfigTree configure(ConfigTreeBuilder builder) { builder.beginValue("maxDistance", INTEGER, 24) @@ -158,6 +162,14 @@ public ConfigTree configure(ConfigTreeBuilder builder) { .withComment("Whether the percentage health of the mob should be shown") .finishValue(showPercentage::mirror) + .beginValue("showOnPassive", BOOLEAN, true) + .withComment("Whether bars on passive mobs should be shown") + .finishValue(showOnPassive::mirror) + + .beginValue("showOnHostile", BOOLEAN, true) + .withComment("Whether bars on hostile mobs should be shown (does not include bosses)") + .finishValue(showOnHostile::mirror) + .beginValue("showOnPlayers", BOOLEAN, true) .withComment("Whether bars on players should be shown") .finishValue(showOnPlayers::mirror) @@ -288,6 +300,16 @@ public boolean showPercentage() { return showPercentage.getValue(); } + @Override + public boolean showOnPassive() { + return showOnPassive.getValue(); + } + + @Override + public boolean showOnHostile() { + return showOnHostile.getValue(); + } + @Override public boolean showOnPlayers() { return showOnPlayers.getValue(); diff --git a/Forge/src/main/java/vazkii/neat/NeatForgeConfig.java b/Forge/src/main/java/vazkii/neat/NeatForgeConfig.java index e6252cf..5fd5363 100644 --- a/Forge/src/main/java/vazkii/neat/NeatForgeConfig.java +++ b/Forge/src/main/java/vazkii/neat/NeatForgeConfig.java @@ -1,5 +1,7 @@ package vazkii.neat; +import com.google.common.base.Enums; +import net.minecraft.world.entity.MobCategory; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; import net.minecraftforge.fml.ModLoadingContext; @@ -36,6 +38,8 @@ private static class ForgeNeatConfig implements NeatConfig.ConfigAccess { private final ConfigValue showMaxHP; private final ConfigValue showCurrentHP; private final ConfigValue showPercentage; + private final ConfigValue showOnPassive; + private final ConfigValue showOnHostile; private final ConfigValue showOnPlayers; private final ConfigValue showOnBosses; private final ConfigValue showOnlyFocused; @@ -67,6 +71,8 @@ public ForgeNeatConfig(ForgeConfigSpec.Builder builder) { showMaxHP = builder.define("Show Max HP", true); showCurrentHP = builder.define("Show Current HP", true); showPercentage = builder.define("Show HP Percentage", true); + showOnPassive = builder.comment("Whether bars on passive mobs should be shown").define("showOnPassive", true); + showOnHostile = builder.comment("Whether bars on hostile mobs should be shown (does not include bosses)").define("showOnHostile", true); showOnPlayers = builder.define("Display on Players", true); showOnBosses = builder.define("Display on Bosses", true); showOnlyFocused = builder.define("Only show the health bar for the entity looked at", false); @@ -175,6 +181,16 @@ public boolean showPercentage() { return showPercentage.get(); } + @Override + public boolean showOnPassive() { + return showOnPassive.get(); + } + + @Override + public boolean showOnHostile() { + return showOnHostile.get(); + } + @Override public boolean showOnPlayers() { return showOnPlayers.get(); diff --git a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java index 0e5f7c6..853cab4 100644 --- a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java +++ b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java @@ -169,6 +169,12 @@ private static boolean shouldShowPlate(LivingEntity living, Entity cameraEntity) if (NeatConfig.instance.showOnlyFocused() && getEntityLookedAt(cameraEntity) != living) { return false; } + if (!NeatConfig.instance.showOnPassive() && living.getType().getCategory().isFriendly()) { + return false; + } + if (!NeatConfig.instance.showOnHostile() && (!living.getType().getCategory().isFriendly() && !isBoss(living))) { + return false; + } if (living.hasPassenger(cameraEntity)) { return false; diff --git a/Xplat/src/main/java/vazkii/neat/NeatConfig.java b/Xplat/src/main/java/vazkii/neat/NeatConfig.java index 41cc3eb..8b9c76c 100644 --- a/Xplat/src/main/java/vazkii/neat/NeatConfig.java +++ b/Xplat/src/main/java/vazkii/neat/NeatConfig.java @@ -1,5 +1,7 @@ package vazkii.neat; +import net.minecraft.world.entity.MobCategory; + import java.util.List; public class NeatConfig { @@ -27,6 +29,8 @@ public interface ConfigAccess { boolean showMaxHP(); boolean showCurrentHP(); boolean showPercentage(); + boolean showOnPassive(); + boolean showOnHostile(); boolean showOnPlayers(); boolean showOnBosses(); boolean showOnlyFocused();