Get rid of old formatting helper

This commit is contained in:
DBotThePony 2022-07-03 22:24:56 +07:00
parent 73e0c9a57e
commit 283342dc82
Signed by: DBot
GPG Key ID: DCC23B5715498507
14 changed files with 127 additions and 477 deletions

View File

@ -1,392 +0,0 @@
package ru.dbotthepony.mc.otm.menu;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import ru.dbotthepony.mc.otm.core.Fraction;
import ru.dbotthepony.mc.otm.core.ImpreciseFraction;
import javax.annotation.ParametersAreNonnullByDefault;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class FormattingHelper {
public static final TranslatableComponent SUFFIX_KILO = new TranslatableComponent("otm.suffix_raw.kilo");
public static final TranslatableComponent SUFFIX_MEGA = new TranslatableComponent("otm.suffix_raw.mega");
public static final TranslatableComponent SUFFIX_GIGA = new TranslatableComponent("otm.suffix_raw.giga");
public static final TranslatableComponent SUFFIX_TERA = new TranslatableComponent("otm.suffix_raw.tera");
public static final TranslatableComponent SUFFIX_PETA = new TranslatableComponent("otm.suffix_raw.peta");
public static final TranslatableComponent SUFFIX_EXA = new TranslatableComponent("otm.suffix_raw.exa");
public static final TranslatableComponent SUFFIX_ZETTA = new TranslatableComponent("otm.suffix_raw.zetta");
public static final TranslatableComponent SUFFIX_YOTTA = new TranslatableComponent("otm.suffix_raw.yotta");
public static final TranslatableComponent SUFFIX_DECI = new TranslatableComponent("otm.suffix_raw.deci");
public static final TranslatableComponent SUFFIX_CENTI = new TranslatableComponent("otm.suffix_raw.centi");
public static final TranslatableComponent SUFFIX_MILLI = new TranslatableComponent("otm.suffix_raw.milli");
public static final TranslatableComponent SUFFIX_MICRO = new TranslatableComponent("otm.suffix_raw.micro");
public static final TranslatableComponent SUFFIX_NANO = new TranslatableComponent("otm.suffix_raw.nano");
public static final TranslatableComponent SUFFIX_PICO = new TranslatableComponent("otm.suffix_raw.pico");
public static final TranslatableComponent SUFFIX_FEMTO = new TranslatableComponent("otm.suffix_raw.femto");
public static final TranslatableComponent SUFFIX_ATTO = new TranslatableComponent("otm.suffix_raw.atto");
public static final TranslatableComponent SUFFIX_ZEPTO = new TranslatableComponent("otm.suffix_raw.zepto");
public static final TranslatableComponent SUFFIX_YOCTO = new TranslatableComponent("otm.suffix_raw.yocto");
public static final List<TranslatableComponent> BIG_SUFFIX_STRIPE = List.of(
SUFFIX_KILO,
SUFFIX_MEGA,
SUFFIX_GIGA,
SUFFIX_TERA,
SUFFIX_PETA,
SUFFIX_EXA,
SUFFIX_ZETTA,
SUFFIX_YOTTA
);
public static final List<TranslatableComponent> SMALL_SUFFIX_STRIPE = List.of(
SUFFIX_DECI,
SUFFIX_CENTI,
SUFFIX_MILLI,
SUFFIX_MICRO,
SUFFIX_NANO,
SUFFIX_PICO,
SUFFIX_FEMTO,
SUFFIX_ATTO,
SUFFIX_ZEPTO,
SUFFIX_YOCTO
);
public static final List<TranslatableComponent> BIG_SUFFIX_STRIPE_INV;
public static final List<TranslatableComponent> SMALL_SUFFIX_STRIPE_INV;
static {
var list = new ArrayList<TranslatableComponent>(BIG_SUFFIX_STRIPE.size());
int i2 = 0;
for (int i = BIG_SUFFIX_STRIPE.size() - 1; i >= 0; i--) {
list.add(BIG_SUFFIX_STRIPE.get(i2));
i2++;
}
BIG_SUFFIX_STRIPE_INV = List.copyOf(list);
}
static {
var list = new ArrayList<TranslatableComponent>(BIG_SUFFIX_STRIPE.size());
int i2 = 0;
for (int i = BIG_SUFFIX_STRIPE.size() - 1; i >= 0; i--) {
list.add(BIG_SUFFIX_STRIPE.get(i2));
i2++;
}
SMALL_SUFFIX_STRIPE_INV = List.copyOf(list);
}
public static final String[] SUFFIX_COMPONENTS_ABOVE_ONE = new String[] {
"otm.suffix.kilo",
"otm.suffix.mega",
"otm.suffix.giga",
"otm.suffix.tera",
"otm.suffix.peta",
"otm.suffix.exa",
"otm.suffix.zetta",
"otm.suffix.yotta",
};
public static final BigDecimal[] SUFFIX_ABOVE_ONE = new BigDecimal[] {
new BigDecimal("1000"), // "otm.suffix.kilo": "k%s",
new BigDecimal("1000000"), // "otm.suffix.mega": "M%s",
new BigDecimal("1000000000"), // "otm.suffix.giga": "G%s",
new BigDecimal("1000000000000"), // "otm.suffix.tera": "T%s",
new BigDecimal("1000000000000000"), // "otm.suffix.peta": "P%s",
new BigDecimal("1000000000000000000"), // "otm.suffix.exa": "E%s",
new BigDecimal("1000000000000000000000"), // "otm.suffix.zetta": "Z%s",
new BigDecimal("1000000000000000000000000"), // "otm.suffix.yotta": "Y%s",
};
public static final Fraction[] SUFFIX_ABOVE_ONE_FRAC = new Fraction[] {
Fraction.fromString("1000"), // "otm.suffix.kilo": "k%s",
Fraction.fromString("1000000"), // "otm.suffix.mega": "M%s",
Fraction.fromString("1000000000"), // "otm.suffix.giga": "G%s",
Fraction.fromString("1000000000000"), // "otm.suffix.tera": "T%s",
Fraction.fromString("1000000000000000"), // "otm.suffix.peta": "P%s",
Fraction.fromString("1000000000000000000"), // "otm.suffix.exa": "E%s",
Fraction.fromString("1000000000000000000000"), // "otm.suffix.zetta": "Z%s",
Fraction.fromString("1000000000000000000000000"), // "otm.suffix.yotta": "Y%s",
};
public static final ImpreciseFraction[] SUFFIX_ABOVE_ONE_IM_FRAC = new ImpreciseFraction[] {
new ImpreciseFraction("1000"), // "otm.suffix.kilo": "k%s",
new ImpreciseFraction("1000000"), // "otm.suffix.mega": "M%s",
new ImpreciseFraction("1000000000"), // "otm.suffix.giga": "G%s",
new ImpreciseFraction("1000000000000"), // "otm.suffix.tera": "T%s",
new ImpreciseFraction("1000000000000000"), // "otm.suffix.peta": "P%s",
new ImpreciseFraction("1000000000000000000"), // "otm.suffix.exa": "E%s",
new ImpreciseFraction("1000000000000000000000"), // "otm.suffix.zetta": "Z%s",
new ImpreciseFraction("1000000000000000000000000"), // "otm.suffix.yotta": "Y%s",
};
public static final String[] SUFFIX_COMPONENTS_BELOW_ONE = new String[] {
"otm.suffix.deci",
"otm.suffix.centi",
"otm.suffix.milli",
"otm.suffix.micro",
"otm.suffix.nano",
"otm.suffix.pico",
"otm.suffix.femto",
"otm.suffix.atto",
"otm.suffix.zepto",
"otm.suffix.yocto",
};
public static final BigDecimal[] SUFFIX_BELOW_ONE = new BigDecimal[] {
new BigDecimal("0.1"), // "otm.suffix.milli": "d%s",
new BigDecimal("0.01"), // "otm.suffix.milli": "c%s",
new BigDecimal("0.001"), // "otm.suffix.milli": "m%s",
new BigDecimal("0.000001"), // "otm.suffix.micro": "μ%s",
new BigDecimal("0.000000001"), // "otm.suffix.nano": "n%s",
new BigDecimal("0.000000000001"), // "otm.suffix.pico": "p%s",
new BigDecimal("0.000000000000001"), // "otm.suffix.femto": "f%s",
new BigDecimal("0.000000000000000001"), // "otm.suffix.atto": "a%s",
new BigDecimal("0.000000000000000000001"), // "otm.suffix.zepto": "z%s",
new BigDecimal("0.000000000000000000000001"), // "otm.suffix.yocto": "y%s",
};
public static final Fraction[] SUFFIX_BELOW_ONE_FRAC = new Fraction[] {
Fraction.fromString("0.1"), // "otm.suffix.milli": "d%s",
Fraction.fromString("0.01"), // "otm.suffix.milli": "c%s",
Fraction.fromString("0.001"), // "otm.suffix.milli": "m%s",
Fraction.fromString("0.000001"), // "otm.suffix.micro": "μ%s",
Fraction.fromString("0.000000001"), // "otm.suffix.nano": "n%s",
Fraction.fromString("0.000000000001"), // "otm.suffix.pico": "p%s",
Fraction.fromString("0.000000000000001"), // "otm.suffix.femto": "f%s",
Fraction.fromString("0.000000000000000001"), // "otm.suffix.atto": "a%s",
Fraction.fromString("0.000000000000000000001"), // "otm.suffix.zepto": "z%s",
Fraction.fromString("0.000000000000000000000001"), // "otm.suffix.yocto": "y%s",
};
public static final ImpreciseFraction[] SUFFIX_BELOW_ONE_IM_FRAC = new ImpreciseFraction[] {
new ImpreciseFraction("0.1"), // "otm.suffix.milli": "d%s",
new ImpreciseFraction("0.01"), // "otm.suffix.milli": "c%s",
new ImpreciseFraction("0.001"), // "otm.suffix.milli": "m%s",
new ImpreciseFraction("0.000001"), // "otm.suffix.micro": "μ%s",
new ImpreciseFraction("0.000000001"), // "otm.suffix.nano": "n%s",
//new ImpreciseFraction("0.000000000001"), // "otm.suffix.pico": "p%s",
//new ImpreciseFraction("0.000000000000001"), // "otm.suffix.femto": "f%s",
//new ImpreciseFraction("0.000000000000000001"), // "otm.suffix.atto": "a%s",
//new ImpreciseFraction("0.000000000000000000001"), // "otm.suffix.zepto": "z%s",
//new ImpreciseFraction("0.000000000000000000000001"), // "otm.suffix.yocto": "y%s",
};
public static String formatDecimal(BigDecimal value, int decimals) {
return value.setScale(decimals, RoundingMode.HALF_UP).toString();
}
public static final TranslatableComponent POWER_NAME = new TranslatableComponent("otm.gui.power.name");
public static final TranslatableComponent MATTER_NAME = new TranslatableComponent("otm.gui.matter.name");
public static Component formatPowerLevel(BigDecimal power, BigDecimal max_power) {
return new TranslatableComponent("otm.gui.level", formatSI(power, POWER_NAME), formatSI(max_power, POWER_NAME));
}
public static Component formatPowerLevel(Fraction power, Fraction max_power) {
return new TranslatableComponent("otm.gui.level", formatSI(power, POWER_NAME), formatSI(max_power, POWER_NAME));
}
public static Component formatPowerLevel(ImpreciseFraction power, ImpreciseFraction max_power) {
return new TranslatableComponent("otm.gui.level", formatSI(power, POWER_NAME), formatSI(max_power, POWER_NAME));
}
public static Component formatMatterLevel(BigDecimal power, BigDecimal max_power) {
return new TranslatableComponent("otm.gui.level", formatMatterValuePlain(power), formatMatterValuePlain(max_power));
}
public static Component formatMatterLevel(Fraction power, Fraction max_power) {
return new TranslatableComponent("otm.gui.level", formatMatterValuePlain(power), formatMatterValuePlain(max_power));
}
public static Component formatMatterLevel(ImpreciseFraction power, ImpreciseFraction max_power) {
return new TranslatableComponent("otm.gui.level", formatMatterValuePlain(power), formatMatterValuePlain(max_power));
}
public static TranslatableComponent formatMatterValue(BigDecimal matter) {
return new TranslatableComponent("otm.gui.matter.format", formatSI(matter, MATTER_NAME));
}
public static TranslatableComponent formatMatterValue(Fraction matter) {
return new TranslatableComponent("otm.gui.matter.format", formatSI(matter, MATTER_NAME));
}
public static TranslatableComponent formatMatterValue(ImpreciseFraction matter) {
return new TranslatableComponent("otm.gui.matter.format", formatSI(matter, MATTER_NAME));
}
public static Component formatMatterValuePlain(BigDecimal matter) {
return formatSI(matter, MATTER_NAME);
}
public static Component formatMatterValuePlain(Fraction matter) {
return formatSI(matter, MATTER_NAME);
}
public static Component formatMatterValuePlain(ImpreciseFraction matter) {
return formatSI(matter, MATTER_NAME);
}
public static Component formatPower(BigDecimal power) {
return formatSI(power, POWER_NAME);
}
public static Component formatPower(Fraction power) {
return formatSI(power, POWER_NAME);
}
public static Component formatPower(ImpreciseFraction power) {
return formatSI(power, POWER_NAME);
}
public static Component formatSI(BigDecimal value) {
return formatSI(value, "");
}
public static Component formatSI(Fraction value) {
return formatSI(value, "");
}
public static Component formatSI(BigDecimal value, Object end_suffix) {
if (value.compareTo(BigDecimal.ZERO) == 0) {
if ("".equals(end_suffix)) {
return new TextComponent("0.00");
} else {
return new TranslatableComponent("otm.suffix.merge", "0.00", end_suffix);
}
}
int compare = value.compareTo(BigDecimal.ONE);
if (compare == 0) {
if ("".equals(end_suffix)) {
return new TextComponent("1.00");
} else {
return new TranslatableComponent("otm.suffix.merge", "1.00", end_suffix);
}
} else if (compare > 0) {
for (int i = SUFFIX_ABOVE_ONE.length - 1; i >= 0; i--) {
if (value.compareTo(SUFFIX_ABOVE_ONE[i]) >= 0) {
return new TranslatableComponent(SUFFIX_COMPONENTS_ABOVE_ONE[i], formatDecimal(value.divide(SUFFIX_ABOVE_ONE[i]), 2), end_suffix);
}
}
if ("".equals(end_suffix)) {
return new TextComponent(formatDecimal(value, 2));
} else {
return new TranslatableComponent("otm.suffix.merge", formatDecimal(value, 2), end_suffix);
}
}
for (int i = SUFFIX_BELOW_ONE.length - 1; i >= 0; i--) {
if (value.compareTo(SUFFIX_BELOW_ONE[i]) < 0) {
return new TranslatableComponent(SUFFIX_COMPONENTS_BELOW_ONE[i], formatDecimal(value.divide(SUFFIX_BELOW_ONE[i]), 2), end_suffix);
}
}
if ("".equals(end_suffix)) {
return new TextComponent(formatDecimal(value, 2));
} else {
return new TranslatableComponent("otm.suffix.merge", formatDecimal(value, 2), end_suffix);
}
}
public static Component formatSI(Fraction value, Object end_suffix) {
if (value.compareTo(Fraction.ZERO) == 0) {
if ("".equals(end_suffix)) {
return new TextComponent("0.00");
} else {
return new TranslatableComponent("otm.suffix.merge", "0.00", end_suffix);
}
}
int compare = value.compareTo(Fraction.ONE);
if (compare == 0) {
if ("".equals(end_suffix)) {
return new TextComponent("1.00");
} else {
return new TranslatableComponent("otm.suffix.merge", "1.00", end_suffix);
}
} else if (compare > 0) {
for (int i = SUFFIX_ABOVE_ONE_FRAC.length - 1; i >= 0; i--) {
if (value.compareTo(SUFFIX_ABOVE_ONE_FRAC[i]) >= 0) {
return new TranslatableComponent(SUFFIX_COMPONENTS_ABOVE_ONE[i], value.div(SUFFIX_ABOVE_ONE_FRAC[i]).decimalString(2, true), end_suffix);
}
}
if ("".equals(end_suffix)) {
return new TextComponent(value.decimalString(2, true));
} else {
return new TranslatableComponent("otm.suffix.merge", value.decimalString(2, true), end_suffix);
}
}
for (int i = SUFFIX_BELOW_ONE.length - 1; i >= 0; i--) {
if (value.compareTo(SUFFIX_BELOW_ONE_FRAC[i]) < 0) {
return new TranslatableComponent(SUFFIX_COMPONENTS_BELOW_ONE[i], value.div(SUFFIX_BELOW_ONE_FRAC[i]).decimalString(2, true), end_suffix);
}
}
if ("".equals(end_suffix)) {
return new TextComponent(value.decimalString(2, true));
} else {
return new TranslatableComponent("otm.suffix.merge", value.decimalString(2, true), end_suffix);
}
}
public static Component formatSI(ImpreciseFraction value, Object end_suffix) {
if (value.compareTo(ImpreciseFraction.ZERO) == 0) {
if ("".equals(end_suffix)) {
return new TextComponent("0.00");
} else {
return new TranslatableComponent("otm.suffix.merge", "0.00", end_suffix);
}
}
int compare = value.compareTo(ImpreciseFraction.ONE);
if (compare == 0) {
if ("".equals(end_suffix)) {
return new TextComponent("1.00");
} else {
return new TranslatableComponent("otm.suffix.merge", "1.00", end_suffix);
}
} else if (compare > 0) {
for (int i = SUFFIX_ABOVE_ONE_IM_FRAC.length - 1; i >= 0; i--) {
if (value.compareTo(SUFFIX_ABOVE_ONE_IM_FRAC[i]) >= 0) {
return new TranslatableComponent(SUFFIX_COMPONENTS_ABOVE_ONE[i], value.div(SUFFIX_ABOVE_ONE_IM_FRAC[i]).toString(2), end_suffix);
}
}
if ("".equals(end_suffix)) {
return new TextComponent(value.toString(2));
} else {
return new TranslatableComponent("otm.suffix.merge", value.toString(2), end_suffix);
}
}
for (int i = SUFFIX_BELOW_ONE_IM_FRAC.length - 1; i >= 0; i--) {
if (value.compareTo(SUFFIX_BELOW_ONE_IM_FRAC[i]) < 0) {
return new TranslatableComponent(SUFFIX_COMPONENTS_BELOW_ONE[i], value.div(SUFFIX_BELOW_ONE_IM_FRAC[i]).toString(2), end_suffix);
}
}
if ("".equals(end_suffix)) {
return new TextComponent(value.toString(2));
} else {
return new TranslatableComponent("otm.suffix.merge", value.toString(2), end_suffix);
}
}
}

