Fixed charge going below 0 when reviving more expensive targets with dynamic cost. Fixing tooltip cost appearing in red when the target's cost is more than the max charge capacity but the totem can revive more expensive targets.

This commit is contained in:
2026-01-18 02:48:22 +01:00
parent c21ba74432
commit 05192b2601

View File

@ -184,7 +184,7 @@ public abstract class TotemItem extends Item {
totemData.getTargetStringUUID(),
totemData.getTargetName(),
totemData.getTargetDeaths(),
totemData.getCharge() - totemItem.getTargetCost(totemData)
Math.max(0, totemData.getCharge() - totemItem.getTargetCost(totemData))
);
setTotemData(itemStack, totemData);
itemStack.hurtAndBreak(1, user, slot);
@ -209,7 +209,7 @@ public abstract class TotemItem extends Item {
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_TARGET_COST.getComponent(
totemData.getTargetUUID().isPresent()
? Component.literal(String.format("%d", getTargetCost(totemData))).withStyle(
getTargetCost(totemData) <= getMaxCharge()
getTargetCost(totemData) <= getMaxCharge() || (getConfig().getCanReviveMoreExpensiveTargets())
? ChatFormatting.WHITE
: ChatFormatting.RED
)