Display matter value for one item and stack at the same time

This commit is contained in:
DBotThePony 2022-11-24 21:35:56 +07:00
parent 4a7fa4c089
commit 5eaa8adc6c
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 22 additions and 8 deletions

View File

@ -271,6 +271,7 @@ private fun misc(provider: MatteryLanguageProvider) {
misc("gui.matter.percentage_level", "Matter level: %s%%") misc("gui.matter.percentage_level", "Matter level: %s%%")
misc("gui.matter.format", "Matter: %s") misc("gui.matter.format", "Matter: %s")
misc("gui.matter.format_and_complexity", "%s / Complexity: %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.matter.name", "MtU")
misc("gui.filter.is_whitelist", "Is Whitelist") misc("gui.filter.is_whitelist", "Is Whitelist")

View File

@ -61,15 +61,15 @@ import ru.dbotthepony.mc.otm.SystemTime
import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive
import ru.dbotthepony.mc.otm.client.minecraft 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.container.stream
import ru.dbotthepony.mc.otm.core.ImpreciseFraction import ru.dbotthepony.mc.otm.core.ImpreciseFraction
import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TextComponent
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.filterNotNull 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.formatMatterFull
import ru.dbotthepony.mc.otm.core.formatSiComponent 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.ifPresentK
import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.isActuallyEmpty
import ru.dbotthepony.mc.otm.core.isZero import ru.dbotthepony.mc.otm.core.isZero
@ -93,6 +93,7 @@ import kotlin.collections.ArrayList
import kotlin.collections.HashMap import kotlin.collections.HashMap
import kotlin.collections.LinkedHashMap import kotlin.collections.LinkedHashMap
import kotlin.math.pow import kotlin.math.pow
import kotlin.math.roundToInt
internal sealed class MutableEntry( internal sealed class MutableEntry(
var matter: ImpreciseFraction, var matter: ImpreciseFraction,
@ -1087,15 +1088,27 @@ object MatterManager {
val window = minecraft.window.window val window = minecraft.window.window
if (InputConstants.isKeyDown(window, GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(window, GLFW.GLFW_KEY_RIGHT_SHIFT)) { 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.hasMatterValue) {
if (matter.complexity >= 1.0E-3) { if (matter.complexity >= 1.0E-3) {
event.toolTip.add( val matterSized = get(event.itemStack, accountForStackSize = true)
TranslatableComponent("otm.gui.matter.format_and_complexity",
matter.matter.formatMatterFull(), if (matter.matter != matterSized.matter || matter.complexity != matterSized.complexity) {
matter.complexity.formatSiComponent(TranslatableComponent("otm.gui.ticks")) event.toolTip.add(
).withStyle(ChatFormatting.AQUA)) 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 { } else {
event.toolTip.add(matter.matter.formatMatterFull().withStyle(ChatFormatting.AQUA)) event.toolTip.add(matter.matter.formatMatterFull().withStyle(ChatFormatting.AQUA))
} }