View File

@ -16,7 +16,6 @@ import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.*
import ru.dbotthepony.mc.otm.menu.FormattingHelper
import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MItems
import kotlin.math.PI import kotlin.math.PI
@ -168,7 +167,7 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context
poseStack.scale(scale, scale, scale) poseStack.scale(scale, scale, scale)
val font = Minecraft.getInstance().font val font = Minecraft.getInstance().font
val text1 = TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", FormattingHelper.formatMatterValuePlain(tile.mass)) val text1 = TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", tile.mass.formatMatter())
val text2 = TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(tile.gravitationStrength)) val text2 = TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(tile.gravitationStrength))
font.drawAligned(poseStack, text1, TextAlign.TOP_LEFT, 0.8f, 0.8f - font.lineHeight.toFloat() / 2f, 0x0) font.drawAligned(poseStack, text1, TextAlign.TOP_LEFT, 0.8f, 0.8f - font.lineHeight.toFloat() / 2f, 0x0)

View File

@ -11,8 +11,8 @@ import ru.dbotthepony.mc.otm.block.EnergyCounterBlock
import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity
import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.RGBAColor
import ru.dbotthepony.mc.otm.core.asAngle import ru.dbotthepony.mc.otm.core.asAngle
import ru.dbotthepony.mc.otm.core.formatPower
import ru.dbotthepony.mc.otm.core.times import ru.dbotthepony.mc.otm.core.times
import ru.dbotthepony.mc.otm.menu.FormattingHelper
import kotlin.math.PI import kotlin.math.PI
class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<EnergyCounterBlockEntity> { class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<EnergyCounterBlockEntity> {
@ -59,7 +59,7 @@ class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Con
y += font.lineHeight * 3 y += font.lineHeight * 3
font.drawAligned(poseStack, TOTAL, TextAlign.CENTER_CENTER, 0f, y, RGBAColor.WHITE) font.drawAligned(poseStack, TOTAL, TextAlign.CENTER_CENTER, 0f, y, RGBAColor.WHITE)
font.drawAligned(poseStack, FormattingHelper.formatPower(tile.passed), TextAlign.CENTER_CENTER, 0f, y + font.lineHeight, RGBAColor.WHITE) font.drawAligned(poseStack, tile.passed.formatPower(), TextAlign.CENTER_CENTER, 0f, y + font.lineHeight, RGBAColor.WHITE)
poseStack.popPose() poseStack.popPose()
} }

