From 5eaa8adc6c248534dab5306138a4b6a4319718ff Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 24 Nov 2022 21:35:56 +0700 Subject: [PATCH] Display matter value for one item and stack at the same time --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/matter/MatterManager.kt | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index bf3618ad2..e0cae9e8a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -271,6 +271,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("gui.matter.percentage_level", "Matter level: %s%%") misc("gui.matter.format", "Matter: %s") misc("gui.matter.format_and_complexity", "%s / Complexity: %s") + misc("gui.matter.format_and_complexity2", "%s (%s) / Complexity: %s (%s)") misc("gui.matter.name", "MtU") misc("gui.filter.is_whitelist", "Is Whitelist") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index e07e73154..8540dc592 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -61,15 +61,15 @@ import ru.dbotthepony.mc.otm.SystemTime import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.container.iterator -import ru.dbotthepony.mc.otm.container.spliterator import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.ImpreciseFraction import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.filterNotNull +import ru.dbotthepony.mc.otm.core.formatMatter import ru.dbotthepony.mc.otm.core.formatMatterFull import ru.dbotthepony.mc.otm.core.formatSiComponent +import ru.dbotthepony.mc.otm.core.formatTickDuration import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.isZero @@ -93,6 +93,7 @@ import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.collections.LinkedHashMap import kotlin.math.pow +import kotlin.math.roundToInt internal sealed class MutableEntry( var matter: ImpreciseFraction, @@ -1087,15 +1088,27 @@ object MatterManager { val window = minecraft.window.window if (InputConstants.isKeyDown(window, GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(window, GLFW.GLFW_KEY_RIGHT_SHIFT)) { - val matter = get(event.itemStack) + val matter = get(event.itemStack, accountForStackSize = false) if (matter.hasMatterValue) { if (matter.complexity >= 1.0E-3) { - event.toolTip.add( - TranslatableComponent("otm.gui.matter.format_and_complexity", - matter.matter.formatMatterFull(), - matter.complexity.formatSiComponent(TranslatableComponent("otm.gui.ticks")) - ).withStyle(ChatFormatting.AQUA)) + val matterSized = get(event.itemStack, accountForStackSize = true) + + if (matter.matter != matterSized.matter || matter.complexity != matterSized.complexity) { + event.toolTip.add( + TranslatableComponent("otm.gui.matter.format_and_complexity2", + matter.matter.formatMatterFull(), + matterSized.matter.formatMatter(), + if (matter.complexity > 1000.0) formatTickDuration(matter.complexity.roundToInt(), true) else matter.complexity.formatSiComponent(TranslatableComponent("otm.gui.ticks")), + if (matterSized.complexity > 1000.0) formatTickDuration(matterSized.complexity.roundToInt(), true) else matterSized.complexity.formatSiComponent(TranslatableComponent("otm.gui.ticks")), + ).withStyle(ChatFormatting.AQUA)) + } else { + event.toolTip.add( + TranslatableComponent("otm.gui.matter.format_and_complexity", + matter.matter.formatMatterFull(), + if (matter.complexity > 1000.0) formatTickDuration(matter.complexity.roundToInt(), true) else matter.complexity.formatSiComponent(TranslatableComponent("otm.gui.ticks")), + ).withStyle(ChatFormatting.AQUA)) + } } else { event.toolTip.add(matter.matter.formatMatterFull().withStyle(ChatFormatting.AQUA)) }