Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Fix numerical display halving health values #298

Open
wants to merge 1 commit into
base: 1.16_forge
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public void appendHead(List<ITextComponent> tooltip, IEntityAccessor accessor, I
public void appendBody(List<ITextComponent> tooltip, IEntityAccessor accessor, IPluginConfig config) {
if (config.get(PluginCore.CONFIG_SHOW_ENTITY_HEALTH) && accessor.getEntity() instanceof LivingEntity) {
LivingEntity living = (LivingEntity) accessor.getEntity();
float health = living.getHealth() / 2.0F;
float maxHealth = living.getMaxHealth() / 2.0F;
float health = living.getHealth();
float maxHealth = living.getMaxHealth();

if (living.getMaxHealth() > Waila.CONFIG.get().getGeneral().getMaxHealthForRender())
tooltip.add(new TranslationTextComponent("tooltip.waila.health", String.format("%.2f", health), String.format("%.2f", maxHealth)));
else {
CompoundNBT healthData = new CompoundNBT();
healthData.putFloat("health", health);
healthData.putFloat("max", maxHealth);
healthData.putFloat("health", health / 2.0F);
healthData.putFloat("max", maxHealth / 2.0F);
tooltip.add(new RenderableTextComponent(PluginCore.RENDER_ENTITY_HEALTH, healthData));
}
}
Expand All @@ -43,4 +43,4 @@ public void appendBody(List<ITextComponent> tooltip, IEntityAccessor accessor, I
public void appendTail(List<ITextComponent> tooltip, IEntityAccessor accessor, IPluginConfig config) {
tooltip.add(new StringTextComponent(String.format(Waila.CONFIG.get().getFormatting().getModName(), ModIdentification.getModInfo(accessor.getEntity()).getName())));
}
}
}