View File

@ -17,7 +17,6 @@ import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
import ru.dbotthepony.mc.otm.block.entity.worker.WorkerState import ru.dbotthepony.mc.otm.block.entity.worker.WorkerState
import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.*
import ru.dbotthepony.mc.otm.menu.FormattingHelper
import kotlin.math.PI import kotlin.math.PI
private val BEAM_RENDER_TYPE_INNER = RenderType.beaconBeam(BeaconRenderer.BEAM_LOCATION, false) private val BEAM_RENDER_TYPE_INNER = RenderType.beaconBeam(BeaconRenderer.BEAM_LOCATION, false)
@ -144,7 +143,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv
poseStack.scale(0.01f, 0.01f, 0.01f) poseStack.scale(0.01f, 0.01f, 0.01f)
val font = Minecraft.getInstance().font val font = Minecraft.getInstance().font
font.drawAligned(poseStack, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", FormattingHelper.formatMatterValuePlain(bhTile.mass)), TextAlign.TOP_CENTER, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) font.drawAligned(poseStack, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter()), TextAlign.TOP_CENTER, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF)
font.drawAligned(poseStack, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), TextAlign.TOP_CENTER, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) font.drawAligned(poseStack, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), TextAlign.TOP_CENTER, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF)
poseStack.popPose() poseStack.popPose()

