diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt index 67040f3b0..cc4c30bb3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt @@ -75,6 +75,9 @@ interface IMatteryUpgrade { companion object : IMatteryUpgrade } +private val positiveBound = Decimal("0.01") +private val negativeBound = Decimal("-0.01") + fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection) { if (upgradeTypes.isNotEmpty() && ShiftPressedCond.asBoolean) { tooltips.add(TranslatableComponent("otm.gui.upgrade_type.list").withStyle(ChatFormatting.GRAY)) @@ -104,9 +107,9 @@ fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection Decimal.ONE) { + if (energyConsumed >= positiveBound) { tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent("+" + (energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) - } else if (energyConsumed < Decimal.MINUS_ONE) { + } else if (energyConsumed <= negativeBound) { tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent((energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) }