Checking config for unbreakable status to make tooltips more accurate in menus such as the creative menu.
This commit is contained in:
@ -62,6 +62,10 @@ public abstract class TotemItem extends Item {
|
|||||||
return getConfig().getChargeCost() == -1;
|
return getConfig().getChargeCost() == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isUnbreakable() {
|
||||||
|
return getConfig().getDurability() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
private int getMaxCharge() {
|
private int getMaxCharge() {
|
||||||
return isChargeCostDynamic()
|
return isChargeCostDynamic()
|
||||||
? getConfig().getChargeCostLimit()
|
? getConfig().getChargeCostLimit()
|
||||||
@ -217,11 +221,11 @@ public abstract class TotemItem extends Item {
|
|||||||
).withStyle(ChatFormatting.GRAY));
|
).withStyle(ChatFormatting.GRAY));
|
||||||
|
|
||||||
tooltipComponents.add(
|
tooltipComponents.add(
|
||||||
stack.isDamageableItem()
|
isUnbreakable()
|
||||||
? LangAsset.TOOLTIP_TOTEM_DURABILITY.getComponent(
|
? 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)
|
Component.literal(String.format("%d / %d", stack.getMaxDamage() - stack.getDamageValue(), stack.getMaxDamage())).withStyle(ChatFormatting.WHITE)
|
||||||
).withStyle(ChatFormatting.GRAY)
|
).withStyle(ChatFormatting.GRAY)
|
||||||
: LangAsset.GENERAL_UNBREAKABLE.getComponent().withStyle(ChatFormatting.WHITE)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
tooltipComponents.add(Component.empty());
|
tooltipComponents.add(Component.empty());
|
||||||
@ -272,7 +276,7 @@ public abstract class TotemItem extends Item {
|
|||||||
|
|
||||||
TotemConfigHashData totemConfigHashData = stack.get(ModDataComponents.TOTEM_CONFIG_HASH_DATA);
|
TotemConfigHashData totemConfigHashData = stack.get(ModDataComponents.TOTEM_CONFIG_HASH_DATA);
|
||||||
if (totemConfigHashData == null || totemConfigHashData.getConfigHash() != getConfig().getConfigHash()) {
|
if (totemConfigHashData == null || totemConfigHashData.getConfigHash() != getConfig().getConfigHash()) {
|
||||||
if (getConfig().getDurability() == 0) {
|
if (isUnbreakable()) {
|
||||||
stack.set(DataComponents.UNBREAKABLE, new Unbreakable(false));
|
stack.set(DataComponents.UNBREAKABLE, new Unbreakable(false));
|
||||||
stack.remove(DataComponents.MAX_DAMAGE);
|
stack.remove(DataComponents.MAX_DAMAGE);
|
||||||
stack.remove(DataComponents.DAMAGE);
|
stack.remove(DataComponents.DAMAGE);
|
||||||
|
|||||||
Reference in New Issue
Block a user