View File

@ -4,8 +4,8 @@ import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TranslatableComponent import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.core.formatPower
import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu
import ru.dbotthepony.mc.otm.menu.FormattingHelper
class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: Component) : MatteryScreen<EnergyCounterMenu>(menu, inventory, title) { class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: Component) : MatteryScreen<EnergyCounterMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel { override fun makeMainFrame(): FramePanel {
@ -16,7 +16,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
super.tick() super.tick()
text = TranslatableComponent( text = TranslatableComponent(
"otm.item.power.passed", "otm.item.power.passed",
FormattingHelper.formatPower(menu.passed.value) menu.passed.value.formatPower()
) )
} }
} }
@ -29,7 +29,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
super.tick() super.tick()
text = TranslatableComponent( text = TranslatableComponent(
"otm.item.power.average", "otm.item.power.average",
FormattingHelper.formatPower(menu.average.value) menu.average.value.formatPower()
) )
} }
} }
@ -42,7 +42,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
super.tick() super.tick()
text = TranslatableComponent( text = TranslatableComponent(
"otm.item.power.last_20_ticks", "otm.item.power.last_20_ticks",
FormattingHelper.formatPower(menu.last20Ticks.value) menu.last20Ticks.value.formatPower()
) )
} }
} }
@ -55,7 +55,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
super.tick() super.tick()
text = TranslatableComponent( text = TranslatableComponent(
"otm.item.power.last_tick", "otm.item.power.last_tick",
FormattingHelper.formatPower(menu.lastTick.value) menu.lastTick.value.formatPower()
) )
} }
} }

