Skip to content

Commit

Permalink
added option to disable passive or hostile mobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Sep 15, 2024
1 parent 9fdbcd2 commit 57f7934
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Fabric/src/main/java/vazkii/neat/NeatFiberConfig.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -72,6 +73,8 @@ private static class Client implements NeatConfig.ConfigAccess {
private final PropertyMirror<Boolean> showMaxHP = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showCurrentHP = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showPercentage = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showOnPassive = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showOnHostile = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showOnPlayers = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showOnBosses = PropertyMirror.create(BOOLEAN);
private final PropertyMirror<Boolean> showOnlyFocused = PropertyMirror.create(BOOLEAN);
Expand All @@ -80,6 +83,7 @@ private static class Client implements NeatConfig.ConfigAccess {
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));
private final PropertyMirror<MobCategory> mobCategoryBlacklist = PropertyMirror.create(ConfigTypes.makeEnum(MobCategory.class));

public ConfigTree configure(ConfigTreeBuilder builder) {
builder.beginValue("maxDistance", INTEGER, 24)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 16 additions & 0 deletions Forge/src/main/java/vazkii/neat/NeatForgeConfig.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -36,6 +38,8 @@ private static class ForgeNeatConfig implements NeatConfig.ConfigAccess {
private final ConfigValue<Boolean> showMaxHP;
private final ConfigValue<Boolean> showCurrentHP;
private final ConfigValue<Boolean> showPercentage;
private final ConfigValue<Boolean> showOnPassive;
private final ConfigValue<Boolean> showOnHostile;
private final ConfigValue<Boolean> showOnPlayers;
private final ConfigValue<Boolean> showOnBosses;
private final ConfigValue<Boolean> showOnlyFocused;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Xplat/src/main/java/vazkii/neat/NeatConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package vazkii.neat;

import net.minecraft.world.entity.MobCategory;

import java.util.List;

public class NeatConfig {
Expand Down Expand Up @@ -27,6 +29,8 @@ public interface ConfigAccess {
boolean showMaxHP();
boolean showCurrentHP();
boolean showPercentage();
boolean showOnPassive();
boolean showOnHostile();
boolean showOnPlayers();
boolean showOnBosses();
boolean showOnlyFocused();
Expand Down

0 comments on commit 57f7934

Please sign in to comment.