lol
This commit is contained in:
parent
13bfa7f2b2
commit
85ed4802f4
@ -147,30 +147,25 @@ fun Long.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsRea
|
||||
}
|
||||
|
||||
val prefix = SiPrefix.determine(this)
|
||||
|
||||
if (bias == 0) {
|
||||
return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix)
|
||||
} else {
|
||||
return TranslatableComponent(SiPrefix.determine(this, bias).formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix)
|
||||
}
|
||||
return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix)
|
||||
}
|
||||
|
||||
fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component {
|
||||
return toLong().formatSiComponent(suffix, decimalPlaces, formatAsReadable, bias)
|
||||
}
|
||||
|
||||
fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component {
|
||||
fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component {
|
||||
require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" }
|
||||
if (formatAsReadable.asBoolean) return concat(reformat("%.${decimalPlaces}f".format(this)), suffix)
|
||||
val prefix = SiPrefix.determine(this)
|
||||
return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix)
|
||||
return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix)
|
||||
}
|
||||
|
||||
fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component {
|
||||
fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component {
|
||||
require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" }
|
||||
if (formatAsReadable.asBoolean) return concat(reformat(toString(decimalPlaces)), suffix)
|
||||
val prefix = SiPrefix.determine(this)
|
||||
return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.decimal).toString(decimalPlaces), suffix)
|
||||
return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, (this / prefix.decimal).toString(decimalPlaces), suffix)
|
||||
}
|
||||
|
||||
fun Int.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable)
|
||||
|
Loading…
Reference in New Issue
Block a user