View File

@ -5,7 +5,7 @@ import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
import ru.dbotthepony.mc.otm.menu.FormattingHelper import ru.dbotthepony.mc.otm.core.formatPower
import ru.dbotthepony.mc.otm.menu.StorageImporterMenu import ru.dbotthepony.mc.otm.menu.StorageImporterMenu
import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu
@ -24,7 +24,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve
text = TranslatableComponent( text = TranslatableComponent(
"otm.item.power.passed", "otm.item.power.passed",
FormattingHelper.formatPower(menu.totalTransferred.value) menu.totalTransferred.value.formatPower()
) )
} }
} }

View File

@ -10,7 +10,8 @@ import ru.dbotthepony.mc.otm.client.render.SkinElement
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.menu.FormattingHelper import ru.dbotthepony.mc.otm.core.formatMatterLevel
import ru.dbotthepony.mc.otm.core.formatPowerLevel
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
@ -28,7 +29,7 @@ open class PowerGaugePanel @JvmOverloads constructor(
protected open fun makeTooltip(): MutableList<Component> { protected open fun makeTooltip(): MutableList<Component> {
return mutableListOf( return mutableListOf(
TranslatableComponent("otm.gui.power.percentage_level", String.format("%.2f", widget.percentage() * 100.0)), TranslatableComponent("otm.gui.power.percentage_level", String.format("%.2f", widget.percentage() * 100.0)),
FormattingHelper.formatPowerLevel(widget.level(), widget.maxLevel()) formatPowerLevel(widget.level(), widget.maxLevel())
) )
} }
@ -67,7 +68,7 @@ open class MatterGaugePanel @JvmOverloads constructor(
protected open fun makeTooltip(): MutableList<Component> { protected open fun makeTooltip(): MutableList<Component> {
return mutableListOf( return mutableListOf(
TranslatableComponent("otm.gui.matter.percentage_level", String.format("%.2f", widget.percentage() * 100.0)), TranslatableComponent("otm.gui.matter.percentage_level", String.format("%.2f", widget.percentage() * 100.0)),
FormattingHelper.formatMatterLevel(widget.level(), widget.maxLevel()) formatMatterLevel(widget.level(), widget.maxLevel())
) )
} }

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.core
import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableList
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TextComponent import net.minecraft.network.chat.TextComponent
import net.minecraft.network.chat.TranslatableComponent
import java.math.BigDecimal import java.math.BigDecimal
import java.math.BigInteger import java.math.BigInteger
@ -126,32 +127,6 @@ enum class SiPrefix(
} }
} }
private fun formatSi(si: SiPrefix, divided: String, remainder: String, decimalPlaces: Int, isNegative: Boolean): String {
@Suppress("NAME_SHADOWING")
val decimalPlaces = decimalPlaces.coerceAtMost(si.power)
val add = (if (isNegative) 1 else 0)
val buffer = CharArray(divided.length + 2 + decimalPlaces + add)
buffer[buffer.size - 1] = si.symbol
if (isNegative) {
buffer[0] = '-'
}
for (i in divided.indices) {
buffer[add + i] = divided[i]
}
buffer[add + divided.length] = '.'
for (i in 0 until decimalPlaces) {
buffer[add + i + divided.length + 1] = si.paddedIndex(remainder, i)
}
return String(buffer)
}
fun BigDecimal.determineSiPrefix(): SiPrefix? { fun BigDecimal.determineSiPrefix(): SiPrefix? {
if (isZero) { if (isZero) {
return null return null
@ -227,18 +202,80 @@ fun BigInteger.formatSi(decimalPlaces: Int = 2): String {
val prefix = determineSiPrefix() ?: return toString() // + "." + "0".repeat(decimalPlaces) val prefix = determineSiPrefix() ?: return toString() // + "." + "0".repeat(decimalPlaces)
val isNegative = isNegative val isNegative = isNegative
val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer) val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer)
val divided = arr[0] val divided = arr[0].toString()
val remainder = arr[1] val remainder = arr[1].toString()
if (decimalPlaces == 0) { if (decimalPlaces == 0) {
if (isNegative) { if (isNegative) {
return "-" + divided.toString() + prefix.symbol return "-" + divided + prefix.symbol
} else { } else {
return divided.toString() + prefix.symbol return divided + prefix.symbol
} }
} }
return formatSi(prefix, divided.toString(), remainder.toString(), decimalPlaces, isNegative) @Suppress("NAME_SHADOWING")
val decimalPlaces = decimalPlaces.coerceAtMost(prefix.power)
val add = (if (isNegative) 1 else 0)
val buffer = CharArray(divided.length + 2 + decimalPlaces + add)
buffer[buffer.size - 1] = prefix.symbol
if (isNegative) {
buffer[0] = '-'
}
for (i in divided.indices) {
buffer[add + i] = divided[i]
}
buffer[add + divided.length] = '.'
for (i in 0 until decimalPlaces) {
buffer[add + i + divided.length + 1] = prefix.paddedIndex(remainder, i)
}
return String(buffer)
}
fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component {
require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" }
val prefix = determineSiPrefix() ?: return TextComponent(toString())
val isNegative = isNegative
val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer)
val divided = arr[0].toString()
val remainder = arr[1].toString()
if (decimalPlaces == 0) {
if (isNegative) {
return TranslatableComponent(prefix.formatLocaleKey, "-$divided", suffix)
} else {
return TranslatableComponent(prefix.formatLocaleKey, divided + prefix.symbol, suffix)
}
}
@Suppress("NAME_SHADOWING")
val decimalPlaces = decimalPlaces.coerceAtMost(prefix.power)
val add = (if (isNegative) 1 else 0)
val buffer = CharArray(divided.length + 1 + decimalPlaces + add)
if (isNegative) {
buffer[0] = '-'
}
for (i in divided.indices) {
buffer[add + i] = divided[i]
}
buffer[add + divided.length] = '.'
for (i in 0 until decimalPlaces) {
buffer[add + i + divided.length + 1] = prefix.paddedIndex(remainder, i)
}
return TranslatableComponent(prefix.formatLocaleKey, String(buffer), suffix)
} }
fun ImpreciseFraction.determineSiPrefix(): SiPrefix? { fun ImpreciseFraction.determineSiPrefix(): SiPrefix? {
@ -280,3 +317,23 @@ fun ImpreciseFraction.formatSi(decimalPlaces: Int = 2): String {
val prefix = determineSiPrefix() ?: return toString(decimalPlaces) val prefix = determineSiPrefix() ?: return toString(decimalPlaces)
return (this / prefix.impreciseFraction).toString(decimalPlaces) + prefix.symbol return (this / prefix.impreciseFraction).toString(decimalPlaces) + prefix.symbol
} }
fun ImpreciseFraction.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component {
require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" }
val prefix = determineSiPrefix() ?: return TextComponent(toString(decimalPlaces))
return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.impreciseFraction).toString(decimalPlaces), suffix)
}
val POWER_NAME = TranslatableComponent("otm.gui.power.name")
val MATTER_NAME = TranslatableComponent("otm.gui.matter.name")
fun ImpreciseFraction.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces)
fun ImpreciseFraction.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces)
fun ImpreciseFraction.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(MATTER_NAME, decimalPlaces))
fun BigInteger.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces)
fun BigInteger.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces)
fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(MATTER_NAME, decimalPlaces))
fun formatPowerLevel(a: ImpreciseFraction, b: ImpreciseFraction, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces), b.formatPower(decimalPlaces))
fun formatMatterLevel(a: ImpreciseFraction, b: ImpreciseFraction, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces), b.formatMatter(decimalPlaces))

