From b2b6868ed9c6ccec19f0a0ff278aa972d86f17de Mon Sep 17 00:00:00 2001 From: Provismet <17149901+Provismet@users.noreply.github.com> Date: Wed, 14 May 2025 23:32:31 +0100 Subject: [PATCH 01/11] Remove self-made render pipeline. --- .../provihealth/mixin/ShaderLoaderMixin.java | 19 ------------------- .../provihealth/world/EntityHealthBar.java | 9 +-------- src/main/resources/provihealth.mixins.json | 3 +-- 3 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 src/main/java/com/provismet/provihealth/mixin/ShaderLoaderMixin.java diff --git a/src/main/java/com/provismet/provihealth/mixin/ShaderLoaderMixin.java b/src/main/java/com/provismet/provihealth/mixin/ShaderLoaderMixin.java deleted file mode 100644 index 5fd575e..0000000 --- a/src/main/java/com/provismet/provihealth/mixin/ShaderLoaderMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.provismet.provihealth.mixin; - -import com.provismet.provihealth.world.HealthBarRendering; -import net.minecraft.client.gl.ShaderLoader; -import net.minecraft.resource.ResourceManager; -import net.minecraft.resource.SinglePreparationResourceReloader; -import net.minecraft.util.profiler.Profiler; -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; - -@Mixin(ShaderLoader.class) -public abstract class ShaderLoaderMixin extends SinglePreparationResourceReloader { - @Inject(method = "apply(Lnet/minecraft/client/gl/ShaderLoader$Definitions;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At("HEAD")) - private void addHealth (ShaderLoader.Definitions definitions, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci) { - HealthBarRendering.init(); - } -} diff --git a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java index f21749b..6fdebdd 100644 --- a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java +++ b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java @@ -45,14 +45,7 @@ public static void render (EntityRenderState state, MatrixStack matrices, Vertex matrices.translate(0f, (mixinState.provi_Health$shouldRenderLabel() && !Options.overrideLabels && !(state.invisible || (state instanceof LivingEntityRenderState livingState && livingState.invisibleToPlayer)) ? 0.02f + 0.3f / Options.worldHealthBarScale : 0f), 0f); matrices.multiply(rotation); // This is the problem. - RenderLayer layer; - if (Options.compatInWorld) { - layer = HealthBarRendering.getHealthBarCompatibilityLayer(COMPAT_BARS); - } - else { - layer = HealthBarRendering.getHealthBarLayer(BARS); - } - layer = RenderLayer.getText(BARS); // WHY DOES THIS FIX THE IRIS ISSUE?! + RenderLayer layer = RenderLayer.getText(BARS); // WHY DOES THIS FIX THE IRIS ISSUE?! VertexConsumer vertexConsumer = vertexConsumers.getBuffer(layer); Matrix4f model = matrices.peek().getPositionMatrix(); diff --git a/src/main/resources/provihealth.mixins.json b/src/main/resources/provihealth.mixins.json index e80b203..35c18da 100644 --- a/src/main/resources/provihealth.mixins.json +++ b/src/main/resources/provihealth.mixins.json @@ -7,8 +7,7 @@ "client": [ "EntityRendererMixin", "EntityRenderStateMixin", - "LivingEntityMixin", - "ShaderLoaderMixin" + "LivingEntityMixin" ], "injectors": { "defaultRequire": 1 From dd3d2ba319eeedabfbb4dd93b98ead3f4f6a7b1c Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Sun, 18 May 2025 22:20:44 +0300 Subject: [PATCH 02/11] FEAT: + Added entity aggression logic to the HUD and world healthbars + Toggle-able config along with new colour config entries for different entity aggression healthbar colours. + Dynamic healthbar colour changes in case mob aggression changes (neutral to aggressive/vice versa) + Accounts for angerable hostile mobs, tameable mobs, and all regularly hostile mobs (default is passive) TODO: + Verify Piglin unique behaviour with mod healthbar colours. + Fix and figure out Llama aggression behaviour to reflect in colours Optional: + Make the colour changes lerp a bit smoothly Note: I finished the content for this commit about 3 weeks ago but had to go out of town --- .../compat/ProviHealthConfigScreen.java | 66 ++++++++++++++++--- .../provismet/provihealth/config/Options.java | 42 +++++++++--- .../provihealth/hud/TargetHealthBar.java | 52 ++++++++++++++- .../interfaces/IMixinEntityRenderState.java | 4 ++ .../interfaces/IMixinLivingEntity.java | 2 + .../mixin/EntityRenderStateMixin.java | 14 ++++ .../mixin/EntityRendererMixin.java | 1 + .../provihealth/mixin/LivingEntityMixin.java | 11 ++++ .../provihealth/util/FunctionalUtilities.java | 5 ++ .../provihealth/world/EntityHealthBar.java | 52 ++++++++++++++- .../assets/provihealth/lang/en_gb.json | 8 ++- .../assets/provihealth/lang/en_us.json | 8 ++- 12 files changed, 238 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java diff --git a/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java b/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java index 96b7eef..4c8f4db 100644 --- a/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java +++ b/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java @@ -97,17 +97,42 @@ public static Screen build (Screen parent) { .build() ); - hud.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barStartColour"), Options.hudStartColour) + hud.addEntry(entryBuilder.startBooleanToggle(Text.translatable("entry.provihealth.aggressionColours"), Options.useHudAggressionColours) + .setDefaultValue(true) + .setTooltip(Text.translatable("tooltip.provihealth.aggressionColours")) + .setSaveConsumer(newValue -> Options.useHudAggressionColours = newValue) + .build() + ); + + hud.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barDefaultStartColour"), Options.hudDefaultStartColour) .setDefaultValue(0x00C100) .setSaveConsumer(newValue -> { - Options.hudStartColour = newValue; - Options.unpackedStartHud = Vec3d.unpackRgb(newValue).toVector3f(); + Options.hudDefaultStartColour = newValue; + Options.unpackedDefaultStartHud = Vec3d.unpackRgb(newValue).toVector3f(); }) .build() ); - hud.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barEndColour"), Options.hudEndColour) + hud.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barNeutralStartColour"), Options.hudNeutralStartColour) + .setDefaultValue(0xF2D00C) + .setSaveConsumer(newValue -> { + Options.hudNeutralStartColour = newValue; + Options.unpackedNeutralStartHud = Vec3d.unpackRgb(newValue).toVector3f(); + }) + .build() + ); + + hud.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barHostileStartColour"), Options.hudHostileStartColour) .setDefaultValue(0xFF0000) + .setSaveConsumer(newValue -> { + Options.hudHostileStartColour = newValue; + Options.unpackedHostileStartHud = Vec3d.unpackRgb(newValue).toVector3f(); + }) + .build() + ); + + hud.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barEndColour"), Options.hudEndColour) + .setDefaultValue(0xBB0000) .setSaveConsumer(newValue -> { Options.hudEndColour = newValue; Options.unpackedEndHud = Vec3d.unpackRgb(newValue).toVector3f(); @@ -214,17 +239,42 @@ public static Screen build (Screen parent) { .build() ); - health.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barStartColour"), Options.worldStartColour) + health.addEntry(entryBuilder.startBooleanToggle(Text.translatable("entry.provihealth.aggressionColours"), Options.useWorldAggressionColours) + .setDefaultValue(true) + .setTooltip(Text.translatable("tooltip.provihealth.aggressionColours")) + .setSaveConsumer(newValue -> Options.useWorldAggressionColours = newValue) + .build() + ); + + health.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barDefaultStartColour"), Options.worldDefaultStartColour) .setDefaultValue(0x00C100) .setSaveConsumer(newValue -> { - Options.worldStartColour = newValue; - Options.unpackedStartWorld = Vec3d.unpackRgb(newValue).toVector3f(); + Options.worldDefaultStartColour = newValue; + Options.unpackedDefaultStartWorld = Vec3d.unpackRgb(newValue).toVector3f(); }) .build() ); - health.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barEndColour"), Options.worldEndColour) + health.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barNeutralStartColour"), Options.worldNeutralStartColour) + .setDefaultValue(0xF2D00C) + .setSaveConsumer(newValue -> { + Options.worldNeutralStartColour = newValue; + Options.unpackedNeutralStartWorld = Vec3d.unpackRgb(newValue).toVector3f(); + }) + .build() + ); + + health.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barHostileStartColour"), Options.worldHostileStartColour) .setDefaultValue(0xFF0000) + .setSaveConsumer(newValue -> { + Options.worldHostileStartColour = newValue; + Options.unpackedHostileStartWorld = Vec3d.unpackRgb(newValue).toVector3f(); + }) + .build() + ); + + health.addEntry(entryBuilder.startColorField(Text.translatable("entry.provihealth.barEndColour"), Options.worldEndColour) + .setDefaultValue(0xBB0000) .setSaveConsumer(newValue -> { Options.worldEndColour = newValue; Options.unpackedEndWorld = Vec3d.unpackRgb(newValue).toVector3f(); diff --git a/src/main/java/com/provismet/provihealth/config/Options.java b/src/main/java/com/provismet/provihealth/config/Options.java index 5958ce2..f6f2061 100644 --- a/src/main/java/com/provismet/provihealth/config/Options.java +++ b/src/main/java/com/provismet/provihealth/config/Options.java @@ -56,20 +56,29 @@ public class Options { public static boolean useCustomHudPortraits = true; public static int hudOffsetPercent = 0; public static HUDPosition hudPosition = HUDPosition.LEFT; - public static int hudStartColour = 0x00C100; - public static int hudEndColour = 0xFF0000; - public static Vector3f unpackedStartHud = Vec3d.unpackRgb(hudStartColour).toVector3f(); + public static int hudDefaultStartColour = 0x00C100; // Renamed to default for clarity with other types. Passive mobs use default + public static int hudNeutralStartColour = 0xF2D00C; + public static int hudHostileStartColour = 0xFF0000; + public static int hudEndColour = 0xBB0000; // Darkened end colour slightly to account for hostile mob bars being dynamic, albeit mildly + public static Vector3f unpackedDefaultStartHud = Vec3d.unpackRgb(hudDefaultStartColour).toVector3f(); + public static Vector3f unpackedNeutralStartHud = Vec3d.unpackRgb(hudNeutralStartColour).toVector3f(); + public static Vector3f unpackedHostileStartHud = Vec3d.unpackRgb(hudHostileStartColour).toVector3f(); public static Vector3f unpackedEndHud = Vec3d.unpackRgb(hudEndColour).toVector3f(); public static boolean hudGradient = false; public static boolean hudTitles = true; public static boolean hudStatuses = true; + public static boolean useHudAggressionColours = true; public static boolean showTextInWorld = true; public static float maxRenderDistance = 24f; public static float worldHealthBarScale = 1.5f; - public static int worldStartColour = 0x00C100; - public static int worldEndColour = 0xFF0000; - public static Vector3f unpackedStartWorld = Vec3d.unpackRgb(worldStartColour).toVector3f(); + public static int worldDefaultStartColour = 0x00C100; // Renamed to default for clarity with other types. Passive mobs use default + public static int worldNeutralStartColour = 0xF2D00C; + public static int worldHostileStartColour = 0xFF0000; + public static int worldEndColour = 0xBB0000; // Darkened end colour slightly to account for hostile mob bars being dynamic, albeit mildly + public static Vector3f unpackedDefaultStartWorld = Vec3d.unpackRgb(worldDefaultStartColour).toVector3f(); + public static Vector3f unpackedNeutralStartWorld = Vec3d.unpackRgb(worldNeutralStartColour).toVector3f(); + public static Vector3f unpackedHostileStartWorld = Vec3d.unpackRgb(worldHostileStartColour).toVector3f(); public static Vector3f unpackedEndWorld = Vec3d.unpackRgb(worldEndColour).toVector3f(); public static boolean worldGradient = false; public static boolean overrideLabels = false; @@ -78,6 +87,7 @@ public class Options { public static boolean worldTitles = true; public static boolean tintBackground = false; public static boolean useTeamColours = false; + public static boolean useWorldAggressionColours = true; public static boolean spawnDamageParticles = true; public static boolean spawnHealingParticles = false; @@ -159,7 +169,10 @@ public static void save () { .append("hudPosition", hudPosition.name()) .append("hudOffsetY", hudOffsetPercent) .append("hudGradient", hudGradient) - .append("hudStartColour", hudStartColour) + .append("hudDefaultStartColour", hudDefaultStartColour) + .append("hudNeutralStartColour", hudNeutralStartColour) + .append("hudHostileStartColour", hudHostileStartColour) + .append("useHudAggressionColours", useHudAggressionColours) .append("hudEndColour", hudEndColour) .append("bossHUD", bossHUD.name()) .append("hostileHUD", hostileHUD.name()) @@ -177,7 +190,9 @@ public static void save () { .append("barScale", worldHealthBarScale) .append("worldOffsetY", worldOffsetY) .append("worldGradient", worldGradient) - .append("worldStartColour", worldStartColour) + .append("worldDefaultStartColour", worldDefaultStartColour) + .append("worldNeutralStartColour", worldNeutralStartColour) + .append("worldHostileStartColour", worldHostileStartColour) .append("worldEndColour", worldEndColour) .append("bossHealth", bosses.name()) .append("bossTarget", bossesVisibilityOverride) @@ -190,6 +205,7 @@ public static void save () { .append("worldTitles", worldTitles) .append("tintBackground", tintBackground) .append("useTeamColours", useTeamColours) + .append("useWorldAggressionColours", useWorldAggressionColours) .appendArray("healthBlacklist", blacklist) ) .append("particles", new JsonBuilder() @@ -240,7 +256,10 @@ public static void load () { json.getString("hudPosition").ifPresent(val -> hudPosition = HUDPosition.valueOf(val)); json.getInteger("hudOffsetY").ifPresent(val -> hudOffsetPercent = val); json.getBoolean("hudGradient").ifPresent(val -> hudGradient = val); - json.getInteger("hudStartColour").ifPresent(val -> hudStartColour = val); + json.getBoolean("useHudAggressionColours").ifPresent(val -> useHudAggressionColours = val); + json.getInteger("hudDefaultStartColour").ifPresent(val -> hudDefaultStartColour = val); + json.getInteger("hudNeutralStartColour").ifPresent(val -> hudNeutralStartColour = val); + json.getInteger("hudHostileStartColour").ifPresent(val -> hudHostileStartColour = val); json.getInteger("hudEndColour").ifPresent(val -> hudEndColour = val); json.getString("bossHUD").ifPresent(val -> bossHUD = HUDType.valueOf(val)); json.getString("hostileHUD").ifPresent(val -> hostileHUD = HUDType.valueOf(val)); @@ -262,7 +281,10 @@ public static void load () { json.getFloat("barScale").ifPresent(val -> worldHealthBarScale = val); json.getFloat("worldOffsetY").ifPresent(val -> worldOffsetY = val); json.getBoolean("worldGradient").ifPresent(val -> worldGradient = val); - json.getInteger("worldStartColour").ifPresent(val -> worldStartColour = val); + json.getBoolean("useWorldAggressionColours").ifPresent(val -> useWorldAggressionColours = val); + json.getInteger("worldDefaultStartColour").ifPresent(val -> worldDefaultStartColour = val); + json.getInteger("worldNeutralStartColour").ifPresent(val -> worldNeutralStartColour = val); + json.getInteger("worldHostileStartColour").ifPresent(val -> worldHostileStartColour = val); json.getInteger("worldEndColour").ifPresent(val -> worldEndColour = val); json.getString("bossHealth").ifPresent(val -> bosses = VisibilityType.valueOf(val)); json.getBoolean("bossTarget").ifPresent(val -> bossesVisibilityOverride = val); diff --git a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java index 4642c0a..d068163 100644 --- a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java +++ b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java @@ -33,6 +33,10 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.entity.EntityPose; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.mob.Angerable; +import net.minecraft.entity.mob.HostileEntity; +import net.minecraft.entity.passive.LlamaEntity; +import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -307,15 +311,57 @@ private int glideVehicleHealth (int trueValue, float glideFactor) { this.currentVehicleHealthWidth += (int)((float)(trueValue - this.currentVehicleHealthWidth) * MathHelper.clamp(glideFactor, 0.001f, 1f)); return this.currentVehicleHealthWidth; } - + private void renderBar (DrawContext drawContext, int width, int barIndex) { - Vector3f barColour = Options.getBarColour((float)width / (float)BAR_WIDTH, barIndex == 1 ? Options.WHITE : Options.unpackedStartHud, Options.unpackedEndHud, barIndex == 0 && Options.hudGradient); + + Vector3f startColour; + LivingEntity entity = this.target; + + System.out.println(((IMixinLivingEntity)this.target).provi_Health$getAnger()); + + if (barIndex == 1) startColour = Options.WHITE; + // ? Llamas are neutral in behaviour but do not extend Angerable, so they need their own checks + // ? If a neutral mob is angered, the bar changes colours to hostile colours. To remove this, remove the null checks for getAngryAt() + // ? Neutrality is checked first, because Endermen, Zombie Piglins, and other Angerable AND HostileEntity mobs should be checked here + // ? before hostility, as they are not hostile unless provoked. + // ? Tameable Angerable mobs only appear with neutral colours if they are untamed. Once tamed they are passive + + // ~ Neutral Aggression Level + else if (Options.useHudAggressionColours && ( + // * If the target is a *non-angered* but angerable tameable mob and is not tamed + (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).getAngryAt() == null) + // * If the target is a *non-angered* LlamaEntity + // || (entity instanceof LlamaEntity && !((IMixinLivingEntity)entity).provi_Health$isAngryAtPlayer()) + || (entity instanceof LlamaEntity) + // * If the target is a *non-angered* but angerable untameable mob + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && ((Angerable)entity).getAngryAt() == null)) + )) { + startColour = Options.unpackedNeutralStartHud; + } + + + // ~ Aggressive/Hostile Aggression Level + else if (Options.useWorldAggressionColours && + // * If the target is a Hostile Entity + entity instanceof HostileEntity + // * If the target is an *angered* LlamaEntity + // || (entity instanceof LlamaEntity && ((IMixinLivingEntity)entity).provi_Health$isAngryAtPlayer()) + // * If the target is an *angered* Angerable entity + || (entity instanceof Angerable && ((Angerable)entity).getAngryAt() != null) + ) { + startColour = Options.unpackedHostileStartHud; + } + + // ~ Passive and Default Aggression Level (all passive mobs and modded mobs that do not extend vanilla classes) + else startColour = Options.unpackedDefaultStartHud; + + Vector3f barColour = Options.getBarColour((float)width / (float)BAR_WIDTH, startColour, Options.unpackedEndHud, barIndex == 0 && Options.hudGradient); if (Options.hudPosition == HUDPosition.LEFT) this.drawTexturedQuad(BARS, drawContext, BAR_X, BAR_X + width, BAR_Y, BAR_Y + BAR_HEIGHT, 0, 0f, (float)width / (float)BAR_WIDTH, barIndex / 2f, BAR_V2 + barIndex / 2f, barColour); else this.drawHorizontallyMirroredTexturedQuad(BARS, drawContext, BAR_X + (BAR_WIDTH - width), BAR_X + BAR_WIDTH, BAR_Y, BAR_Y + BAR_HEIGHT, 0, 0f, (float)width / (float)BAR_WIDTH, barIndex / 2f, BAR_V2 + barIndex / 2f, barColour); } private void renderMountBar (DrawContext drawContext, int width, int barIndex) { - Vector3f barColour = Options.getBarColour((float)width / (float)MOUNT_BAR_WIDTH, barIndex == 1 ? Options.WHITE : Options.unpackedStartHud, Options.unpackedEndHud, barIndex == 0 && Options.hudGradient); + Vector3f barColour = Options.getBarColour((float)width / (float)MOUNT_BAR_WIDTH, barIndex == 1 ? Options.WHITE : Options.unpackedDefaultStartHud, Options.unpackedEndHud, barIndex == 0 && Options.hudGradient); if (Options.hudPosition == HUDPosition.LEFT) this.drawTexturedQuad(BARS, drawContext, BAR_X, BAR_X + width, BAR_Y + BAR_HEIGHT, BAR_Y + BAR_HEIGHT + MOUNT_BAR_HEIGHT, 0, 0f, ((float)width / (float)MOUNT_BAR_WIDTH) * MOUNT_BAR_U2, MOUNT_BAR_V1 + barIndex / 2f, MOUNT_BAR_V2 + barIndex / 2f, barColour); else this.drawHorizontallyMirroredTexturedQuad(BARS, drawContext, BAR_X + (MOUNT_BAR_WIDTH - width) + BAR_WIDTH_DIFF, BAR_X + BAR_WIDTH_DIFF + MOUNT_BAR_WIDTH, BAR_Y + BAR_HEIGHT, BAR_Y + BAR_HEIGHT + MOUNT_BAR_HEIGHT, 0, 0f, ((float)width / (float)MOUNT_BAR_WIDTH) * MOUNT_BAR_U2, MOUNT_BAR_V1 + barIndex / 2f, MOUNT_BAR_V2 + barIndex / 2f, barColour); } diff --git a/src/main/java/com/provismet/provihealth/interfaces/IMixinEntityRenderState.java b/src/main/java/com/provismet/provihealth/interfaces/IMixinEntityRenderState.java index 6089fde..eec89ff 100644 --- a/src/main/java/com/provismet/provihealth/interfaces/IMixinEntityRenderState.java +++ b/src/main/java/com/provismet/provihealth/interfaces/IMixinEntityRenderState.java @@ -2,6 +2,8 @@ import com.provismet.provihealth.util.HealthContainer; import net.minecraft.text.Text; +import net.minecraft.entity.Entity; + import org.jetbrains.annotations.Nullable; import java.util.List; @@ -15,6 +17,7 @@ public interface IMixinEntityRenderState { void provi_Health$setShouldRenderLabel (boolean value); void provi_Health$setLabel (Text label); void provi_Health$setTeamColour (Integer colour); + void provi_Health$setEntityType (Entity entity); boolean provi_Health$shouldRenderHealth (); HealthContainer provi_Health$getHealth (); @@ -23,5 +26,6 @@ public interface IMixinEntityRenderState { List provi_Health$getTitles (); boolean provi_Health$shouldRenderLabel (); Text provi_Health$getLabel (); + Entity provi_Health$getEntityType (); @Nullable Integer provi_Health$getTeamColour (); } diff --git a/src/main/java/com/provismet/provihealth/interfaces/IMixinLivingEntity.java b/src/main/java/com/provismet/provihealth/interfaces/IMixinLivingEntity.java index 1f78cf2..db50a62 100644 --- a/src/main/java/com/provismet/provihealth/interfaces/IMixinLivingEntity.java +++ b/src/main/java/com/provismet/provihealth/interfaces/IMixinLivingEntity.java @@ -10,4 +10,6 @@ public interface IMixinLivingEntity { HealthContainer provi_Health$getHealthContainer (); HealthContainer provi_Health$getMountHealthContainer (); List> provi_Health$getClientSideStatusEffects (); + boolean provi_Health$isAngryAtPlayer (); + int provi_Health$getAnger (); } diff --git a/src/main/java/com/provismet/provihealth/mixin/EntityRenderStateMixin.java b/src/main/java/com/provismet/provihealth/mixin/EntityRenderStateMixin.java index 883a68c..1a2f08a 100644 --- a/src/main/java/com/provismet/provihealth/mixin/EntityRenderStateMixin.java +++ b/src/main/java/com/provismet/provihealth/mixin/EntityRenderStateMixin.java @@ -3,6 +3,7 @@ import com.provismet.provihealth.interfaces.IMixinEntityRenderState; import com.provismet.provihealth.util.HealthContainer; import net.minecraft.client.render.entity.state.EntityRenderState; +import net.minecraft.entity.Entity; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; @@ -36,6 +37,9 @@ public abstract class EntityRenderStateMixin implements IMixinEntityRenderState @Unique private Integer teamColour = null; + @Unique + private Entity entityType; + @Override public void provi_Health$setShouldRenderHealth (boolean value) { this.shouldRenderHealth = value; @@ -76,6 +80,11 @@ public abstract class EntityRenderStateMixin implements IMixinEntityRenderState this.teamColour = colour; } + @Override + public void provi_Health$setEntityType (Entity entity) { + this.entityType = entity; + } + @Override public boolean provi_Health$shouldRenderHealth () { return this.shouldRenderHealth; @@ -111,6 +120,11 @@ public abstract class EntityRenderStateMixin implements IMixinEntityRenderState return this.healthBarLabel; } + @Override + public Entity provi_Health$getEntityType () { + return this.entityType; + } + @Override @Nullable public Integer provi_Health$getTeamColour () { diff --git a/src/main/java/com/provismet/provihealth/mixin/EntityRendererMixin.java b/src/main/java/com/provismet/provihealth/mixin/EntityRendererMixin.java index 6f88563..de3745d 100644 --- a/src/main/java/com/provismet/provihealth/mixin/EntityRendererMixin.java +++ b/src/main/java/com/provismet/provihealth/mixin/EntityRendererMixin.java @@ -69,6 +69,7 @@ private void modifyRenderState (Entity entity, EntityRenderState state, float ti mixinState.provi_Health$setShouldRenderHealth(Options.shouldRenderHealthFor(living)); mixinState.provi_Health$setIsLiving(true); mixinState.provi_Health$setShouldRenderLabel(this.hasLabel(entity, state.squaredDistanceToCamera)); + mixinState.provi_Health$setEntityType(entity); if (entity.getDisplayName() != null) mixinState.provi_Health$setLabel(entity.getDisplayName()); else mixinState.provi_Health$setLabel(entity.getName()); diff --git a/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java b/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java index 8c8ea85..fda941a 100644 --- a/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java +++ b/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java @@ -48,6 +48,7 @@ protected LivingEntityMixin (EntityType type, World world) { public abstract float getMaxHealth(); @Shadow @Final private static TrackedData> POTION_SWIRLS; + @Shadow protected int lastAttackTimer; @Override public HealthContainer provi_Health$getHealthContainer () { @@ -74,6 +75,16 @@ protected LivingEntityMixin (EntityType type, World world) { .toList(); } + @Override + public boolean provi_Health$isAngryAtPlayer () { + return this.lastAttackTimer > 0; + } + + @Override + public int provi_Health$getAnger () { + return this.lastAttackTimer; + } + @Inject(method="tick", at=@At("TAIL")) private void spawnParticles (CallbackInfo info) { if (this.container == null) this.container = new HealthContainer(this.getHealth()); diff --git a/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java b/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java new file mode 100644 index 0000000..137e58b --- /dev/null +++ b/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java @@ -0,0 +1,5 @@ +package com.provismet.provihealth.util; + +public class FunctionalUtilities { + +} diff --git a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java index 187260d..a82f184 100644 --- a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java +++ b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java @@ -3,6 +3,8 @@ import com.mojang.blaze3d.opengl.GlStateManager; import com.mojang.blaze3d.vertex.VertexFormat; import com.provismet.provihealth.interfaces.IMixinEntityRenderState; +import com.provismet.provihealth.interfaces.IMixinLivingEntity; + import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.state.EntityRenderState; import net.minecraft.client.render.entity.state.LivingEntityRenderState; @@ -12,7 +14,12 @@ import org.joml.Quaternionf; import org.joml.Vector3f; -import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.mob.HostileEntity; +import net.minecraft.entity.passive.LlamaEntity; +import net.minecraft.entity.mob.Angerable; +import net.minecraft.entity.passive.TameableEntity; import com.provismet.provihealth.ProviHealthClient; import com.provismet.provihealth.config.Options; import com.provismet.provihealth.config.Options.SeeThroughText; @@ -186,6 +193,8 @@ private static void renderBar (IMixinEntityRenderState state, Matrix4f model, Ve final float Z = (float)index * -0.0001f; + Entity entity = state.provi_Health$getEntityType(); // Store to avoid constant calls in checks + if (Options.compatInWorld) { vertexConsumer.vertex(model, MAX_X, MAX_Y, Z).texture(MAX_U, MAX_V); // Bottom-Right vertexConsumer.vertex(model, MIN_X, MAX_Y, Z).texture(MIN_U, MAX_V); // Bottom-Left @@ -200,8 +209,47 @@ private static void renderBar (IMixinEntityRenderState state, Matrix4f model, Ve else if (Options.useTeamColours && state.provi_Health$getTeamColour() instanceof Integer teamColour) { colour = Vec3d.unpackRgb(teamColour).toVector3f(); } + + // ? Llamas are neutral in behaviour but do not extend Angerable, so they need their own checks + // ? If a neutral mob is angered, the bar changes colours to hostile colours. To remove this, remove the null checks for getAngryAt() + // ? Neutrality is checked first, because Endermen, Zombie Piglins, and other Angerable AND HostileEntity mobs should be checked here + // ? before hostility, as they are not hostile unless provoked. + // ? Tameable Angerable mobs only appear with neutral colours if they are untamed. Once tamed they are passive + // ? Also, all Neutral untameable mobs are always neutral. + + // ~ Neutral Aggression Level + else if (Options.useHudAggressionColours && ( + // * If the target is a *non-angered* LlamaEntity + (entity instanceof LlamaEntity && !((IMixinLivingEntity)entity).provi_Health$isAngryAtPlayer()) + // * If the target is a *non-angered* angerable mob, and is tameable but is not tamed + || (entity instanceof Angerable && !((Angerable)entity).hasAngerTime() + && entity instanceof TameableEntity && !((TameableEntity)entity).isTamed()) + // * If the target is a *non-angered* angerable mob, and is untameable + || (entity instanceof Angerable && !((Angerable)entity).hasAngerTime() + && !(entity instanceof TameableEntity))) + ) { + colour = Options.getBarColour(healthPercentage, Options.unpackedNeutralStartWorld, Options.unpackedEndWorld, isMount); + } + + // ~ Aggressive/Hostile Aggression Level + else if (Options.useWorldAggressionColours && + // * If the target is a Hostile Entity + entity instanceof HostileEntity + // * If the target is an *angered* LlamaEntity + || (entity instanceof LlamaEntity && ((IMixinLivingEntity)entity).provi_Health$isAngryAtPlayer()) + // * If the target is an *angered* angerable mob, and is tameable but is not tamed + || (entity instanceof Angerable && ((Angerable)entity).hasAngerTime() + && entity instanceof TameableEntity && !((TameableEntity)entity).isTamed()) + // * If the target is an *angered* angerable mob, and is untameable + || (entity instanceof Angerable && ((Angerable)entity).hasAngerTime() + && !(entity instanceof TameableEntity)) + ) { + colour = Options.getBarColour(healthPercentage, Options.unpackedHostileStartWorld, Options.unpackedEndWorld, isMount); + } + + // ~ Passive and Default Aggression Level (all passive mobs and modded mobs that do not extend vanilla classes), or all mobs if the aggression colour option is off else { - colour = Options.getBarColour(healthPercentage, Options.unpackedStartWorld, Options.unpackedEndWorld, Options.worldGradient); + colour = Options.getBarColour(healthPercentage, Options.unpackedDefaultStartWorld, Options.unpackedEndWorld, Options.worldGradient); } vertexConsumer.vertex(model, MIN_X, MIN_Y, Z).texture(MIN_U, MIN_V).color(colour.x, colour.y, colour.z, 1f); // Top-Left diff --git a/src/main/resources/assets/provihealth/lang/en_gb.json b/src/main/resources/assets/provihealth/lang/en_gb.json index 0f2926c..9270e7c 100644 --- a/src/main/resources/assets/provihealth/lang/en_gb.json +++ b/src/main/resources/assets/provihealth/lang/en_gb.json @@ -3,12 +3,16 @@ "entry.provihealth.healingColour": "Healing Particle Colour", "entry.provihealth.damageParticleTextColour": "Damage Text Colour", "entry.provihealth.healingParticleTextColour": "Healing Text Colour", - "entry.provihealth.barStartColour": "Full Health Colour", + "entry.provihealth.barDefaultStartColour": "Full Default/Passive Mob Health Colour", + "entry.provihealth.barNeutralStartColour": "Full Neutral Mob Health Colour", + "entry.provihealth.barHostileStartColour": "Full Hostile Mob Health Colour", "entry.provihealth.barEndColour": "Low Health Colour", "entry.provihealth.teamColours": "Use Team Colours", + "entry.provihealth.aggressionColours": "Use Entity Aggression Colours", "tooltip.provihealth.gradient": "Whether or not the health bar will change colour as it gets lower.\nTurning this off sets the bar colour to the starting value.", "tooltip.provihealth.compatWorld": "Uses a different rendering program for in-world health bars. Only turn this on if shaders are preventing the bars from rendering.\nWarning: This option disables any colour-related settings for in-world health bars.", "tooltip.provihealth.tintBackground": "Applies the bar colour to the background as well.", - "tooltip.provihealth.teamColours": "Matches health bar colour to the entity's team if applicable.\nTeam colours will override colours from other settings." + "tooltip.provihealth.teamColours": "Matches health bar colour to the entity's team if applicable.\nTeam colours will override colours from other settings.", + "tooltip.provihealth.aggressionColours": "Matches health bar colour to the entity aggression type/level.\nAngered and Hostile mobs will use the Hostile aggression colours.\nNon-angered and Untamed Neutral/Angerable mobs will use the Neutral aggression colours\nPassive mobs will use the default colour.\nIf turned off, all mobs use the default colour." } \ No newline at end of file diff --git a/src/main/resources/assets/provihealth/lang/en_us.json b/src/main/resources/assets/provihealth/lang/en_us.json index bb97685..1cff8c9 100644 --- a/src/main/resources/assets/provihealth/lang/en_us.json +++ b/src/main/resources/assets/provihealth/lang/en_us.json @@ -40,8 +40,10 @@ "entry.provihealth.maxParticleDistance": "Particle Render Distance", "entry.provihealth.hudOffsetX": "HUD Position", "entry.provihealth.gradient": "Dynamic Bar Color", - "entry.provihealth.barStartColour": "Full Health Colour", - "entry.provihealth.barEndColour": "Low Health Colour", + "entry.provihealth.barDefaultStartColour": "Full Default/Passive Mob Health Color", + "entry.provihealth.barNeutralStartColour": "Full Neutral Mob Health Color", + "entry.provihealth.barHostileStartColour": "Full Hostile Mob Health Color", + "entry.provihealth.barEndColour": "Low Health Color", "entry.provihealth.overrideLabels": "Replace Nameplates", "entry.provihealth.worldShadows": "Text Shadow", "entry.provihealth.compatText": "In-World Health Bar SeeThrough Text Mode", @@ -54,6 +56,7 @@ "entry.provihealth.hudStatuses": "Show Status Effects", "entry.provihealth.tintBackground": "Tint Background", "entry.provihealth.teamColours": "Use Team Colors", + "entry.provihealth.aggressionColours": "Use Entity Aggression Colors", "enum.provihealth.full": "Full", "enum.provihealth.portrait_only": "Portrait Only", @@ -92,6 +95,7 @@ "tooltip.provihealth.worldTitles": "Allows other mods to show text above the in-world health bars.", "tooltip.provihealth.tintBackground": "Applies the bar color to the background as well.", "tooltip.provihealth.teamColours": "Matches health bar color to the entity's team if applicable.\nTeam colors will override colors from other settings.", + "tooltip.provihealth.aggressionColours": "Matches health bar color to the entity aggression type/level.\nAngered and Hostile mobs will use the Hostile aggression colors.\nNon-angered and Untamed Neutral/Angerable mobs will use the Neutral aggression colors\nPassive mobs will use the default color.\nIf turned off, all mobs use the default color.", "entity.provihealth.unknownPlayer": "[Invisible Player]", From 982d9fdd85800732acd5b01dbca90c5305d7b7da Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Sun, 18 May 2025 22:50:39 +0300 Subject: [PATCH 03/11] Fix method calls after merge. + New functional utilities class (unused for now) --- .../java/com/provismet/provihealth/world/EntityHealthBar.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java index 69a2b16..ee5775f 100644 --- a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java +++ b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java @@ -223,7 +223,7 @@ else if (Options.useHudAggressionColours && ( || (entity instanceof Angerable && !((Angerable)entity).hasAngerTime() && !(entity instanceof TameableEntity))) ) { - colour = Options.getBarColour(healthPercentage, Options.unpackedNeutralStartWorld, Options.unpackedEndWorld, isMount); + colour = Options.lerpBarColour(healthPercentage, Options.unpackedNeutralStartWorld, Options.unpackedEndWorld, isMount); } // ~ Aggressive/Hostile Aggression Level @@ -239,7 +239,7 @@ else if (Options.useWorldAggressionColours && || (entity instanceof Angerable && ((Angerable)entity).hasAngerTime() && !(entity instanceof TameableEntity)) ) { - colour = Options.getBarColour(healthPercentage, Options.unpackedHostileStartWorld, Options.unpackedEndWorld, isMount); + colour = Options.lerpBarColour(healthPercentage, Options.unpackedHostileStartWorld, Options.unpackedEndWorld, isMount); } // ~ Passive and Default Aggression Level (all passive mobs and modded mobs that do not extend vanilla classes), or all mobs if the aggression colour option is off From 75f4821bb58df046b476366edfe49cc6626c03ad Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Fri, 30 May 2025 18:58:32 +0300 Subject: [PATCH 04/11] Removed inefficient Llama checking for now. FEAT: + Added instant kill messages + Added kill messages TODO: Add toggles --- .../provihealth/hud/TargetHealthBar.java | 7 ++-- .../interfaces/IMixinLivingEntity.java | 1 - .../provihealth/mixin/LivingEntityMixin.java | 33 +++++++++++++------ .../particle/TextParticleEffect.java | 3 +- .../provihealth/world/EntityHealthBar.java | 6 ++-- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java index b8dab54..dc6060f 100644 --- a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java +++ b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java @@ -319,7 +319,7 @@ private void renderBar (DrawContext drawContext, Identifier texture, int width, Vector3f startColour; LivingEntity entity = this.target; - System.out.println(((IMixinLivingEntity)this.target).provi_Health$getAnger()); + // System.out.println(((IMixinLivingEntity)this.target).provi_Health$getAnger()); if (barIndex == 1) startColour = Options.WHITE; // ? Llamas are neutral in behaviour but do not extend Angerable, so they need their own checks @@ -332,8 +332,7 @@ private void renderBar (DrawContext drawContext, Identifier texture, int width, else if (Options.useHudAggressionColours && ( // * If the target is a *non-angered* but angerable tameable mob and is not tamed (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).getAngryAt() == null) - // * If the target is a *non-angered* LlamaEntity - // || (entity instanceof LlamaEntity && !((IMixinLivingEntity)entity).provi_Health$isAngryAtPlayer()) + // * If the target is a LlamaEntity || (entity instanceof LlamaEntity) // * If the target is a *non-angered* but angerable untameable mob || (entity instanceof Angerable && !(entity instanceof TameableEntity) && ((Angerable)entity).getAngryAt() == null)) @@ -346,8 +345,6 @@ else if (Options.useHudAggressionColours && ( else if (Options.useWorldAggressionColours && // * If the target is a Hostile Entity entity instanceof HostileEntity - // * If the target is an *angered* LlamaEntity - // || (entity instanceof LlamaEntity && ((IMixinLivingEntity)entity).provi_Health$isAngryAtPlayer()) // * If the target is an *angered* Angerable entity || (entity instanceof Angerable && ((Angerable)entity).getAngryAt() != null) ) { diff --git a/src/main/java/com/provismet/provihealth/interfaces/IMixinLivingEntity.java b/src/main/java/com/provismet/provihealth/interfaces/IMixinLivingEntity.java index db50a62..d83753a 100644 --- a/src/main/java/com/provismet/provihealth/interfaces/IMixinLivingEntity.java +++ b/src/main/java/com/provismet/provihealth/interfaces/IMixinLivingEntity.java @@ -10,6 +10,5 @@ public interface IMixinLivingEntity { HealthContainer provi_Health$getHealthContainer (); HealthContainer provi_Health$getMountHealthContainer (); List> provi_Health$getClientSideStatusEffects (); - boolean provi_Health$isAngryAtPlayer (); int provi_Health$getAnger (); } diff --git a/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java b/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java index fda941a..626bb05 100644 --- a/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java +++ b/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java @@ -28,6 +28,7 @@ import java.util.Comparator; import java.util.List; import java.util.Objects; +import java.util.Random; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin extends Entity implements IMixinLivingEntity { @@ -41,6 +42,12 @@ protected LivingEntityMixin (EntityType type, World world) { @Unique private HealthContainer mountContainer; + @Unique + private String[] instantKillMessages = {"INSTA-KILL!", "INSTANT KILL!", "DECIMATED!", "VAPORISED!", "ONE-HIT KILL!", "FATALITY!"}; + + @Unique + private String[] deathMessages = {"Killed", "Boom", "Dead", "Eliminated", "Removed from Equation", "Finished"}; + @Shadow public abstract float getHealth(); @@ -48,7 +55,7 @@ protected LivingEntityMixin (EntityType type, World world) { public abstract float getMaxHealth(); @Shadow @Final private static TrackedData> POTION_SWIRLS; - @Shadow protected int lastAttackTimer; + // @Shadow protected int lastAttackTimer; @Override public HealthContainer provi_Health$getHealthContainer () { @@ -75,15 +82,15 @@ protected LivingEntityMixin (EntityType type, World world) { .toList(); } - @Override - public boolean provi_Health$isAngryAtPlayer () { - return this.lastAttackTimer > 0; - } + // @Override + // public boolean provi_Health$isAngryAtPlayer () { + // return this.lastAttackTimer > 0; + // } - @Override - public int provi_Health$getAnger () { - return this.lastAttackTimer; - } + // @Override + // public int provi_Health$getAnger () { + // return this.lastAttackTimer; + // } @Inject(method="tick", at=@At("TAIL")) private void spawnParticles (CallbackInfo info) { @@ -97,7 +104,13 @@ private void spawnParticles (CallbackInfo info) { final Entity cameraEntity = MinecraftClient.getInstance().getCameraEntity(); if (cameraEntity != null && this != cameraEntity && this.distanceTo(MinecraftClient.getInstance().getCameraEntity()) <= Options.maxParticleDistance) { - if (this.container.getCurrent() < this.container.getPrevious() && Options.spawnDamageParticles) { + if (this.container.getCurrent() <= 0 && this.container.getPrevious() == this.container.getMax() && Options.spawnDamageParticles) { + this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, instantKillMessages[new Random().nextInt(instantKillMessages.length)]), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); + } + else if (this.container.getCurrent() <= 0 && this.container.getCurrent() < this.container.getPrevious() && Options.spawnDamageParticles) { + this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, deathMessages[new Random().nextInt(deathMessages.length)]), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); + } + else if (this.container.getCurrent() < this.container.getPrevious() && Options.spawnDamageParticles) { this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, String.format("%d", (int)this.container.getPrevious() - (int)this.container.getCurrent())), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); } else if (this.container.getCurrent() > this.container.getPrevious() && Options.spawnHealingParticles) { diff --git a/src/main/java/com/provismet/provihealth/particle/TextParticleEffect.java b/src/main/java/com/provismet/provihealth/particle/TextParticleEffect.java index ede7255..6e883de 100644 --- a/src/main/java/com/provismet/provihealth/particle/TextParticleEffect.java +++ b/src/main/java/com/provismet/provihealth/particle/TextParticleEffect.java @@ -15,7 +15,8 @@ public record TextParticleEffect (float scale, int textColour, String text) implements ParticleEffect { private final static Codec TEXT_CODEC = Codec.string(1, 8).validate(text -> { try { - Integer.valueOf(text); + // Integer.valueOf(text); + // String.valueOf(text); return DataResult.success(text); } catch (Exception e) { return DataResult.error(() -> "Text must be an integer: " + text); diff --git a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java index ee5775f..dd9fc5c 100644 --- a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java +++ b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java @@ -214,8 +214,8 @@ else if (Options.useTeamColours && state.provi_Health$getTeamColour() instanceof // ~ Neutral Aggression Level else if (Options.useHudAggressionColours && ( - // * If the target is a *non-angered* LlamaEntity - (entity instanceof LlamaEntity && !((IMixinLivingEntity)entity).provi_Health$isAngryAtPlayer()) + // * If the target is a LlamaEntity + (entity instanceof LlamaEntity) // * If the target is a *non-angered* angerable mob, and is tameable but is not tamed || (entity instanceof Angerable && !((Angerable)entity).hasAngerTime() && entity instanceof TameableEntity && !((TameableEntity)entity).isTamed()) @@ -230,8 +230,6 @@ else if (Options.useHudAggressionColours && ( else if (Options.useWorldAggressionColours && // * If the target is a Hostile Entity entity instanceof HostileEntity - // * If the target is an *angered* LlamaEntity - || (entity instanceof LlamaEntity && ((IMixinLivingEntity)entity).provi_Health$isAngryAtPlayer()) // * If the target is an *angered* angerable mob, and is tameable but is not tamed || (entity instanceof Angerable && ((Angerable)entity).hasAngerTime() && entity instanceof TameableEntity && !((TameableEntity)entity).isTamed()) From 8aa5c644dda7ecfbdc3c93b5423e04a7aa1e56df Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:44:00 +0300 Subject: [PATCH 05/11] Added toggles for kill text --- .../compat/ProviHealthConfigScreen.java | 6 ++++++ .../com/provismet/provihealth/config/Options.java | 3 +++ .../provihealth/hud/TargetHealthBar.java | 15 ++++++++++++--- .../provihealth/mixin/LivingEntityMixin.java | 4 ++-- .../resources/assets/provihealth/lang/en_us.json | 1 + 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java b/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java index 4c8f4db..10dbbc8 100644 --- a/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java +++ b/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java @@ -356,6 +356,12 @@ public static Screen build (Screen parent) { .build() ); + particles.addEntry(entryBuilder.startBooleanToggle(Text.translatable("entry.provihealth.killText"), Options.spawnKillText) + .setDefaultValue(false) + .setSaveConsumer(newValue -> Options.spawnKillText = newValue) + .build() + ); + particles.addEntry(entryBuilder.startEnumSelector(Text.translatable("entry.provihealth.particleType"), DamageParticleType.class, Options.particleType) .setDefaultValue(DamageParticleType.RISING) .setSaveConsumer(newValue -> Options.particleType = newValue) diff --git a/src/main/java/com/provismet/provihealth/config/Options.java b/src/main/java/com/provismet/provihealth/config/Options.java index c79a1f6..cfc7422 100644 --- a/src/main/java/com/provismet/provihealth/config/Options.java +++ b/src/main/java/com/provismet/provihealth/config/Options.java @@ -91,6 +91,7 @@ public class Options { public static boolean spawnDamageParticles = true; public static boolean spawnHealingParticles = false; + public static boolean spawnKillText = true; public static int damageColour = 0xFF0000; public static int healingColour = 0x00FF00; public static Vector3f unpackedDamage = Vec3d.unpackRgb(damageColour).toVector3f(); @@ -203,6 +204,7 @@ public static void save () { .append("particles", new JsonBuilder() .append("damageParticles", spawnDamageParticles) .append("healingParticles", spawnHealingParticles) + .append("killText", spawnKillText) .append("damageColour", damageColour) .append("damageAlpha", damageAlpha) .append("healingColour", healingColour) @@ -298,6 +300,7 @@ public static void load () { }).ifPresent(json -> { json.getBoolean("damageParticles").ifPresent(val -> spawnDamageParticles = val); json.getBoolean("healingParticles").ifPresent(val -> spawnHealingParticles = val); + json.getBoolean("killText").ifPresent(val -> spawnKillText = val); json.getInteger("damageColour").ifPresent(val -> damageColour = val); json.getFloat("damageAlpha").ifPresent(val -> damageAlpha = val); json.getInteger("healingColour").ifPresent(val -> healingColour = val); diff --git a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java index dc6060f..bb10735 100644 --- a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java +++ b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java @@ -36,6 +36,9 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.Angerable; import net.minecraft.entity.mob.HostileEntity; +import net.minecraft.entity.mob.PiglinActivity; +import net.minecraft.entity.mob.PiglinEntity; +import net.minecraft.entity.mob.ZombifiedPiglinEntity; import net.minecraft.entity.passive.LlamaEntity; import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.player.PlayerEntity; @@ -331,12 +334,18 @@ private void renderBar (DrawContext drawContext, Identifier texture, int width, // ~ Neutral Aggression Level else if (Options.useHudAggressionColours && ( // * If the target is a *non-angered* but angerable tameable mob and is not tamed - (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).getAngryAt() == null) + (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && !((Angerable)entity).hasAngerTime()) // * If the target is a LlamaEntity || (entity instanceof LlamaEntity) // * If the target is a *non-angered* but angerable untameable mob - || (entity instanceof Angerable && !(entity instanceof TameableEntity) && ((Angerable)entity).getAngryAt() == null)) + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && ((Angerable)entity).getAngryAt() == null) && ((Angerable)entity).getTarget() == null) + // * If the target is a non-angered Piglin + || (entity instanceof PiglinEntity && ! + ((((PiglinEntity)entity).getActivity() == PiglinActivity.ATTACKING_WITH_MELEE_WEAPON) + || ((PiglinEntity)entity).getActivity() == PiglinActivity.CROSSBOW_CHARGE + || ((PiglinEntity)entity).getActivity() == PiglinActivity.CROSSBOW_HOLD)) )) { + if (entity instanceof ZombifiedPiglinEntity) System.out.println(((ZombifiedPiglinEntity)entity).getAngryAt()); startColour = Options.unpackedNeutralStartHud; } @@ -346,7 +355,7 @@ else if (Options.useWorldAggressionColours && // * If the target is a Hostile Entity entity instanceof HostileEntity // * If the target is an *angered* Angerable entity - || (entity instanceof Angerable && ((Angerable)entity).getAngryAt() != null) + || (entity instanceof Angerable && ((Angerable)entity).hasAngerTime()) ) { startColour = Options.unpackedHostileStartHud; } diff --git a/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java b/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java index 626bb05..a2bc078 100644 --- a/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java +++ b/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java @@ -104,10 +104,10 @@ private void spawnParticles (CallbackInfo info) { final Entity cameraEntity = MinecraftClient.getInstance().getCameraEntity(); if (cameraEntity != null && this != cameraEntity && this.distanceTo(MinecraftClient.getInstance().getCameraEntity()) <= Options.maxParticleDistance) { - if (this.container.getCurrent() <= 0 && this.container.getPrevious() == this.container.getMax() && Options.spawnDamageParticles) { + if (this.container.getCurrent() <= 0 && this.container.getPrevious() == this.container.getMax() && Options.spawnDamageParticles && Options.spawnKillText) { this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, instantKillMessages[new Random().nextInt(instantKillMessages.length)]), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); } - else if (this.container.getCurrent() <= 0 && this.container.getCurrent() < this.container.getPrevious() && Options.spawnDamageParticles) { + else if (this.container.getCurrent() <= 0 && this.container.getCurrent() < this.container.getPrevious() && Options.spawnDamageParticles && Options.spawnKillText) { this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, deathMessages[new Random().nextInt(deathMessages.length)]), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); } else if (this.container.getCurrent() < this.container.getPrevious() && Options.spawnDamageParticles) { diff --git a/src/main/resources/assets/provihealth/lang/en_us.json b/src/main/resources/assets/provihealth/lang/en_us.json index 1cff8c9..73e5d7b 100644 --- a/src/main/resources/assets/provihealth/lang/en_us.json +++ b/src/main/resources/assets/provihealth/lang/en_us.json @@ -30,6 +30,7 @@ "entry.provihealth.hudTitles": "Show Titles On HUD", "entry.provihealth.damageParticles": "Show Damage Particles", "entry.provihealth.healingParticles": "Show Healing Particles", + "entry.provihealth.killText": "Spawn Kill/Insta-kill text", "entry.provihealth.damageColour": "Damage Particle Color", "entry.provihealth.healingColour": "Healing Particle Color", "entry.provihealth.particleScale": "Particle Size", From 33be7c1267cf44101dcdbca438004af9cdd876ee Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:37:55 +0300 Subject: [PATCH 06/11] Piglin Logic fixed, enderman logic fixed. --- .../compat/ProviHealthConfigScreen.java | 2 +- .../provihealth/hud/TargetHealthBar.java | 58 ++++++++++++++----- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java b/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java index 10dbbc8..19530a6 100644 --- a/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java +++ b/src/main/java/com/provismet/provihealth/compat/ProviHealthConfigScreen.java @@ -357,7 +357,7 @@ public static Screen build (Screen parent) { ); particles.addEntry(entryBuilder.startBooleanToggle(Text.translatable("entry.provihealth.killText"), Options.spawnKillText) - .setDefaultValue(false) + .setDefaultValue(true) .setSaveConsumer(newValue -> Options.spawnKillText = newValue) .build() ); diff --git a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java index bb10735..f33f216 100644 --- a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java +++ b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java @@ -17,6 +17,9 @@ import net.minecraft.entity.effect.StatusEffect; import net.minecraft.item.ItemStack; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.command.CommandManager; +import net.minecraft.server.command.ServerCommandSource; import net.minecraft.util.math.Vec3d; import org.joml.Matrix4f; import org.joml.Quaternionf; @@ -34,11 +37,20 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.entity.EntityPose; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.ai.brain.MemoryModuleState; +import net.minecraft.entity.ai.brain.MemoryModuleType; +import net.minecraft.entity.data.TrackedData; +import net.minecraft.entity.data.TrackedDataHandler; +import net.minecraft.entity.mob.AbstractPiglinEntity; import net.minecraft.entity.mob.Angerable; +import net.minecraft.entity.mob.EndermanEntity; import net.minecraft.entity.mob.HostileEntity; +import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.PiglinActivity; import net.minecraft.entity.mob.PiglinEntity; +import net.minecraft.entity.mob.ZombieVillagerEntity; import net.minecraft.entity.mob.ZombifiedPiglinEntity; +import net.minecraft.entity.passive.AbstractHorseEntity; import net.minecraft.entity.passive.LlamaEntity; import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.player.PlayerEntity; @@ -324,6 +336,11 @@ private void renderBar (DrawContext drawContext, Identifier texture, int width, // System.out.println(((IMixinLivingEntity)this.target).provi_Health$getAnger()); + // CommandManager commandManager = Objects.requireNonNull(player.getServer()).getCommandManager(); + // ServerCommandSource commandSource = player.getServer().getCommandSource(); + // commandManager.executeWithPrefix(commandSource, command); + + if (barIndex == 1) startColour = Options.WHITE; // ? Llamas are neutral in behaviour but do not extend Angerable, so they need their own checks // ? If a neutral mob is angered, the bar changes colours to hostile colours. To remove this, remove the null checks for getAngryAt() @@ -334,28 +351,41 @@ private void renderBar (DrawContext drawContext, Identifier texture, int width, // ~ Neutral Aggression Level else if (Options.useHudAggressionColours && ( // * If the target is a *non-angered* but angerable tameable mob and is not tamed - (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && !((Angerable)entity).hasAngerTime()) - // * If the target is a LlamaEntity - || (entity instanceof LlamaEntity) - // * If the target is a *non-angered* but angerable untameable mob - || (entity instanceof Angerable && !(entity instanceof TameableEntity) && ((Angerable)entity).getAngryAt() == null) && ((Angerable)entity).getTarget() == null) - // * If the target is a non-angered Piglin - || (entity instanceof PiglinEntity && ! - ((((PiglinEntity)entity).getActivity() == PiglinActivity.ATTACKING_WITH_MELEE_WEAPON) - || ((PiglinEntity)entity).getActivity() == PiglinActivity.CROSSBOW_CHARGE - || ((PiglinEntity)entity).getActivity() == PiglinActivity.CROSSBOW_HOLD)) + (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && !((Angerable)entity).hasAngerTime())) + // * If the target is a *non-angered* LlamaEntity + || (entity instanceof LlamaEntity && !((AbstractHorseEntity)entity).isAngry()) + // * If the target is a *non-angered* Enderman + || (entity instanceof EndermanEntity && !((EndermanEntity)entity).isAngry()) + // * If the target is a *non-angered* but angerable untameable mob (not an Enderman) + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && !(entity instanceof EndermanEntity) && !((Angerable)entity).hasAngerTime() && !((MobEntity)entity).isAttacking()) + // * If the target is a *non-angered* PiglinEntity (these entities are not Angerable, only HostileEntities) + || (entity instanceof PiglinEntity && !((MobEntity)entity).isAttacking()) + // * If the target is an unangered Zombie Piglin + // || (entity instanceof ZombifiedPiglinEntity && ((MobEntity)entity).isAttacking()) )) { - if (entity instanceof ZombifiedPiglinEntity) System.out.println(((ZombifiedPiglinEntity)entity).getAngryAt()); + if (entity instanceof ZombifiedPiglinEntity) System.out.println(entity.getDataTracker().getChangedEntries().toString()); startColour = Options.unpackedNeutralStartHud; } + + // [SerializedEntry[id=9, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@b3bb18a, value=15.0], SerializedEntry[id=15, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@4c57b0e7, value=4]] + + // [SerializedEntry[id=8, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@4c57b0e7, value=1], SerializedEntry[id=9, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@b3bb18a, value=15.0], SerializedEntry[id=15, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@4c57b0e7, value=4], SerializedEntry[id=18, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@7852d8ed, value=true]] // ~ Aggressive/Hostile Aggression Level else if (Options.useWorldAggressionColours && // * If the target is a Hostile Entity - entity instanceof HostileEntity - // * If the target is an *angered* Angerable entity - || (entity instanceof Angerable && ((Angerable)entity).hasAngerTime()) + (entity instanceof HostileEntity) + // * If the target is an angered angerable tameable mob and is not tamed + || (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).hasAngerTime())) + // * If the target is an angered LlamaEntity + || (entity instanceof LlamaEntity && ((AbstractHorseEntity)entity).isAngry()) + // * If the target is an angered Enderman + || (entity instanceof EndermanEntity && ((EndermanEntity)entity).isAngry()) + // * If the target is an angered angerable untameable mob + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && (((Angerable)entity).hasAngerTime() || ((MobEntity)entity).isAttacking())) + // * If the target is an angered PiglinEntity (these entities are not Angerable, only HostileEntities) + || (entity instanceof PiglinEntity && ((MobEntity)entity).isAttacking()) ) { startColour = Options.unpackedHostileStartHud; } From 4b9b877e7df87af464a8b58ac90425445a0efa7d Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Thu, 5 Jun 2025 12:46:44 +0300 Subject: [PATCH 07/11] Fixed logic for many mobs --- .../provihealth/hud/TargetHealthBar.java | 45 +++++----------- .../provihealth/mixin/LivingEntityMixin.java | 2 +- .../provihealth/world/EntityHealthBar.java | 52 +++++++++---------- 3 files changed, 38 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java index f33f216..150d930 100644 --- a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java +++ b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java @@ -37,20 +37,12 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.entity.EntityPose; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.brain.MemoryModuleState; -import net.minecraft.entity.ai.brain.MemoryModuleType; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.data.TrackedDataHandler; -import net.minecraft.entity.mob.AbstractPiglinEntity; import net.minecraft.entity.mob.Angerable; import net.minecraft.entity.mob.EndermanEntity; +import net.minecraft.entity.mob.HoglinEntity; import net.minecraft.entity.mob.HostileEntity; import net.minecraft.entity.mob.MobEntity; -import net.minecraft.entity.mob.PiglinActivity; import net.minecraft.entity.mob.PiglinEntity; -import net.minecraft.entity.mob.ZombieVillagerEntity; -import net.minecraft.entity.mob.ZombifiedPiglinEntity; -import net.minecraft.entity.passive.AbstractHorseEntity; import net.minecraft.entity.passive.LlamaEntity; import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.player.PlayerEntity; @@ -352,41 +344,30 @@ private void renderBar (DrawContext drawContext, Identifier texture, int width, else if (Options.useHudAggressionColours && ( // * If the target is a *non-angered* but angerable tameable mob and is not tamed (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && !((Angerable)entity).hasAngerTime())) - // * If the target is a *non-angered* LlamaEntity - || (entity instanceof LlamaEntity && !((AbstractHorseEntity)entity).isAngry()) - // * If the target is a *non-angered* Enderman + // * If the target is a LlamaEntity + || (entity instanceof LlamaEntity) + // * If the target is a *non-angered* Enderman - Endermen have their own Anger TrackedData || (entity instanceof EndermanEntity && !((EndermanEntity)entity).isAngry()) - // * If the target is a *non-angered* but angerable untameable mob (not an Enderman) - || (entity instanceof Angerable && !(entity instanceof TameableEntity) && !(entity instanceof EndermanEntity) && !((Angerable)entity).hasAngerTime() && !((MobEntity)entity).isAttacking()) // * If the target is a *non-angered* PiglinEntity (these entities are not Angerable, only HostileEntities) || (entity instanceof PiglinEntity && !((MobEntity)entity).isAttacking()) - // * If the target is an unangered Zombie Piglin - // || (entity instanceof ZombifiedPiglinEntity && ((MobEntity)entity).isAttacking()) + // * If the target is a generic *non-angered* but angerable untameable mob (not an Enderman) + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && !(entity instanceof EndermanEntity) && !((Angerable)entity).hasAngerTime() && !((MobEntity)entity).isAttacking()) )) { - if (entity instanceof ZombifiedPiglinEntity) System.out.println(entity.getDataTracker().getChangedEntries().toString()); startColour = Options.unpackedNeutralStartHud; } - // [SerializedEntry[id=9, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@b3bb18a, value=15.0], SerializedEntry[id=15, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@4c57b0e7, value=4]] - - // [SerializedEntry[id=8, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@4c57b0e7, value=1], SerializedEntry[id=9, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@b3bb18a, value=15.0], SerializedEntry[id=15, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@4c57b0e7, value=4], SerializedEntry[id=18, serializer=net.minecraft.entity.data.TrackedDataHandler$$Lambda/0x00000172e092a0b8@7852d8ed, value=true]] - - // ~ Aggressive/Hostile Aggression Level - else if (Options.useWorldAggressionColours && - // * If the target is a Hostile Entity - (entity instanceof HostileEntity) - // * If the target is an angered angerable tameable mob and is not tamed + else if (Options.useWorldAggressionColours && ( + // * If the target is a Hostile Entity, or a Hoglin (which are passive in the code) + (entity instanceof HostileEntity || entity instanceof HoglinEntity) + // * If the target is an angered tameable mob and is not tamed || (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).hasAngerTime())) - // * If the target is an angered LlamaEntity - || (entity instanceof LlamaEntity && ((AbstractHorseEntity)entity).isAngry()) // * If the target is an angered Enderman || (entity instanceof EndermanEntity && ((EndermanEntity)entity).isAngry()) - // * If the target is an angered angerable untameable mob + // * If the target is a generic angered untameable mob || (entity instanceof Angerable && !(entity instanceof TameableEntity) && (((Angerable)entity).hasAngerTime() || ((MobEntity)entity).isAttacking())) - // * If the target is an angered PiglinEntity (these entities are not Angerable, only HostileEntities) - || (entity instanceof PiglinEntity && ((MobEntity)entity).isAttacking()) - ) { + + )) { startColour = Options.unpackedHostileStartHud; } diff --git a/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java b/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java index a2bc078..ff84336 100644 --- a/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java +++ b/src/main/java/com/provismet/provihealth/mixin/LivingEntityMixin.java @@ -108,7 +108,7 @@ private void spawnParticles (CallbackInfo info) { this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, instantKillMessages[new Random().nextInt(instantKillMessages.length)]), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); } else if (this.container.getCurrent() <= 0 && this.container.getCurrent() < this.container.getPrevious() && Options.spawnDamageParticles && Options.spawnKillText) { - this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, deathMessages[new Random().nextInt(deathMessages.length)]), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); + this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale * 1.5f, Options.damageParticleTextColour, deathMessages[new Random().nextInt(deathMessages.length)]), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); } else if (this.container.getCurrent() < this.container.getPrevious() && Options.spawnDamageParticles) { this.getWorld().addParticleClient(new HealthParticleEffect(Options.unpackedDamage, Options.damageAlpha, Options.particleScale, Options.damageParticleTextColour, String.format("%d", (int)this.container.getPrevious() - (int)this.container.getCurrent())), this.getX(), this.getEyeY(), this.getZ(), 0f, 0f, 0f); diff --git a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java index dd9fc5c..1a415fd 100644 --- a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java +++ b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java @@ -15,33 +15,27 @@ import org.joml.Vector3f; import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.HostileEntity; +import net.minecraft.entity.mob.MobEntity; +import net.minecraft.entity.mob.PiglinEntity; import net.minecraft.entity.passive.LlamaEntity; import net.minecraft.entity.mob.Angerable; +import net.minecraft.entity.mob.EndermanEntity; +import net.minecraft.entity.mob.HoglinEntity; import net.minecraft.entity.passive.TameableEntity; import com.provismet.provihealth.ProviHealthClient; import com.provismet.provihealth.config.Options; import com.provismet.provihealth.config.Options.SeeThroughText; -import com.provismet.provihealth.interfaces.IMixinEntityRenderState; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer.TextLayerType; import net.minecraft.client.render.LightmapTextureManager; -import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.state.EntityRenderState; -import net.minecraft.client.render.entity.state.LivingEntityRenderState; -import net.minecraft.client.render.entity.state.PlayerEntityRenderState; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import org.joml.Matrix4f; -import org.joml.Quaternionf; -import org.joml.Vector3f; import java.util.List; @@ -214,29 +208,31 @@ else if (Options.useTeamColours && state.provi_Health$getTeamColour() instanceof // ~ Neutral Aggression Level else if (Options.useHudAggressionColours && ( + // * If the target is a *non-angered* but angerable tameable mob and is not tamed + (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && !((Angerable)entity).hasAngerTime())) // * If the target is a LlamaEntity - (entity instanceof LlamaEntity) - // * If the target is a *non-angered* angerable mob, and is tameable but is not tamed - || (entity instanceof Angerable && !((Angerable)entity).hasAngerTime() - && entity instanceof TameableEntity && !((TameableEntity)entity).isTamed()) - // * If the target is a *non-angered* angerable mob, and is untameable - || (entity instanceof Angerable && !((Angerable)entity).hasAngerTime() - && !(entity instanceof TameableEntity))) - ) { + || (entity instanceof LlamaEntity) + // * If the target is a *non-angered* Enderman - Endermen have their own Anger TrackedData + || (entity instanceof EndermanEntity && !((EndermanEntity)entity).isAngry()) + // * If the target is a *non-angered* PiglinEntity (these entities are not Angerable, only HostileEntities) + || (entity instanceof PiglinEntity && !((MobEntity)entity).isAttacking()) + // * If the target is a generic *non-angered* but angerable untameable mob (not an Enderman) + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && !(entity instanceof EndermanEntity) && !((Angerable)entity).hasAngerTime() && !((MobEntity)entity).isAttacking()) + )) { colour = Options.lerpBarColour(healthPercentage, Options.unpackedNeutralStartWorld, Options.unpackedEndWorld, isMount); } // ~ Aggressive/Hostile Aggression Level - else if (Options.useWorldAggressionColours && - // * If the target is a Hostile Entity - entity instanceof HostileEntity - // * If the target is an *angered* angerable mob, and is tameable but is not tamed - || (entity instanceof Angerable && ((Angerable)entity).hasAngerTime() - && entity instanceof TameableEntity && !((TameableEntity)entity).isTamed()) - // * If the target is an *angered* angerable mob, and is untameable - || (entity instanceof Angerable && ((Angerable)entity).hasAngerTime() - && !(entity instanceof TameableEntity)) - ) { + else if (Options.useWorldAggressionColours && ( + // * If the target is a Hostile Entity or a Hoglin (which are passive in terms of Class) + (entity instanceof HostileEntity || entity instanceof HoglinEntity) + // * If the target is an angered tameable mob and is not tamed + || (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).hasAngerTime())) + // * If the target is an angered Enderman + || (entity instanceof EndermanEntity && ((EndermanEntity)entity).isAngry()) + // * If the target is a generic angered untameable mob + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && (((Angerable)entity).hasAngerTime() || ((MobEntity)entity).isAttacking())) + )) { colour = Options.lerpBarColour(healthPercentage, Options.unpackedHostileStartWorld, Options.unpackedEndWorld, isMount); } From fe6c431b80329ec37f68fd963ad1685a59294273 Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Thu, 5 Jun 2025 13:11:25 +0300 Subject: [PATCH 08/11] Moved all colour checking code to the FunctionalUtilities class --- .../provihealth/hud/TargetHealthBar.java | 40 +------------ .../provihealth/util/FunctionalUtilities.java | 57 ++++++++++++++++++- .../provihealth/world/EntityHealthBar.java | 45 +-------------- 3 files changed, 61 insertions(+), 81 deletions(-) diff --git a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java index 150d930..d403c4f 100644 --- a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java +++ b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java @@ -2,6 +2,7 @@ import com.provismet.provihealth.config.resources.EntityOptions; import com.provismet.provihealth.interfaces.IMixinLivingEntity; +import com.provismet.provihealth.util.FunctionalUtilities; import com.provismet.provihealth.util.HealthCalculator; import com.provismet.provihealth.util.HealthContainer; import net.fabricmc.fabric.api.client.rendering.v1.HudLayerRegistrationCallback; @@ -334,45 +335,8 @@ private void renderBar (DrawContext drawContext, Identifier texture, int width, if (barIndex == 1) startColour = Options.WHITE; - // ? Llamas are neutral in behaviour but do not extend Angerable, so they need their own checks - // ? If a neutral mob is angered, the bar changes colours to hostile colours. To remove this, remove the null checks for getAngryAt() - // ? Neutrality is checked first, because Endermen, Zombie Piglins, and other Angerable AND HostileEntity mobs should be checked here - // ? before hostility, as they are not hostile unless provoked. - // ? Tameable Angerable mobs only appear with neutral colours if they are untamed. Once tamed they are passive - - // ~ Neutral Aggression Level - else if (Options.useHudAggressionColours && ( - // * If the target is a *non-angered* but angerable tameable mob and is not tamed - (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && !((Angerable)entity).hasAngerTime())) - // * If the target is a LlamaEntity - || (entity instanceof LlamaEntity) - // * If the target is a *non-angered* Enderman - Endermen have their own Anger TrackedData - || (entity instanceof EndermanEntity && !((EndermanEntity)entity).isAngry()) - // * If the target is a *non-angered* PiglinEntity (these entities are not Angerable, only HostileEntities) - || (entity instanceof PiglinEntity && !((MobEntity)entity).isAttacking()) - // * If the target is a generic *non-angered* but angerable untameable mob (not an Enderman) - || (entity instanceof Angerable && !(entity instanceof TameableEntity) && !(entity instanceof EndermanEntity) && !((Angerable)entity).hasAngerTime() && !((MobEntity)entity).isAttacking()) - )) { - startColour = Options.unpackedNeutralStartHud; - } - - // ~ Aggressive/Hostile Aggression Level - else if (Options.useWorldAggressionColours && ( - // * If the target is a Hostile Entity, or a Hoglin (which are passive in the code) - (entity instanceof HostileEntity || entity instanceof HoglinEntity) - // * If the target is an angered tameable mob and is not tamed - || (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).hasAngerTime())) - // * If the target is an angered Enderman - || (entity instanceof EndermanEntity && ((EndermanEntity)entity).isAngry()) - // * If the target is a generic angered untameable mob - || (entity instanceof Angerable && !(entity instanceof TameableEntity) && (((Angerable)entity).hasAngerTime() || ((MobEntity)entity).isAttacking())) - - )) { - startColour = Options.unpackedHostileStartHud; - } - // ~ Passive and Default Aggression Level (all passive mobs and modded mobs that do not extend vanilla classes) - else startColour = Options.unpackedDefaultStartHud; + else startColour = FunctionalUtilities.deduceColour(entity); Vector3f barColour = Options.lerpBarColour((float)width / (float)BAR_WIDTH, startColour, Options.unpackedEndHud, barIndex == 0 && Options.hudGradient); if (Options.hudPosition == HUDPosition.LEFT) this.drawTexturedQuad(texture, drawContext, BAR_X, BAR_X + width, BAR_Y, BAR_Y + BAR_HEIGHT, 0, 0f, (float)width / (float)BAR_WIDTH, barIndex / 2f, BAR_V2 + barIndex / 2f, barColour); diff --git a/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java b/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java index 137e58b..1d778d7 100644 --- a/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java +++ b/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java @@ -1,5 +1,60 @@ package com.provismet.provihealth.util; +import org.joml.Vector3f; + +import com.provismet.provihealth.config.Options; + +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.mob.Angerable; +import net.minecraft.entity.mob.EndermanEntity; +import net.minecraft.entity.mob.HoglinEntity; +import net.minecraft.entity.mob.HostileEntity; +import net.minecraft.entity.mob.MobEntity; +import net.minecraft.entity.mob.PiglinEntity; +import net.minecraft.entity.passive.LlamaEntity; +import net.minecraft.entity.passive.TameableEntity; + public class FunctionalUtilities { - + public static Vector3f deduceColour (LivingEntity entity) { + + // ? Llamas are neutral in behaviour but do not extend Angerable, so they need their own checks + // ? If a neutral mob is angered, the bar changes colours to hostile colours. + // ? Neutrality is checked first, because Endermen, Zombie Piglins, and other Angerable AND HostileEntity mobs should be checked here + // ? before hostility, as they are not hostile unless provoked. + // ? Tameable Angerable mobs only appear with neutral colours if they are untamed. Once tamed they are passive + + // ~ Neutral Aggression Level + if (Options.useHudAggressionColours && ( + // * If the target is a *non-angered* but angerable tameable mob and is not tamed + (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && !((Angerable)entity).hasAngerTime())) + // * If the target is a LlamaEntity + || (entity instanceof LlamaEntity) + // * If the target is a *non-angered* Enderman - Endermen have their own Anger TrackedData + || (entity instanceof EndermanEntity && !((EndermanEntity)entity).isAngry()) + // * If the target is a *non-angered* PiglinEntity (these entities are not Angerable, only HostileEntities) + || (entity instanceof PiglinEntity && !((MobEntity)entity).isAttacking()) + // * If the target is a generic *non-angered* but angerable untameable mob (not an Enderman) + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && !(entity instanceof EndermanEntity) && !((Angerable)entity).hasAngerTime() && !((MobEntity)entity).isAttacking()) + )) { + return Options.unpackedNeutralStartHud; + } + + // ~ Aggressive/Hostile Aggression Level + else if (Options.useWorldAggressionColours && ( + // * If the target is a Hostile Entity, or a Hoglin (which are passive in the code) + (entity instanceof HostileEntity || entity instanceof HoglinEntity) + // * If the target is an angered tameable mob and is not tamed + || (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).hasAngerTime())) + // * If the target is an angered Enderman + || (entity instanceof EndermanEntity && ((EndermanEntity)entity).isAngry()) + // * If the target is a generic angered untameable mob + || (entity instanceof Angerable && !(entity instanceof TameableEntity) && (((Angerable)entity).hasAngerTime() || ((MobEntity)entity).isAttacking())) + + )) { + return Options.unpackedHostileStartHud; + } + + // ~ Passive and Default Aggression Level (all passive mobs and modded mobs that do not extend vanilla classes) + return Options.unpackedDefaultStartHud; + } } diff --git a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java index 1a415fd..70ba7cb 100644 --- a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java +++ b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.VertexFormat; import com.provismet.provihealth.interfaces.IMixinEntityRenderState; import com.provismet.provihealth.interfaces.IMixinLivingEntity; +import com.provismet.provihealth.util.FunctionalUtilities; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.state.EntityRenderState; @@ -15,6 +16,7 @@ import org.joml.Vector3f; import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.HostileEntity; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.PiglinEntity; @@ -199,48 +201,7 @@ else if (Options.useTeamColours && state.provi_Health$getTeamColour() instanceof colour = Vec3d.unpackRgb(teamColour).toVector3f(); } - // ? Llamas are neutral in behaviour but do not extend Angerable, so they need their own checks - // ? If a neutral mob is angered, the bar changes colours to hostile colours. To remove this, remove the null checks for getAngryAt() - // ? Neutrality is checked first, because Endermen, Zombie Piglins, and other Angerable AND HostileEntity mobs should be checked here - // ? before hostility, as they are not hostile unless provoked. - // ? Tameable Angerable mobs only appear with neutral colours if they are untamed. Once tamed they are passive - // ? Also, all Neutral untameable mobs are always neutral. - - // ~ Neutral Aggression Level - else if (Options.useHudAggressionColours && ( - // * If the target is a *non-angered* but angerable tameable mob and is not tamed - (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && !((Angerable)entity).hasAngerTime())) - // * If the target is a LlamaEntity - || (entity instanceof LlamaEntity) - // * If the target is a *non-angered* Enderman - Endermen have their own Anger TrackedData - || (entity instanceof EndermanEntity && !((EndermanEntity)entity).isAngry()) - // * If the target is a *non-angered* PiglinEntity (these entities are not Angerable, only HostileEntities) - || (entity instanceof PiglinEntity && !((MobEntity)entity).isAttacking()) - // * If the target is a generic *non-angered* but angerable untameable mob (not an Enderman) - || (entity instanceof Angerable && !(entity instanceof TameableEntity) && !(entity instanceof EndermanEntity) && !((Angerable)entity).hasAngerTime() && !((MobEntity)entity).isAttacking()) - )) { - colour = Options.lerpBarColour(healthPercentage, Options.unpackedNeutralStartWorld, Options.unpackedEndWorld, isMount); - } - - // ~ Aggressive/Hostile Aggression Level - else if (Options.useWorldAggressionColours && ( - // * If the target is a Hostile Entity or a Hoglin (which are passive in terms of Class) - (entity instanceof HostileEntity || entity instanceof HoglinEntity) - // * If the target is an angered tameable mob and is not tamed - || (entity instanceof Angerable && entity instanceof TameableEntity && !(((TameableEntity)(entity)).isTamed() && ((Angerable)entity).hasAngerTime())) - // * If the target is an angered Enderman - || (entity instanceof EndermanEntity && ((EndermanEntity)entity).isAngry()) - // * If the target is a generic angered untameable mob - || (entity instanceof Angerable && !(entity instanceof TameableEntity) && (((Angerable)entity).hasAngerTime() || ((MobEntity)entity).isAttacking())) - )) { - colour = Options.lerpBarColour(healthPercentage, Options.unpackedHostileStartWorld, Options.unpackedEndWorld, isMount); - } - - // ~ Passive and Default Aggression Level (all passive mobs and modded mobs that do not extend vanilla classes), or all mobs if the aggression colour option is off - else { - colour = Options.lerpBarColour(healthPercentage, Options.unpackedDefaultStartWorld, Options.unpackedEndWorld, Options.worldGradient); - - } + else colour = Options.lerpBarColour(healthPercentage, FunctionalUtilities.deduceColour((LivingEntity)entity), Options.unpackedEndWorld, isMount); int maxLight = 0xF000F0; vertexConsumer.vertex(model, MIN_X, MIN_Y, Z).texture(MIN_U, MIN_V).light(maxLight).color(colour.x, colour.y, colour.z, 1f); // Top-Left From e06a81b6a2e1484a48b7578f6454cae84c8279e6 Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Thu, 5 Jun 2025 13:13:53 +0300 Subject: [PATCH 09/11] Added checks to return the appropriate HUD or World colour --- .../provihealth/util/FunctionalUtilities.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java b/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java index 1d778d7..b4e2d40 100644 --- a/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java +++ b/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java @@ -15,7 +15,7 @@ import net.minecraft.entity.passive.TameableEntity; public class FunctionalUtilities { - public static Vector3f deduceColour (LivingEntity entity) { + public static Vector3f deduceColour (LivingEntity entity, boolean inHud) { // ? Llamas are neutral in behaviour but do not extend Angerable, so they need their own checks // ? If a neutral mob is angered, the bar changes colours to hostile colours. @@ -36,7 +36,8 @@ public static Vector3f deduceColour (LivingEntity entity) { // * If the target is a generic *non-angered* but angerable untameable mob (not an Enderman) || (entity instanceof Angerable && !(entity instanceof TameableEntity) && !(entity instanceof EndermanEntity) && !((Angerable)entity).hasAngerTime() && !((MobEntity)entity).isAttacking()) )) { - return Options.unpackedNeutralStartHud; + if (inHud) return Options.unpackedNeutralStartHud; + else return Options.unpackedNeutralStartWorld; } // ~ Aggressive/Hostile Aggression Level @@ -51,10 +52,12 @@ else if (Options.useWorldAggressionColours && ( || (entity instanceof Angerable && !(entity instanceof TameableEntity) && (((Angerable)entity).hasAngerTime() || ((MobEntity)entity).isAttacking())) )) { - return Options.unpackedHostileStartHud; + if (inHud) return Options.unpackedHostileStartHud; + else return Options.unpackedHostileStartWorld; } // ~ Passive and Default Aggression Level (all passive mobs and modded mobs that do not extend vanilla classes) - return Options.unpackedDefaultStartHud; + if (inHud) return Options.unpackedDefaultStartHud; + else return Options.unpackedDefaultStartWorld; } } From 1c8d7cbf6cb9119cff0c0681a7ebe3fef230f8fb Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Thu, 5 Jun 2025 13:51:20 +0300 Subject: [PATCH 10/11] Fix Merge issues, up to date with upstream Origin --- .../assets/provihealth/lang/en_gb.json | 15 +- .../assets/provihealth/lang/en_us.json | 147 ++++++++++-------- .../provihealth/hud/TargetHealthBar.java | 2 +- .../provihealth/world/EntityHealthBar.java | 29 +--- .../assets/provihealth/lang/en_gb.json | 18 --- .../assets/provihealth/lang/en_us.json | 107 ------------- 6 files changed, 101 insertions(+), 217 deletions(-) delete mode 100644 src/main/resources/assets/provihealth/lang/en_gb.json delete mode 100644 src/main/resources/assets/provihealth/lang/en_us.json diff --git a/src/main/generated/assets/provihealth/lang/en_gb.json b/src/main/generated/assets/provihealth/lang/en_gb.json index c28ee03..ace440c 100644 --- a/src/main/generated/assets/provihealth/lang/en_gb.json +++ b/src/main/generated/assets/provihealth/lang/en_gb.json @@ -1,13 +1,18 @@ { - "entry.provihealth.barEndColour": "Low Health Colour", - "entry.provihealth.barStartColour": "Full Health Colour", "entry.provihealth.damageColour": "Damage Particle Colour", - "entry.provihealth.damageParticleTextColour": "Damage Text Colour", "entry.provihealth.healingColour": "Healing Particle Colour", + "entry.provihealth.damageParticleTextColour": "Damage Text Colour", "entry.provihealth.healingParticleTextColour": "Healing Text Colour", + "entry.provihealth.barDefaultStartColour": "Full Default/Passive Mob Health Colour", + "entry.provihealth.barNeutralStartColour": "Full Neutral Mob Health Colour", + "entry.provihealth.barHostileStartColour": "Full Hostile Mob Health Colour", + "entry.provihealth.barEndColour": "Low Health Colour", "entry.provihealth.teamColours": "Use Team Colours", - "tooltip.provihealth.compatWorld": "Uses a different rendering program for in-world health bars. Only turn this on if shaders are preventing the bars from rendering.\nWarning: This option disables any colour-related settings for in-world health bars.", + "entry.provihealth.aggressionColours": "Use Entity Aggression Colours", + "tooltip.provihealth.gradient": "Whether or not the health bar will change colour as it gets lower.\nTurning this off sets the bar colour to the starting value.", + "tooltip.provihealth.compatWorld": "Uses a different rendering program for in-world health bars. Only turn this on if shaders are preventing the bars from rendering.\nWarning: This option disables any colour-related settings for in-world health bars.", + "tooltip.provihealth.tintBackground": "Applies the bar colour to the background as well.", "tooltip.provihealth.teamColours": "Matches health bar colour to the entity's team if applicable.\nTeam colours will override colours from other settings.", - "tooltip.provihealth.tintBackground": "Applies the bar colour to the background as well." + "tooltip.provihealth.aggressionColours": "Matches health bar colour to the entity aggression type/level.\nAngered and Hostile mobs will use the Hostile aggression colours.\nNon-angered and Untamed Neutral/Angerable mobs will use the Neutral aggression colours\nPassive mobs will use the default colour.\nIf turned off, all mobs use the default colour." } \ No newline at end of file diff --git a/src/main/generated/assets/provihealth/lang/en_us.json b/src/main/generated/assets/provihealth/lang/en_us.json index 7887e73..9356677 100644 --- a/src/main/generated/assets/provihealth/lang/en_us.json +++ b/src/main/generated/assets/provihealth/lang/en_us.json @@ -1,90 +1,107 @@ { - "category.provihealth.compat": "Compatibility", + "title.provihealth.config": "Provi's Health Bars", + "category.provihealth.general": "General", - "category.provihealth.health": "In-World", "category.provihealth.hud": "HUD", + "category.provihealth.health": "In-World", "category.provihealth.particles": "Particles", - "entity.provihealth.unknownPlayer": "[Invisible Player]", - "entry.provihealth.barEndColour": "Low Health Colour", - "entry.provihealth.barScale": "Bar Size", - "entry.provihealth.barStartColour": "Full Health Colour", + "category.provihealth.compat": "Compatibility", + + "subcategory.provihealth.boss": "Bosses", + "subcategory.provihealth.hostile": "Hostile Mobs", + "subcategory.provihealth.player": "Players", + "subcategory.provihealth.other": "Non-Hostile Mobs", + + "entry.provihealth.hudDuration": "HUD Duration", "entry.provihealth.blacklist": "Blacklist", "entry.provihealth.boss": "Boss Display", - "entry.provihealth.compatHud": "HUD Paperdoll Render Mode", - "entry.provihealth.compatText": "In-World Health Bar SeeThrough Text Mode", - "entry.provihealth.compatWorld": "In-World Health Bar Shader Compatibility", - "entry.provihealth.damageAlpha": "Damage Particle Alpha", - "entry.provihealth.damageColour": "Damage Particle Color", - "entry.provihealth.damageParticleTextColour": "Damage Text Color", - "entry.provihealth.damageParticles": "Show Damage Particles", - "entry.provihealth.gradient": "Dynamic Bar Color", - "entry.provihealth.healingAlpha": "Healing Particle Alpha", - "entry.provihealth.healingColour": "Healing Particle Color", - "entry.provihealth.healingParticleTextColour": "Healing Text Color", - "entry.provihealth.healingParticles": "Show Healing Particles", - "entry.provihealth.healthBar": "Health Bar Visibility", "entry.provihealth.hostile": "Hostile Mob Display", - "entry.provihealth.hudDuration": "HUD Duration", + "entry.provihealth.player": "Player Display", + "entry.provihealth.other": "Non-Hostile Mob Display", + "entry.provihealth.healthBar": "Health Bar Visibility", + "entry.provihealth.targetOverride": "Show On Target", "entry.provihealth.hudGlide": "Glide Speed", - "entry.provihealth.hudOffsetX": "HUD Position", - "entry.provihealth.hudOffsetY": "HUD Offset Y", + "entry.provihealth.showIcon": "Show Group Icon", "entry.provihealth.hudPortraits": "Use Custom HUD Portraits", - "entry.provihealth.hudStatuses": "Show Status Effects", - "entry.provihealth.hudTitles": "Show Titles On HUD", + "entry.provihealth.worldText": "Show Health Value", "entry.provihealth.maxDistance": "Maximum Render Distance", - "entry.provihealth.maxParticleDistance": "Particle Render Distance", - "entry.provihealth.other": "Non-Hostile Mob Display", - "entry.provihealth.overrideLabels": "Replace Nameplates", + "entry.provihealth.barScale": "Bar Size", + "entry.provihealth.hudOffsetY": "HUD Offset Y", + "entry.provihealth.hudTitles": "Show Titles On HUD", + "entry.provihealth.damageParticles": "Show Damage Particles", + "entry.provihealth.healingParticles": "Show Healing Particles", + "entry.provihealth.killText": "Spawn Kill/Insta-kill text", + "entry.provihealth.damageColour": "Damage Particle Color", + "entry.provihealth.healingColour": "Healing Particle Color", "entry.provihealth.particleScale": "Particle Size", "entry.provihealth.particleTextShadow": "Text Shadow", + "entry.provihealth.damageParticleTextColour": "Damage Text Color", + "entry.provihealth.healingParticleTextColour": "Healing Text Color", "entry.provihealth.particleType": "Particle Movement", - "entry.provihealth.player": "Player Display", - "entry.provihealth.showIcon": "Show Group Icon", - "entry.provihealth.targetOverride": "Show On Target", - "entry.provihealth.teamColours": "Use Team Colors", - "entry.provihealth.tintBackground": "Tint Background", - "entry.provihealth.worldOffsetY": "Health Bar Offset Y", + "entry.provihealth.maxParticleDistance": "Particle Render Distance", + "entry.provihealth.hudOffsetX": "HUD Position", + "entry.provihealth.gradient": "Dynamic Bar Color", + "entry.provihealth.barDefaultStartColour": "Full Default/Passive Mob Health Color", + "entry.provihealth.barNeutralStartColour": "Full Neutral Mob Health Color", + "entry.provihealth.barHostileStartColour": "Full Hostile Mob Health Color", + "entry.provihealth.barEndColour": "Low Health Color", + "entry.provihealth.overrideLabels": "Replace Nameplates", "entry.provihealth.worldShadows": "Text Shadow", - "entry.provihealth.worldText": "Show Health Value", + "entry.provihealth.compatText": "In-World Health Bar SeeThrough Text Mode", + "entry.provihealth.compatWorld": "In-World Health Bar Shader Compatibility", + "entry.provihealth.worldOffsetY": "Health Bar Offset Y", "entry.provihealth.worldTitles": "Show Titles In World", - "enum.provihealth.always_hide": "Hide", - "enum.provihealth.always_show": "Show", + "entry.provihealth.damageAlpha": "Damage Particle Alpha", + "entry.provihealth.healingAlpha": "Healing Particle Alpha", + "entry.provihealth.compatHud": "HUD Paperdoll Render Mode", + "entry.provihealth.hudStatuses": "Show Status Effects", + "entry.provihealth.tintBackground": "Tint Background", + "entry.provihealth.teamColours": "Use Team Colors", + "entry.provihealth.aggressionColours": "Use Entity Aggression Colors", + "enum.provihealth.full": "Full", - "enum.provihealth.gravity": "Has Gravity", + "enum.provihealth.portrait_only": "Portrait Only", + "enum.provihealth.none": "None", + + "enum.provihealth.always_show": "Show", "enum.provihealth.hide_if_full": "Hide When Full", - "enum.provihealth.hudportraitcompatmode.compat": "Compatibility", - "enum.provihealth.hudportraitcompatmode.none": "None", - "enum.provihealth.hudportraitcompatmode.standard": "Standard", + "enum.provihealth.always_hide": "Hide", + + "enum.provihealth.rising": "Rising", + "enum.provihealth.gravity": "Has Gravity", + "enum.provihealth.static": "None", + "enum.provihealth.left": "Left", - "enum.provihealth.none": "None", - "enum.provihealth.portrait_only": "Portrait Only", "enum.provihealth.right": "Right", - "enum.provihealth.rising": "Rising", - "enum.provihealth.seethroughtext.full": "SeeThrough Text/Shadows", - "enum.provihealth.seethroughtext.none": "Normal Text/Shadows", + "enum.provihealth.seethroughtext.standard": "SeeThrough Text, Normal Shadows", - "enum.provihealth.static": "None", - "resource.provihealth.rounded_bars": "Rounded Bars", - "resource.provihealth.rounded_bars.description": "Round-styled healthbars.", - "resource.provihealth.square_bars": "Square Bars", - "resource.provihealth.square_bars.description": "Square-styled healthbars.", - "subcategory.provihealth.boss": "Bosses", - "subcategory.provihealth.hostile": "Hostile Mobs", - "subcategory.provihealth.other": "Non-Hostile Mobs", - "subcategory.provihealth.player": "Players", - "title.provihealth.config": "Provi's Health Bars", - "tooltip.provihealth.compatText": "SeeThrough Text is any text that is visible through walls, this includes player nameplates.\nThis setting only applies when Replace Nameplates is active.\nSeeThrough Text-Shadows break easily in both vanilla and heavily modded environments. Change this setting if overridden nameplates render wrong.\nIf this setting does not solve the shadow issue, then disable text-shadows in the In-World menu.", - "tooltip.provihealth.compatWorld": "Uses a different rendering program for in-world health bars. Only turn this on if shaders are preventing the bars from rendering.\nWarning, This option disables any color-related settings for in-world health bars.", - "tooltip.provihealth.glide": "Determines how quickly the health bar will slide from its old value to new values.\nWarning, Very low values will prevent the health bar visual from catching up with the true value.", - "tooltip.provihealth.gradient": "Whether or not the health bar will change color as it gets lower.\nTurning this off sets the bar color to the starting value.", + "enum.provihealth.seethroughtext.none": "Normal Text/Shadows", + "enum.provihealth.seethroughtext.full": "SeeThrough Text/Shadows", + + "enum.provihealth.hudportraitcompatmode.standard": "Standard", + "enum.provihealth.hudportraitcompatmode.compat": "Compatibility", + "enum.provihealth.hudportraitcompatmode.none": "None", + "tooltip.provihealth.hudDuration": "How many ticks the HUD display will linger for when not targeting a mob.", - "tooltip.provihealth.hudOffsetY": "As a percentage of the window height.", + "tooltip.provihealth.targetOverride": "Always render health bar when targeting a mob of this type.", + "tooltip.provihealth.glide": "Determines how quickly the health bar will slide from its old value to new values.\nWarning: Very low values will prevent the health bar visual from catching up with the true value.", "tooltip.provihealth.hudPortraits": "Allows mobs to have different HUD portraits based on their group or type.", - "tooltip.provihealth.hudTitles": "Allows other mods to show text under the HUD portrait.", "tooltip.provihealth.maxDistance": "Mobs beyond this distance will not render health bars.", - "tooltip.provihealth.overrideLabels": "When true health bar text will include the name of the mob and nameplates will not be rendered.\nWhen false health bar text will only show the health values, and the bar will move upwards when a nameplate is being rendered.\nWarning, Only the name of the mob is added to the health bar, if a mod/plugin/scoreboard adds additional lines of text to the nameplate then that text will be lost.", - "tooltip.provihealth.targetOverride": "Always render health bar when targeting a mob of this type.", - "tooltip.provihealth.teamColours": "Matches health bar color to the entity's team if applicable.\nTeam colors will override colors from other settings.", + "tooltip.provihealth.hudOffsetY": "As a percentage of the window height.", + "tooltip.provihealth.gradient": "Whether or not the health bar will change color as it gets lower.\nTurning this off sets the bar color to the starting value.", + "tooltip.provihealth.overrideLabels": "When true health bar text will include the name of the mob and nameplates will not be rendered.\nWhen false health bar text will only show the health values, and the bar will move upwards when a nameplate is being rendered.\nWarning: Only the name of the mob is added to the health bar, if a mod/plugin/scoreboard adds additional lines of text to the nameplate then that text will be lost.", + "tooltip.provihealth.compatText": "SeeThrough Text is any text that is visible through walls, this includes player nameplates.\nThis setting only applies when Replace Nameplates is active.\nSeeThrough Text-Shadows break easily in both vanilla and heavily modded environments. Change this setting if overridden nameplates render wrong.\nIf this setting does not solve the shadow issue, then disable text-shadows in the In-World menu.", + "tooltip.provihealth.compatWorld": "Uses a different rendering program for in-world health bars. Only turn this on if shaders are preventing the bars from rendering.\nWarning: This option disables any color-related settings for in-world health bars.", + "tooltip.provihealth.hudTitles": "Allows other mods to show text under the HUD portrait.", + "tooltip.provihealth.worldTitles": "Allows other mods to show text above the in-world health bars.", "tooltip.provihealth.tintBackground": "Applies the bar color to the background as well.", - "tooltip.provihealth.worldTitles": "Allows other mods to show text above the in-world health bars." + "tooltip.provihealth.teamColours": "Matches health bar color to the entity's team if applicable.\nTeam colors will override colors from other settings.", + "tooltip.provihealth.aggressionColours": "Matches health bar color to the entity aggression type/level.\nAngered and Hostile mobs will use the Hostile aggression colors.\nNon-angered and Untamed Neutral/Angerable mobs will use the Neutral aggression colors\nPassive mobs will use the default color.\nIf turned off, all mobs use the default color.", + + "entity.provihealth.unknownPlayer": "[Invisible Player]", + + "resource.provihealth.rounded_bars": "Rounded Bars", + "resource.provihealth.rounded_bars.description": "Round-styled healthbars.", + "resource.provihealth.square_bars": "Square Bars", + "resource.provihealth.square_bars.description": "Square-styled healthbars." } \ No newline at end of file diff --git a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java index d403c4f..b751cd8 100644 --- a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java +++ b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java @@ -336,7 +336,7 @@ private void renderBar (DrawContext drawContext, Identifier texture, int width, if (barIndex == 1) startColour = Options.WHITE; - else startColour = FunctionalUtilities.deduceColour(entity); + else startColour = FunctionalUtilities.deduceColour(entity, true); Vector3f barColour = Options.lerpBarColour((float)width / (float)BAR_WIDTH, startColour, Options.unpackedEndHud, barIndex == 0 && Options.hudGradient); if (Options.hudPosition == HUDPosition.LEFT) this.drawTexturedQuad(texture, drawContext, BAR_X, BAR_X + width, BAR_Y, BAR_Y + BAR_HEIGHT, 0, 0f, (float)width / (float)BAR_WIDTH, barIndex / 2f, BAR_V2 + barIndex / 2f, barColour); diff --git a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java index 75edb59..5f7a91b 100644 --- a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java +++ b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java @@ -186,30 +186,17 @@ private static void renderBar (IMixinEntityRenderState state, Matrix4f model, Ve Entity entity = state.provi_Health$getEntityType(); // Store to avoid constant calls in checks - if (Options.compatInWorld) { - vertexConsumer.vertex(model, MAX_X, MAX_Y, Z).texture(MAX_U, MAX_V); // Bottom-Right - vertexConsumer.vertex(model, MIN_X, MAX_Y, Z).texture(MIN_U, MAX_V); // Bottom-Left - vertexConsumer.vertex(model, MIN_X, MIN_Y, Z).texture(MIN_U, MIN_V); // Top-Left - vertexConsumer.vertex(model, MAX_X, MIN_Y, Z).texture(MAX_U, MIN_V); // Top-Right + + Vector3f colour; + if (!Options.tintBackground && index == 1) { + colour = Options.WHITE; } - else { - Vector3f colour; - if (!Options.tintBackground && index == 1) { - colour = Options.WHITE; - } - else if (Options.useTeamColours && state.provi_Health$getTeamColour() instanceof Integer teamColour) { - colour = Vec3d.unpackRgb(teamColour).toVector3f(); - } - - else colour = Options.lerpBarColour(healthPercentage, FunctionalUtilities.deduceColour((LivingEntity)entity), Options.unpackedEndWorld, isMount); - - int maxLight = 0xF000F0; - vertexConsumer.vertex(model, MIN_X, MIN_Y, Z).texture(MIN_U, MIN_V).light(maxLight).color(colour.x, colour.y, colour.z, 1f); // Top-Left - vertexConsumer.vertex(model, MAX_X, MIN_Y, Z).texture(MAX_U, MIN_V).light(maxLight).color(colour.x, colour.y, colour.z, 1f); // Top-Right - vertexConsumer.vertex(model, MAX_X, MAX_Y, Z).texture(MAX_U, MAX_V).light(maxLight).color(colour.x, colour.y, colour.z, 1f); // Bottom-Right - vertexConsumer.vertex(model, MIN_X, MAX_Y, Z).texture(MIN_U, MAX_V).light(maxLight).color(colour.x, colour.y, colour.z, 1f); // Bottom-Left + else if (Options.useTeamColours && state.provi_Health$getTeamColour() instanceof Integer teamColour) { + colour = Vec3d.unpackRgb(teamColour).toVector3f(); } + else colour = Options.lerpBarColour(healthPercentage, FunctionalUtilities.deduceColour((LivingEntity)entity, false), Options.unpackedEndWorld, isMount); + int maxLight = 0xF000F0; vertexConsumer.vertex(model, MIN_X, MIN_Y, Z).texture(MIN_U, MIN_V).light(maxLight).color(colour.x, colour.y, colour.z, 1f); // Top-Left vertexConsumer.vertex(model, MAX_X, MIN_Y, Z).texture(MAX_U, MIN_V).light(maxLight).color(colour.x, colour.y, colour.z, 1f); // Top-Right diff --git a/src/main/resources/assets/provihealth/lang/en_gb.json b/src/main/resources/assets/provihealth/lang/en_gb.json deleted file mode 100644 index 9270e7c..0000000 --- a/src/main/resources/assets/provihealth/lang/en_gb.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "entry.provihealth.damageColour": "Damage Particle Colour", - "entry.provihealth.healingColour": "Healing Particle Colour", - "entry.provihealth.damageParticleTextColour": "Damage Text Colour", - "entry.provihealth.healingParticleTextColour": "Healing Text Colour", - "entry.provihealth.barDefaultStartColour": "Full Default/Passive Mob Health Colour", - "entry.provihealth.barNeutralStartColour": "Full Neutral Mob Health Colour", - "entry.provihealth.barHostileStartColour": "Full Hostile Mob Health Colour", - "entry.provihealth.barEndColour": "Low Health Colour", - "entry.provihealth.teamColours": "Use Team Colours", - "entry.provihealth.aggressionColours": "Use Entity Aggression Colours", - - "tooltip.provihealth.gradient": "Whether or not the health bar will change colour as it gets lower.\nTurning this off sets the bar colour to the starting value.", - "tooltip.provihealth.compatWorld": "Uses a different rendering program for in-world health bars. Only turn this on if shaders are preventing the bars from rendering.\nWarning: This option disables any colour-related settings for in-world health bars.", - "tooltip.provihealth.tintBackground": "Applies the bar colour to the background as well.", - "tooltip.provihealth.teamColours": "Matches health bar colour to the entity's team if applicable.\nTeam colours will override colours from other settings.", - "tooltip.provihealth.aggressionColours": "Matches health bar colour to the entity aggression type/level.\nAngered and Hostile mobs will use the Hostile aggression colours.\nNon-angered and Untamed Neutral/Angerable mobs will use the Neutral aggression colours\nPassive mobs will use the default colour.\nIf turned off, all mobs use the default colour." -} \ No newline at end of file diff --git a/src/main/resources/assets/provihealth/lang/en_us.json b/src/main/resources/assets/provihealth/lang/en_us.json deleted file mode 100644 index 73e5d7b..0000000 --- a/src/main/resources/assets/provihealth/lang/en_us.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "title.provihealth.config": "Provi's Health Bars", - - "category.provihealth.general": "General", - "category.provihealth.hud": "HUD", - "category.provihealth.health": "In-World", - "category.provihealth.particles": "Particles", - "category.provihealth.compat": "Compatibility", - - "subcategory.provihealth.boss": "Bosses", - "subcategory.provihealth.hostile": "Hostile Mobs", - "subcategory.provihealth.player": "Players", - "subcategory.provihealth.other": "Non-Hostile Mobs", - - "entry.provihealth.hudDuration": "HUD Duration", - "entry.provihealth.blacklist": "Blacklist", - "entry.provihealth.boss": "Boss Display", - "entry.provihealth.hostile": "Hostile Mob Display", - "entry.provihealth.player": "Player Display", - "entry.provihealth.other": "Non-Hostile Mob Display", - "entry.provihealth.healthBar": "Health Bar Visibility", - "entry.provihealth.targetOverride": "Show On Target", - "entry.provihealth.hudGlide": "Glide Speed", - "entry.provihealth.showIcon": "Show Group Icon", - "entry.provihealth.hudPortraits": "Use Custom HUD Portraits", - "entry.provihealth.worldText": "Show Health Value", - "entry.provihealth.maxDistance": "Maximum Render Distance", - "entry.provihealth.barScale": "Bar Size", - "entry.provihealth.hudOffsetY": "HUD Offset Y", - "entry.provihealth.hudTitles": "Show Titles On HUD", - "entry.provihealth.damageParticles": "Show Damage Particles", - "entry.provihealth.healingParticles": "Show Healing Particles", - "entry.provihealth.killText": "Spawn Kill/Insta-kill text", - "entry.provihealth.damageColour": "Damage Particle Color", - "entry.provihealth.healingColour": "Healing Particle Color", - "entry.provihealth.particleScale": "Particle Size", - "entry.provihealth.particleTextShadow": "Text Shadow", - "entry.provihealth.damageParticleTextColour": "Damage Text Color", - "entry.provihealth.healingParticleTextColour": "Healing Text Color", - "entry.provihealth.particleType": "Particle Movement", - "entry.provihealth.maxParticleDistance": "Particle Render Distance", - "entry.provihealth.hudOffsetX": "HUD Position", - "entry.provihealth.gradient": "Dynamic Bar Color", - "entry.provihealth.barDefaultStartColour": "Full Default/Passive Mob Health Color", - "entry.provihealth.barNeutralStartColour": "Full Neutral Mob Health Color", - "entry.provihealth.barHostileStartColour": "Full Hostile Mob Health Color", - "entry.provihealth.barEndColour": "Low Health Color", - "entry.provihealth.overrideLabels": "Replace Nameplates", - "entry.provihealth.worldShadows": "Text Shadow", - "entry.provihealth.compatText": "In-World Health Bar SeeThrough Text Mode", - "entry.provihealth.compatWorld": "In-World Health Bar Shader Compatibility", - "entry.provihealth.worldOffsetY": "Health Bar Offset Y", - "entry.provihealth.worldTitles": "Show Titles In World", - "entry.provihealth.damageAlpha": "Damage Particle Alpha", - "entry.provihealth.healingAlpha": "Healing Particle Alpha", - "entry.provihealth.compatHud": "HUD Paperdoll Render Mode", - "entry.provihealth.hudStatuses": "Show Status Effects", - "entry.provihealth.tintBackground": "Tint Background", - "entry.provihealth.teamColours": "Use Team Colors", - "entry.provihealth.aggressionColours": "Use Entity Aggression Colors", - - "enum.provihealth.full": "Full", - "enum.provihealth.portrait_only": "Portrait Only", - "enum.provihealth.none": "None", - - "enum.provihealth.always_show": "Show", - "enum.provihealth.hide_if_full": "Hide When Full", - "enum.provihealth.always_hide": "Hide", - - "enum.provihealth.rising": "Rising", - "enum.provihealth.gravity": "Has Gravity", - "enum.provihealth.static": "None", - - "enum.provihealth.left": "Left", - "enum.provihealth.right": "Right", - - "enum.provihealth.seethroughtext.standard": "SeeThrough Text, Normal Shadows", - "enum.provihealth.seethroughtext.none": "Normal Text/Shadows", - "enum.provihealth.seethroughtext.full": "SeeThrough Text/Shadows", - - "enum.provihealth.hudportraitcompatmode.standard": "Standard", - "enum.provihealth.hudportraitcompatmode.compat": "Compatibility", - "enum.provihealth.hudportraitcompatmode.none": "None", - - "tooltip.provihealth.hudDuration": "How many ticks the HUD display will linger for when not targeting a mob.", - "tooltip.provihealth.targetOverride": "Always render health bar when targeting a mob of this type.", - "tooltip.provihealth.glide": "Determines how quickly the health bar will slide from its old value to new values.\nWarning: Very low values will prevent the health bar visual from catching up with the true value.", - "tooltip.provihealth.hudPortraits": "Allows mobs to have different HUD portraits based on their group or type.", - "tooltip.provihealth.maxDistance": "Mobs beyond this distance will not render health bars.", - "tooltip.provihealth.hudOffsetY": "As a percentage of the window height.", - "tooltip.provihealth.gradient": "Whether or not the health bar will change color as it gets lower.\nTurning this off sets the bar color to the starting value.", - "tooltip.provihealth.overrideLabels": "When true health bar text will include the name of the mob and nameplates will not be rendered.\nWhen false health bar text will only show the health values, and the bar will move upwards when a nameplate is being rendered.\nWarning: Only the name of the mob is added to the health bar, if a mod/plugin/scoreboard adds additional lines of text to the nameplate then that text will be lost.", - "tooltip.provihealth.compatText": "SeeThrough Text is any text that is visible through walls, this includes player nameplates.\nThis setting only applies when Replace Nameplates is active.\nSeeThrough Text-Shadows break easily in both vanilla and heavily modded environments. Change this setting if overridden nameplates render wrong.\nIf this setting does not solve the shadow issue, then disable text-shadows in the In-World menu.", - "tooltip.provihealth.compatWorld": "Uses a different rendering program for in-world health bars. Only turn this on if shaders are preventing the bars from rendering.\nWarning: This option disables any color-related settings for in-world health bars.", - "tooltip.provihealth.hudTitles": "Allows other mods to show text under the HUD portrait.", - "tooltip.provihealth.worldTitles": "Allows other mods to show text above the in-world health bars.", - "tooltip.provihealth.tintBackground": "Applies the bar color to the background as well.", - "tooltip.provihealth.teamColours": "Matches health bar color to the entity's team if applicable.\nTeam colors will override colors from other settings.", - "tooltip.provihealth.aggressionColours": "Matches health bar color to the entity aggression type/level.\nAngered and Hostile mobs will use the Hostile aggression colors.\nNon-angered and Untamed Neutral/Angerable mobs will use the Neutral aggression colors\nPassive mobs will use the default color.\nIf turned off, all mobs use the default color.", - - "entity.provihealth.unknownPlayer": "[Invisible Player]", - - "resource.provihealth.rounded_bars": "Rounded Bars", - "resource.provihealth.rounded_bars.description": "Round-styled healthbars.", - "resource.provihealth.square_bars": "Square Bars", - "resource.provihealth.square_bars.description": "Square-styled healthbars." -} \ No newline at end of file From 654c4c20c1ad516319199416f4119f8d919308b3 Mon Sep 17 00:00:00 2001 From: "Radioactive.exe" <84581607+radioactive-exe@users.noreply.github.com> Date: Thu, 5 Jun 2025 14:48:09 +0300 Subject: [PATCH 11/11] Removed Unused imports after moving logic to `FunctionalUtilities` --- .../provismet/provihealth/hud/TargetHealthBar.java | 11 ----------- .../provihealth/util/FunctionalUtilities.java | 2 ++ .../provismet/provihealth/world/EntityHealthBar.java | 8 -------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java index b751cd8..2bee2fb 100644 --- a/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java +++ b/src/main/java/com/provismet/provihealth/hud/TargetHealthBar.java @@ -18,9 +18,6 @@ import net.minecraft.entity.effect.StatusEffect; import net.minecraft.item.ItemStack; import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.command.CommandManager; -import net.minecraft.server.command.ServerCommandSource; import net.minecraft.util.math.Vec3d; import org.joml.Matrix4f; import org.joml.Quaternionf; @@ -38,14 +35,6 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.entity.EntityPose; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.mob.Angerable; -import net.minecraft.entity.mob.EndermanEntity; -import net.minecraft.entity.mob.HoglinEntity; -import net.minecraft.entity.mob.HostileEntity; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.entity.mob.PiglinEntity; -import net.minecraft.entity.passive.LlamaEntity; -import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; diff --git a/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java b/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java index b4e2d40..624c044 100644 --- a/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java +++ b/src/main/java/com/provismet/provihealth/util/FunctionalUtilities.java @@ -60,4 +60,6 @@ else if (Options.useWorldAggressionColours && ( if (inHud) return Options.unpackedDefaultStartHud; else return Options.unpackedDefaultStartWorld; } + + } diff --git a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java index 5f7a91b..3940283 100644 --- a/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java +++ b/src/main/java/com/provismet/provihealth/world/EntityHealthBar.java @@ -17,14 +17,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.mob.HostileEntity; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.entity.mob.PiglinEntity; -import net.minecraft.entity.passive.LlamaEntity; -import net.minecraft.entity.mob.Angerable; -import net.minecraft.entity.mob.EndermanEntity; -import net.minecraft.entity.mob.HoglinEntity; -import net.minecraft.entity.passive.TameableEntity; import com.provismet.provihealth.ProviHealthClient; import com.provismet.provihealth.config.Options; import com.provismet.provihealth.config.Options.SeeThroughText;