Checking config for unbreakable status to make tooltips more accurate in menus such as the creative menu.

This commit is contained in:
2026-01-18 02:21:02 +01:00
parent 07184045e4
commit ed3dcc3d1e

View File

@ -62,6 +62,10 @@ public abstract class TotemItem extends Item {
return getConfig().getChargeCost() == -1;
}
private boolean isUnbreakable() {
return getConfig().getDurability() == 0;
}
private int getMaxCharge() {
return isChargeCostDynamic()
? getConfig().getChargeCostLimit()
@ -217,11 +221,11 @@ public abstract class TotemItem extends Item {
).withStyle(ChatFormatting.GRAY));
tooltipComponents.add(
stack.isDamageableItem()
? LangAsset.TOOLTIP_TOTEM_DURABILITY.getComponent(
isUnbreakable()
? LangAsset.GENERAL_UNBREAKABLE.getComponent().withStyle(ChatFormatting.WHITE)
: LangAsset.TOOLTIP_TOTEM_DURABILITY.getComponent(
Component.literal(String.format("%d / %d", stack.getMaxDamage() - stack.getDamageValue(), stack.getMaxDamage())).withStyle(ChatFormatting.WHITE)
).withStyle(ChatFormatting.GRAY)
: LangAsset.GENERAL_UNBREAKABLE.getComponent().withStyle(ChatFormatting.WHITE)
);
tooltipComponents.add(Component.empty());
@ -272,7 +276,7 @@ public abstract class TotemItem extends Item {
TotemConfigHashData totemConfigHashData = stack.get(ModDataComponents.TOTEM_CONFIG_HASH_DATA);
if (totemConfigHashData == null || totemConfigHashData.getConfigHash() != getConfig().getConfigHash()) {
if (getConfig().getDurability() == 0) {
if (isUnbreakable()) {
stack.set(DataComponents.UNBREAKABLE, new Unbreakable(false));
stack.remove(DataComponents.MAX_DAMAGE);
stack.remove(DataComponents.DAMAGE);