View File

@ -1,25 +1,20 @@
package ru.dbotthepony.mc.otm.item package ru.dbotthepony.mc.otm.item
import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage
import net.minecraftforge.common.capabilities.ICapabilityProvider
import net.minecraft.world.item.ItemStack
import net.minecraft.nbt.CompoundTag
import ru.dbotthepony.mc.otm.capability.MatteryCapability
import net.minecraftforge.common.util.LazyOptional
import net.minecraftforge.energy.CapabilityEnergy
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import net.minecraft.network.chat.TranslatableComponent
import ru.dbotthepony.mc.otm.menu.FormattingHelper
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.world.item.Item import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Rarity import net.minecraft.world.item.Rarity
import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.TooltipFlag
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.capability.EnergyCapacitorItem import ru.dbotthepony.mc.otm.capability.EnergyCapacitorItem
import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.core.ImpreciseFraction import ru.dbotthepony.mc.otm.core.ImpreciseFraction
import ru.dbotthepony.mc.otm.core.formatPower
import ru.dbotthepony.mc.otm.ifPresentK import ru.dbotthepony.mc.otm.ifPresentK
class BatteryItem : Item { class BatteryItem : Item {
@ -59,8 +54,8 @@ class BatteryItem : Item {
this.extract = extract this.extract = extract
throughputText = TranslatableComponent( throughputText = TranslatableComponent(
"otm.item.power.normal.throughput", "otm.item.power.normal.throughput",
FormattingHelper.formatPower(receive), receive.formatPower(),
FormattingHelper.formatPower(extract) extract.formatPower()
).withStyle(ChatFormatting.GRAY) ).withStyle(ChatFormatting.GRAY)
} }
@ -88,8 +83,8 @@ class BatteryItem : Item {
p_41423_.add( p_41423_.add(
TranslatableComponent( TranslatableComponent(
"otm.item.power.normal.storage", "otm.item.power.normal.storage",
FormattingHelper.formatPower(it.batteryLevel), it.batteryLevel.formatPower(),
FormattingHelper.formatPower(it.maxBatteryLevel) it.maxBatteryLevel.formatPower()
).withStyle(ChatFormatting.GRAY) ).withStyle(ChatFormatting.GRAY)
) )
} }

