aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-12 21:13:43 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-12 21:13:43 +0100
commit3174b0cf96a4bb4f31c8c94a6d604e580639a3e3 (patch)
tree101fda786436982d1a9e48c7cfae2e899458767c /src/main/java/at/hannibal2
parenta6294dbea249c77f889c068f429e21792c7ce2ea (diff)
downloadskyhanni-3174b0cf96a4bb4f31c8c94a6d604e580639a3e3.tar.gz
skyhanni-3174b0cf96a4bb4f31c8c94a6d604e580639a3e3.tar.bz2
skyhanni-3174b0cf96a4bb4f31c8c94a6d604e580639a3e3.zip
NumberFormat optimizations
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt6
4 files changed, 8 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
index 5b8bc369d..729c4f85b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
@@ -649,7 +649,7 @@ class DamageIndicatorManager {
else -> {
LorenzUtils.error(
"Unexpected health of thorn in f4! (${
- LorenzUtils.formatDouble(realHealth.toDouble())
+ LorenzUtils.formatInteger(realHealth)
})"
)
return null
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
index 3b5b7834c..a8dda617d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
@@ -130,8 +130,8 @@ class EliteFarmingWeight {
}
}
- val totalWeight = (cropWeight + bonusWeight).round(2)
- return "§e" + LorenzUtils.formatDouble(totalWeight)
+ val totalWeight = (cropWeight + bonusWeight)
+ return "§e" + LorenzUtils.formatDouble(totalWeight, 2)
}
private fun isEnabled() = GardenAPI.inGarden() && config.eliteFarmingWeightDisplay
diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
index 7251facb1..ea1ac0a82 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
@@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.PlaySoundEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.utils.*
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.MinecraftForge
@@ -106,9 +105,9 @@ class LorenzTest {
fun copyLocation() {
val location = LocationUtils.playerLocation()
- val x = LorenzUtils.formatDouble(location.x.round(1), "0.0")
- val y = LorenzUtils.formatDouble(location.y.round(1), "0.0")
- val z = LorenzUtils.formatDouble(location.z.round(1), "0.0")
+ val x = LorenzUtils.formatDouble(location.x)
+ val y = LorenzUtils.formatDouble(location.y)
+ val z = LorenzUtils.formatDouble(location.z)
OSUtils.copyToClipboard("LorenzVec($x, $y, $z)")
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 91430d923..b85250841 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -121,10 +121,8 @@ object LorenzUtils {
fun formatInteger(l: Long): String = NumberFormat.getIntegerInstance().format(l)
- fun formatDouble(d: Double, format: String?): String =
- NumberFormat.getNumberInstance().format(d)
-
- fun formatDouble(d: Double): String = formatDouble(d, "#,##0.0")
+ fun formatDouble(d: Double, round: Int = 1): String =
+ NumberFormat.getNumberInstance().format(d.round(round))
fun consoleLog(text: String) {
SkyHanniMod.consoleLog(text)