From fea86d74ef2e576d6a1d1033fa4145aa57b86483 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 5 Feb 2023 17:56:35 +0700 Subject: [PATCH] Cycle between full and si-prefixed matter values --- .../ru/dbotthepony/mc/otm/matter/MatterManager.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 15851efe9..8d2f02ae8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -79,6 +79,7 @@ import ru.dbotthepony.mc.otm.core.readItemType import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.core.writeItemType +import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.registry.RegistryDelegate @@ -86,6 +87,7 @@ import ru.dbotthepony.mc.otm.storage.ItemStackWrapper import java.io.File import java.math.BigInteger import java.util.* +import java.util.function.BooleanSupplier import java.util.function.Supplier import java.util.stream.Stream import kotlin.ConcurrentModificationException @@ -1085,6 +1087,8 @@ object MatterManager { return getResearchAdvance(this@MatterManager.get(stack.asItem()).complexity) } + private val formatMatterAsReadable = BooleanSupplier { minecraft.window.isShiftDown && milliTime % 2_000L > 1_000L } + fun tooltipEvent(event: ItemTooltipEvent) { if (minecraft.window.isShiftDown) { val matter = get(event.itemStack, accountForStackSize = false) @@ -1096,20 +1100,20 @@ object MatterManager { 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(), + matter.matter.formatMatterFull(formatAsReadable = formatMatterAsReadable), + matterSized.matter.formatMatter(formatAsReadable = formatMatterAsReadable), 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(), + matter.matter.formatMatterFull(formatAsReadable = formatMatterAsReadable), 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)) + event.toolTip.add(matter.matter.formatMatterFull(formatAsReadable = formatMatterAsReadable).withStyle(ChatFormatting.AQUA)) } }