View File

@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableMultimap
import com.google.common.collect.Multimap import com.google.common.collect.Multimap
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TranslatableComponent import net.minecraft.network.chat.TranslatableComponent
@ -21,14 +20,11 @@ import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.Material
import net.minecraftforge.common.capabilities.Capability
import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.capabilities.ICapabilityProvider
import net.minecraftforge.common.util.LazyOptional
import net.minecraftforge.energy.CapabilityEnergy
import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.*
import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.*
import ru.dbotthepony.mc.otm.core.ImpreciseFraction import ru.dbotthepony.mc.otm.core.ImpreciseFraction
import ru.dbotthepony.mc.otm.menu.FormattingHelper import ru.dbotthepony.mc.otm.core.formatPower
import ru.dbotthepony.mc.otm.registry.EMPDamageSource import ru.dbotthepony.mc.otm.registry.EMPDamageSource
class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
@ -94,8 +90,8 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE).tab(Ov
p_41423_.add( p_41423_.add(
TranslatableComponent( TranslatableComponent(
"otm.item.power.normal.storage", "otm.item.power.normal.storage",
FormattingHelper.formatPower(it.batteryLevel), it.batteryLevel.formatPower(),
FormattingHelper.formatPower(it.maxBatteryLevel) it.maxBatteryLevel.formatPower()
).withStyle(ChatFormatting.GRAY) ).withStyle(ChatFormatting.GRAY)
) )
} }

View File

@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler
import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.capability.matter.MatterDirection
import ru.dbotthepony.mc.otm.core.ImpreciseFraction import ru.dbotthepony.mc.otm.core.ImpreciseFraction
import ru.dbotthepony.mc.otm.menu.FormattingHelper import ru.dbotthepony.mc.otm.core.formatMatter
import javax.annotation.ParametersAreNonnullByDefault import javax.annotation.ParametersAreNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
@ -117,8 +117,8 @@ class MatterCapacitorItem : Item {
p_41423_.add( p_41423_.add(
TranslatableComponent( TranslatableComponent(
"otm.item.matter.normal", "otm.item.matter.normal",
FormattingHelper.formatMatterValuePlain(cap.storedMatter), cap.storedMatter.formatMatter(),
FormattingHelper.formatMatterValuePlain(storage) storage.formatMatter()
).withStyle(ChatFormatting.GRAY) ).withStyle(ChatFormatting.GRAY)
) )
} }

View File

@ -31,7 +31,6 @@ import ru.dbotthepony.mc.otm.client.font
import ru.dbotthepony.mc.otm.client.render.RenderHelper import ru.dbotthepony.mc.otm.client.render.RenderHelper
import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.*
import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.core.Vector
import ru.dbotthepony.mc.otm.menu.FormattingHelper
import ru.dbotthepony.mc.otm.network.MatteryNetworking import ru.dbotthepony.mc.otm.network.MatteryNetworking
import java.util.* import java.util.*
import java.util.function.Supplier import java.util.function.Supplier
@ -459,7 +458,7 @@ abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, ra
pose.pushPose() pose.pushPose()
pose.translate(0.0, 0.0, -1.0) pose.translate(0.0, 0.0, -1.0)
pose.scale(0.7f, 0.7f, 0.7f) pose.scale(0.7f, 0.7f, 0.7f)
val text = FormattingHelper.formatPower(it.batteryLevel) val text = it.batteryLevel.formatPower()
font.draw(pose, text, 2f, 2f, RGBAColor.WHITE.toInt()) font.draw(pose, text, 2f, 2f, RGBAColor.WHITE.toInt())
pose.popPose() pose.popPose()
} }

View File

@ -19,10 +19,10 @@ import net.minecraftforge.energy.CapabilityEnergy
import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.*
import ru.dbotthepony.mc.otm.core.ImpreciseFraction import ru.dbotthepony.mc.otm.core.ImpreciseFraction
import ru.dbotthepony.mc.otm.core.bezierCurve import ru.dbotthepony.mc.otm.core.bezierCurve
import ru.dbotthepony.mc.otm.core.formatPower
import ru.dbotthepony.mc.otm.doubles import ru.dbotthepony.mc.otm.doubles
import ru.dbotthepony.mc.otm.ifPresentK import ru.dbotthepony.mc.otm.ifPresentK
import ru.dbotthepony.mc.otm.ints import ru.dbotthepony.mc.otm.ints
import ru.dbotthepony.mc.otm.menu.FormattingHelper
import ru.dbotthepony.mc.otm.registry.MSoundEvents import ru.dbotthepony.mc.otm.registry.MSoundEvents
import ru.dbotthepony.mc.otm.set import ru.dbotthepony.mc.otm.set
import kotlin.reflect.KClass import kotlin.reflect.KClass
@ -169,8 +169,8 @@ abstract class PlasmaWeaponItem<D : PlasmaWeaponDataTable>(tables: KClass<D>, pr
p_41423_.add( p_41423_.add(
TranslatableComponent( TranslatableComponent(
"otm.item.power.normal.storage", "otm.item.power.normal.storage",
FormattingHelper.formatPower(it.batteryLevel), it.batteryLevel.formatPower(),
FormattingHelper.formatPower(it.maxBatteryLevel) it.maxBatteryLevel.formatPower()
).withStyle(ChatFormatting.GRAY) ).withStyle(ChatFormatting.GRAY)
) )
} }

View File

@ -19,11 +19,7 @@ import org.lwjgl.glfw.GLFW
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
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.core.ImpreciseFraction import ru.dbotthepony.mc.otm.core.*
import ru.dbotthepony.mc.otm.core.isZero
import ru.dbotthepony.mc.otm.core.readImpreciseFraction
import ru.dbotthepony.mc.otm.core.writeImpreciseFraction
import ru.dbotthepony.mc.otm.menu.FormattingHelper
import ru.dbotthepony.mc.otm.network.MatteryNetworking import ru.dbotthepony.mc.otm.network.MatteryNetworking
import ru.dbotthepony.mc.otm.orNull import ru.dbotthepony.mc.otm.orNull
import ru.dbotthepony.mc.otm.storage.ItemStackWrapper import ru.dbotthepony.mc.otm.storage.ItemStackWrapper
@ -259,11 +255,11 @@ fun tooltipEvent(event: ItemTooltipEvent) {
if (matter.complexity >= 1.0E-3) { if (matter.complexity >= 1.0E-3) {
event.toolTip.add( event.toolTip.add(
TranslatableComponent("otm.gui.matter.format_and_complexity", TranslatableComponent("otm.gui.matter.format_and_complexity",
FormattingHelper.formatMatterValue(matter.value), matter.value.formatMatterFull(),
"%.3f".format(matter.complexity) "%.3f".format(matter.complexity)
).withStyle(ChatFormatting.AQUA)) ).withStyle(ChatFormatting.AQUA))
} else { } else {
event.toolTip.add(FormattingHelper.formatMatterValue(matter.value).withStyle(ChatFormatting.AQUA)) event.toolTip.add(matter.value.formatMatterFull().withStyle(ChatFormatting.AQUA))
} }
} }
} }