aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt4
-rwxr-xr-xsrc/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/PowderPerHotmPerk.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/UserLuckBreakdown.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetExpTooltip.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt26
52 files changed, 145 insertions, 160 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
index 3e64d5f5a..ba3a57675 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
@@ -27,11 +27,10 @@ import at.hannibal2.skyhanni.data.OtherInventoryData
import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer
import at.hannibal2.skyhanni.utils.GuiRenderUtils
import at.hannibal2.skyhanni.utils.KeyboardManager
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.compat.GuiScreenUtils
import at.hannibal2.skyhanni.utils.compat.SkyhanniBaseScreen
import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.ScaledResolution
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.client.renderer.GlStateManager
import org.lwjgl.input.Keyboard
@@ -100,7 +99,7 @@ class GuiPositionEditor(
}
val pos = positions[displayPos]
- val location = "§7x: §e${pos.rawX}§7, y: §e${pos.rawY}§7, scale: §e${pos.scale.round(2)}"
+ val location = "§7x: §e${pos.rawX}§7, y: §e${pos.rawY}§7, scale: §e${pos.scale.roundTo(2)}"
GuiRenderUtils.drawStringCentered("§b" + pos.internalName, getScaledWidth() / 2, 18)
GuiRenderUtils.drawStringCentered(location, getScaledWidth() / 2, 28)
if (pos.canJumpToConfigOptions())
diff --git a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt
index 88daf40b9..2f516610c 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt
@@ -16,10 +16,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getExtraAttributes
@@ -236,7 +236,7 @@ object QuiverAPI {
}
}
- fun Int.asArrowPercentage() = ((this.toFloat() / MAX_ARROW_AMOUNT) * 100).round(1)
+ fun Int.asArrowPercentage() = ((this.toFloat() / MAX_ARROW_AMOUNT) * 100).roundTo(1)
fun hasBowInInventory() = hasBow
diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt b/src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt
index b9ad1251c..bc4be57a1 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.data.model
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.json.SkyHanniTypeAdapters.registerTypeAdapter
import at.hannibal2.skyhanni.utils.json.fromJson
import com.google.gson.GsonBuilder
@@ -63,7 +63,7 @@ value class Graph(
out.beginObject()
for ((node, weight) in it.neighbours) {
val id = node.id.toString()
- out.name(id).value(weight.round(2))
+ out.name(id).value(weight.roundTo(2))
}
out.endObject()
diff --git a/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt
index 2f793ff28..386167123 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt
@@ -1,8 +1,8 @@
package at.hannibal2.skyhanni.events
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import net.minecraftforge.fml.common.eventhandler.Cancelable
@Cancelable
@@ -12,9 +12,7 @@ class PlaySoundEvent(val soundName: String, val location: LorenzVec, val pitch:
val distanceToPlayer by lazy { location.distanceToPlayer() }
override fun toString(): String {
return "PlaySoundEvent(soundName='$soundName', pitch=$pitch, volume=$volume, location=${location.round(1)}, distanceToPlayer=${
- distanceToPlayer.round(
- 1
- )
+ distanceToPlayer.roundTo(1)
})"
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt
index ef296326d..7c695c7ee 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt
@@ -1,8 +1,8 @@
package at.hannibal2.skyhanni.events
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import net.minecraft.util.EnumParticleTypes
import net.minecraftforge.fml.common.eventhandler.Cancelable
@@ -26,7 +26,7 @@ class ReceiveParticleEvent(
1
)
}, longDistance=$longDistance, particleArgs=${particleArgs.contentToString()}, distanceToPlayer=${
- distanceToPlayer.round(
+ distanceToPlayer.roundTo(
1
)
})"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
index 5d056f456..957f1ecd0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
@@ -20,7 +20,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.addButton
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
-import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.NumberUtil.toRoman
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
@@ -327,7 +327,7 @@ object BestiaryData {
DisplayTypeEntry.GLOBAL_NEXT -> mob.killNeededForNextLevel
else -> 0
}
- val percentage = ((currentKill.toDouble() / killNeeded) * 100).roundToPrecision(2)
+ val percentage = ((currentKill.toDouble() / killNeeded) * 100).roundTo(2)
val suffix = if (type == DisplayTypeEntry.GLOBAL_NEXT) "§ato level ${mob.getNextLevel()}" else ""
"§7(§b${currentKill.formatNumber()}§7/§b${killNeeded.formatNumber()}§7) §a$percentage§6% $suffix"
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
index b7af2d72b..0391e40a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
@@ -34,10 +34,10 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
@@ -718,7 +718,7 @@ object DamageIndicatorManager {
if (existed > 40) {
val end = (20 * 26) - existed
val time = end.toDouble() / 20
- entityData.nameAbove = "Mania Circles: §b${time.round(1)}s"
+ entityData.nameAbove = "Mania Circles: §b${time.roundTo(1)}s"
return ""
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt
index 85d5778fe..b337d58b1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt
@@ -48,7 +48,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble
import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
-import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
@@ -154,7 +154,7 @@ object GhostCounter {
0.0 -> "0"
else -> {
val mf = (((storage?.totalMF!! / Option.TOTALDROPS.get()) + Math.ulp(1.0)) * 100) / 100
- mf.roundToPrecision(2).toString()
+ mf.roundTo(2).toString()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt
index d568fc492..36a4edfb3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt
@@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
-import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import java.io.FileReader
@@ -106,8 +106,8 @@ object GhostUtil {
)
}
- fun String.formatText(value: Double, session: Double) = this.replace("%value%", value.roundToPrecision(2).addSeparators())
- .replace("%session%", session.roundToPrecision(2).addSeparators())
+ fun String.formatText(value: Double, session: Double) = this.replace("%value%", value.roundTo(2).addSeparators())
+ .replace("%session%", session.roundTo(2).addSeparators())
.replace("&", "§")
fun String.formatBestiary(currentKill: Int, killNeeded: Int): String {
@@ -129,5 +129,5 @@ object GhostUtil {
}
private fun percent(number: Double) =
- 100.0.coerceAtMost(((number / 100_000) * 100).roundToPrecision(4)).toString()
+ 100.0.coerceAtMost(((number / 100_000) * 100).roundTo(4)).toString()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
index 34dab01e6..4074b465d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
@@ -12,8 +12,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.sorted
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -104,11 +104,11 @@ object BurrowWarpHelper {
debug?.add("warpPoint: ${warpPoint.displayName}")
val playerDistance = playerLocation.distance(target)
- debug?.add("playerDistance: ${playerDistance.round(1)}")
+ debug?.add("playerDistance: ${playerDistance.roundTo(1)}")
val warpDistance = warpPoint.distance(target)
- debug?.add("warpDistance: ${warpDistance.round(1)}")
+ debug?.add("warpDistance: ${warpDistance.roundTo(1)}")
val difference = playerDistance - warpDistance
- debug?.add("difference: ${difference.round(1)}")
+ debug?.add("difference: ${difference.roundTo(1)}")
val setWarpPoint = difference > 10
debug?.add("setWarpPoint: $setWarpPoint")
currentWarp = if (setWarpPoint) warpPoint else null
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt
index 7be0913e9..e84d93dfa 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt
@@ -22,11 +22,11 @@ import at.hannibal2.skyhanni.utils.KSerializable
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzRarity
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches
import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher
@@ -435,7 +435,7 @@ object HoppityCollectionStats {
add("§7Total Rabbits Found: §a${displayFound + displayDuplicates}")
add("")
add("§7Chocolate Per Second: §a${displayChocolatePerSecond.addSeparators()}")
- add("§7Chocolate Multiplier: §a${displayChocolateMultiplier.round(3)}")
+ add("§7Chocolate Multiplier: §a${displayChocolateMultiplier.roundTo(3)}")
}
table.add(
DisplayTableEntry(
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
index 8e9e68e16..468fecbcb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
@@ -19,10 +19,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RecalculatingValue
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
@@ -249,7 +249,7 @@ object HoppityEggLocator {
}.sortedBy { it.second }
eggLocationWeights = sortedEggs.map {
- it.second.round(3)
+ it.second.roundTo(3)
}.take(5)
val filteredEggs = sortedEggs.filter {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
index 29b92f24a..55898266e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -17,9 +17,9 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
@@ -167,7 +167,7 @@ object FarmingFortuneDisplay {
list.add(
Renderable.string(
"§6Farming Fortune§7: §e" + if (!recentlySwitchedTool && farmingFortune != -1.0) {
- farmingFortune.round(0).addSeparators()
+ farmingFortune.roundTo(0).addSeparators()
} else "§7" + (displayCrop.getLatestTrueFarmingFortune()?.addSeparators() ?: "?"),
),
)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt
index cdbb07963..ad03a7784 100755
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt
@@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.client.Minecraft
@@ -41,8 +41,8 @@ object GardenYawAndPitch {
if (!config.showAlways && lastChange.passedSince() > config.timeout.seconds) return
- val yawText = yaw.round(config.yawPrecision).toBigDecimal().toPlainString()
- val pitchText = pitch.round(config.pitchPrecision).toBigDecimal().toPlainString()
+ val yawText = yaw.roundTo(config.yawPrecision).toBigDecimal().toPlainString()
+ val pitchText = pitch.roundTo(config.pitchPrecision).toBigDecimal().toPlainString()
val displayList = listOf(
"§aYaw: §f$yawText",
"§aPitch: §f$pitchText",
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
index aee2a93f4..fa45e579d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
@@ -31,7 +31,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.NONE
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
@@ -41,6 +40,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SimpleTimeMark
@@ -338,10 +338,10 @@ object ComposterOverlay {
val multiplier = multiDropFactor * timeMultiplier
val multiplierPreview = multiDropFactorPreview * timeMultiplierPreview
val compostPerTitlePreview =
- if (multiplier != multiplierPreview) " §c➜ §e" + multiplierPreview.round(2) else ""
+ if (multiplier != multiplierPreview) " §c➜ §e" + multiplierPreview.roundTo(2) else ""
val compostPerTitle =
if (currentTimeType == TimeType.COMPOST) "Compost multiplier" else "Composts per $timeText"
- newList.addAsSingletonList(" §7$compostPerTitle: §e${multiplier.round(2)}$compostPerTitlePreview")
+ newList.addAsSingletonList(" §7$compostPerTitle: §e${multiplier.roundTo(2)}$compostPerTitlePreview")
val organicMatterPrice = getPrice(organicMatterItem)
val organicMatterFactor = organicMatterFactors[organicMatterItem]!!
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt
index 7d009629b..a2e8a859f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt
@@ -6,8 +6,8 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.DelayedRun
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -88,7 +88,7 @@ object FarmingPersonalBestGain {
val oldFF = oldCollected / collectionPerFF
val ffDiff = newFF - oldFF
- ChatUtils.chat("This is §6${ffDiff.round(2)}☘ $crop Fortune §emore than previously!")
+ ChatUtils.chat("This is §6${ffDiff.roundTo(2)}☘ $crop Fortune §emore than previously!")
}
fun isEnabled() = GardenAPI.inGarden() && config.contestPersonalBestIncreaseFF
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
index 963193c4b..5d9b7f92f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
@@ -12,8 +12,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.item.ItemStack
@@ -81,7 +81,7 @@ object JacobContestFFNeededDisplay {
addAsSingletonList("§cassuming 19.9 instead.")
} else {
if (blocksPerSecond < 15.0) {
- add(listOf("§7Your latest ", crop.icon, "§7blocks/second: §e${blocksPerSecond.round(2)}"))
+ add(listOf("§7Your latest ", crop.icon, "§7blocks/second: §e${blocksPerSecond.roundTo(2)}"))
add(listOf("§cThis is too low, showing 19.9 Blocks/second instead!"))
blocksPerSecond = 19.9
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt
index 3d4fef9a3..144abc0c2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt
@@ -6,8 +6,8 @@ import at.hannibal2.skyhanni.events.FarmingContestEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.TimeUtils.format
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -41,7 +41,7 @@ object JacobContestStatsSummary {
FarmingContestPhase.STOP -> {
val duration = startTime.passedSince()
- val blocksPerSecond = (blocksBroken.toDouble() / duration.inWholeSeconds).round(2)
+ val blocksPerSecond = (blocksBroken.toDouble() / duration.inWholeSeconds).roundTo(2)
val cropName = event.crop.cropName
ChatUtils.chat("Stats for $cropName Contest:")
val time = duration.format()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt
index 3e99c2683..bb9f9ea21 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt
@@ -11,8 +11,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.CollectionUtils.sorted
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.TimeUtils.format
import at.hannibal2.skyhanni.utils.renderables.Renderable
@@ -102,7 +102,7 @@ object JacobContestTimeNeeded {
return
}
- val speed = (ff * crop.baseDrops * bps / 100).round(1).toInt()
+ val speed = (ff * crop.baseDrops * bps / 100).roundTo(1).toInt()
renderCrop(speed, crop, averages, sorted, map)
}
@@ -174,7 +174,7 @@ object JacobContestTimeNeeded {
add("")
val latestFF = crop.getLatestTrueFarmingFortune() ?: 0.0
add("§7Latest FF: §e${(latestFF).addSeparators()}")
- val bps = crop.getBps()?.round(1) ?: 0
+ val bps = crop.getBps()?.roundTo(1) ?: 0
add("§7${addBpsTitle()}§e${bps.addSeparators()}")
addAll(lowBPSWarning)
})
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt
index aa977b65a..74c59674f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt
@@ -9,8 +9,8 @@ import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -91,7 +91,7 @@ object CropSpeedMeter {
currentCrop?.let {
val crops = it.getCounter() - startCrops[it]!!
val blocks = currentBlocks
- val cropsPerBlocks = (crops.toDouble() / blocks.toDouble()).round(3)
+ val cropsPerBlocks = (crops.toDouble() / blocks.toDouble()).roundTo(3)
val list = mutableListOf<String>()
list.add("")
@@ -101,7 +101,7 @@ object CropSpeedMeter {
list.add(" §7Crops per Block: " + cropsPerBlocks.addSeparators())
val baseDrops = it.baseDrops
- val farmingFortune = (cropsPerBlocks * 100 / baseDrops).round(3)
+ val farmingFortune = (cropsPerBlocks * 100 / baseDrops).roundTo(3)
list.add(" §7Calculated farming Fortune: §e" + farmingFortune.addSeparators())
list.add("§cOpen /cropmilestones again to recalculate!")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
index 1fa4b57e6..da461d749 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
@@ -23,8 +23,8 @@ import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.APIUtils
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.SimpleTimeMark
@@ -234,7 +234,7 @@ object FarmingWeightDisplay {
}
val totalWeight = (localWeight + weight)
- return "§e" + totalWeight.round(2).addSeparators()
+ return "§e" + totalWeight.roundTo(2).addSeparators()
}
private fun getRankGoal(): Int {
@@ -326,7 +326,7 @@ object FarmingWeightDisplay {
" §7(§b$format§7)"
} else ""
- val weightFormat = weightUntilOvertake.round(2).addSeparators()
+ val weightFormat = weightUntilOvertake.roundTo(2).addSeparators()
val text = "§e$weightFormat$timeFormat §7behind §b$nextName"
return if (showRankGoal) {
Renderable.string(text)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
index c37eb41b7..7189199a9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
@@ -26,8 +26,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addString
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.ConfigUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SimpleTimeMark
@@ -187,7 +187,7 @@ object GardenCropMilestoneDisplay {
val farmingFortune = FarmingFortuneDisplay.getCurrentFarmingFortune()
val speed = GardenCropSpeed.averageBlocksPerSecond
- val farmingFortuneSpeed = ((100.0 + farmingFortune) * crop.baseDrops * speed / 100).round(1).toInt()
+ val farmingFortuneSpeed = ((100.0 + farmingFortune) * crop.baseDrops * speed / 100).roundTo(1).toInt()
if (farmingFortuneSpeed > 0) {
crop.setSpeed(farmingFortuneSpeed)
@@ -219,7 +219,7 @@ object GardenCropMilestoneDisplay {
val hourFormat = (farmingFortuneSpeed * 60 * 60).addSeparators()
lineMap[MilestoneTextEntry.CROPS_PER_HOUR] = Renderable.string("§7Crops/Hour§8: §e$hourFormat")
- val formatBps = speed.round(config.blocksBrokenPrecision).addSeparators()
+ val formatBps = speed.roundTo(config.blocksBrokenPrecision).addSeparators()
lineMap[MilestoneTextEntry.BLOCKS_PER_SECOND] = Renderable.string("§7Blocks/Second§8: §e$formatBps")
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt
index cb63d40de..e407d0ad4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt
@@ -14,8 +14,8 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
@@ -76,7 +76,7 @@ object FarmingLaneFeatures {
if (config.distanceDisplay) {
display = buildList {
- add("§7Distance until switch: §e${currentDistance.round(1)}")
+ add("§7Distance until switch: §e${currentDistance.roundTo(1)}")
val normal = movementState == MovementState.NORMAL
val color = if (normal) "§b" else "§8"
@@ -152,7 +152,7 @@ object FarmingLaneFeatures {
private var sameSpeedCounter = 0
private fun calculateSpeed(): Boolean {
- val speed = MovementSpeedDisplay.speed.round(2)
+ val speed = MovementSpeedDisplay.speed.roundTo(2)
movementState = calculateMovementState(speed)
if (movementState != MovementState.NORMAL) return false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt
index 7a2f8d415..e0cb07073 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt
@@ -12,8 +12,8 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.indexOfFirst
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.StringUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -35,7 +35,7 @@ object GardenCropMilestoneInventory {
val tier = GardenCropMilestones.getTierForCropCount(counter, cropType, allowOverflow)
tiers.add(tier.toDouble())
}
- average = (tiers.sum() / CropType.entries.size).round(2)
+ average = (tiers.sum() / CropType.entries.size).roundTo(2)
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt
index 5ef150907..078ef1672 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt
@@ -12,12 +12,12 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
import at.hannibal2.skyhanni.utils.ItemUtils.loreCosts
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.renderables.Renderable
@@ -115,7 +115,7 @@ object SkyMartCopperPrice {
event.move(3, "garden.skyMartCopperPriceAdvancedStats", "garden.skyMart.copperPriceAdvancedStats")
event.move(3, "garden.skyMartCopperPricePos", "garden.skyMart.copperPricePos")
event.transform(32, "garden.skyMart.itemScale") {
- JsonPrimitive((it.asDouble / 1.851).round(1))
+ JsonPrimitive((it.asDouble / 1.851).roundTo(1))
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
index 3724dbc53..eebbb19e9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
@@ -14,11 +14,11 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.ItemUtils.name
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
@@ -334,7 +334,7 @@ object ChocolateFactoryDataLoader {
val itemName = item.name.removeColor()
val lore = item.getLore()
val upgradeCost = ChocolateFactoryAPI.getChocolateBuyCost(lore)
- val averageChocolate = ChocolateAmount.averageChocPerSecond().round(2)
+ val averageChocolate = ChocolateAmount.averageChocPerSecond().roundTo(2)
val isMaxed = upgradeCost == null
if (slotIndex in ChocolateFactoryAPI.rabbitSlots) {
@@ -415,8 +415,8 @@ object ChocolateFactoryDataLoader {
newAverageChocolate: Double,
isRabbit: Boolean,
) {
- val extra = (newAverageChocolate - averageChocolate).round(2)
- val effectiveCost = (upgradeCost!! / extra).round(2)
+ val extra = (newAverageChocolate - averageChocolate).roundTo(2)
+ val effectiveCost = (upgradeCost!! / extra).roundTo(2)
val upgrade = ChocolateFactoryUpgrade(slotIndex, level, upgradeCost, extra, effectiveCost, isRabbit = isRabbit)
list.add(upgrade)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
index 8973bc1e4..88ac9d474 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
@@ -3,8 +3,8 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.profileStorage
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -35,7 +35,7 @@ object ChocolateFactoryTooltip {
if (upgradeInfo.effectiveCost == null) return
- event.toolTip.add("§7Extra: §6${upgradeInfo.extraPerSecond?.round(2) ?: "N/A"} §7choc/s")
+ event.toolTip.add("§7Extra: §6${upgradeInfo.extraPerSecond?.roundTo(2) ?: "N/A"} §7choc/s")
event.toolTip.add("§7Effective Cost: §6${upgradeInfo.effectiveCost.addSeparators() ?: "N/A"}")
if (slotIndex == ChocolateFactoryAPI.timeTowerIndex) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
index de7bc8bdf..020feba76 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
@@ -2,10 +2,10 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import kotlin.math.floor
enum class ItemAbility(
@@ -106,7 +106,7 @@ enum class ItemAbility(
duration /= 100
var d = duration.toDouble()
d /= 10.0
- d.round(1).addSeparators()
+ d.roundTo(1).addSeparators()
} else {
duration /= 1000
duration++
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
index 567adb251..5748220c5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
@@ -23,8 +23,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls
@@ -168,7 +168,7 @@ object ItemAbilityCooldown {
ItemAbility.STAFF_OF_THE_VOLCANO.sound()
}
// Holy Ice
- event.soundName == "random.drink" && event.pitch.round(1) == 1.8f && event.volume == 1.0f -> {
+ event.soundName == "random.drink" && event.pitch.roundTo(1) == 1.8f && event.volume == 1.0f -> {
ItemAbility.HOLY_ICE.sound()
}
// Royal Pigeon
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt
index ec9a390ed..4415b59f5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt
@@ -17,8 +17,8 @@ import at.hannibal2.skyhanni.features.mining.MineshaftPityDisplay.PityBlock.Comp
import at.hannibal2.skyhanni.features.mining.OreType.Companion.getOreType
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.SimpleTimeMark
@@ -118,7 +118,7 @@ object MineshaftPityDisplay {
add("§7Pity Counter: §e$pityCounter")
add(
"§7Chance: " +
- "§e1§6/§e${chance.round(1)} " +
+ "§e1§6/§e${chance.roundTo(1)} " +
"§7(§b${((1.0 / chance) * 100).addSeparators()}%§7)",
)
minedBlocks.forEach {
@@ -214,7 +214,7 @@ object MineshaftPityDisplay {
MineshaftPityLine.COUNTER to Renderable.string("§3Pity Counter: §e$counterUntilPity§6/§e$MAX_COUNTER"),
MineshaftPityLine.CHANCE to Renderable.string(
"§3Chance: §e1§6/§e${
- chance.round(1).addSeparators()
+ chance.roundTo(1).addSeparators()
} §7(§b${((1.0 / chance) * 100).addSeparators()}%§7)",
),
MineshaftPityLine.NEEDED_TO_PITY to neededToPityRenderable,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/PowderPerHotmPerk.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/PowderPerHotmPerk.kt
index 58fa83753..e268beb16 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/PowderPerHotmPerk.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/PowderPerHotmPerk.kt
@@ -6,9 +6,9 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.fractionOf
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -48,7 +48,7 @@ object PowderPerHotmPerk {
private fun handlePowderSpend(perk: HotmData): String {
val currentPowderSpend = perk.calculateTotalCost(perk.rawLevel)
val maxPowderNeeded = perk.totalCostMaxLevel
- val percentage = (currentPowderSpend.fractionOf(maxPowderNeeded) * 100).round(2)
+ val percentage = (currentPowderSpend.fractionOf(maxPowderNeeded) * 100).roundTo(2)
return when (config.powderSpentDesign) {
PowderSpentDesign.NUMBER -> {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt
index 82fc73030..cb50e3c85 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt
@@ -17,7 +17,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
@@ -218,7 +218,7 @@ object FossilSolverDisplay {
}
fun nextData(slotToClick: FossilTile, correctPercentage: Double, fossilsRemaining: Int) {
- val formattedPercentage = (correctPercentage * 100).round(1)
+ val formattedPercentage = (correctPercentage * 100).roundTo(1)
possibleFossilsRemaining = fossilsRemaining
FossilSolverDisplay.slotToClick = slotToClick.toSlotIndex()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt
index d5e57d513..3c1e844a6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt
@@ -23,7 +23,7 @@ import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable
import at.hannibal2.skyhanni.utils.renderables.Renderable
@@ -164,7 +164,7 @@ object IslandAreas {
}
}
- val distance = difference.round(1)
+ val distance = difference.roundTo(1)
val text = "${coloredName}§7: §e$distance$suffix"
if (!foundCurrentArea) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt
index 50148f031..685ffa3cd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt
@@ -7,8 +7,8 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import net.minecraft.client.Minecraft
import net.minecraft.init.Blocks
@@ -59,7 +59,7 @@ object MovementSpeedDisplay {
}
usingSoulsandSpeed = movingOnSoulsand && soulsandSpeeds.size == 6
if (isEnabled()) {
- display = "Movement Speed: ${speed.round(2)}"
+ display = "Movement Speed: ${speed.roundTo(2)}"
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt
index 0a3a60295..01d84daa3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt
@@ -10,7 +10,7 @@ import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
@@ -55,7 +55,7 @@ object TpsCounter {
"§eTPS: §f(${current}s)"
} else {
val sum = tpsList.sum().toDouble()
- var tps = (sum / tpsList.size).round(1)
+ var tps = (sum / tpsList.size).roundTo(1)
if (tps > 20) tps = 20.0
val color = getColor(tps)
"§eTPS: $color$tps"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/UserLuckBreakdown.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/UserLuckBreakdown.kt
index 7f041bc27..f1fad4e63 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/UserLuckBreakdown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/UserLuckBreakdown.kt
@@ -14,10 +14,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
@@ -160,7 +160,7 @@ object UserLuckBreakdown {
skillCalcCoolDown = SimpleTimeMark.now()
calcSkillLuck()
}
- val limboLuck = storage?.limbo?.userLuck?.round(1) ?: 0.0f
+ val limboLuck = storage?.limbo?.userLuck?.roundTo(1) ?: 0.0f
when (event.slot.inventory.name) {
"Your Equipment and Stats" -> equipmentMenuTooltip(event, limboLuck)
"Your Stats Breakdown" -> statsBreakdownLoreTooltip(event, limboLuck)
@@ -270,7 +270,7 @@ object UserLuckBreakdown {
calcSkillLuck()
return when (type) {
"mainMenu" -> {
- val luckString = tryTruncateFloat(luckInput.round(2))
+ val luckString = tryTruncateFloat(luckInput.roundTo(2))
if (luckInput == 0.0f) {
arrayOf(
"§7SkyHanni User Luck is the best stat.",
@@ -293,7 +293,7 @@ object UserLuckBreakdown {
}
"limbo" -> {
- val luckString = tryTruncateFloat(luckInput.round(2))
+ val luckString = tryTruncateFloat(luckInput.roundTo(2))
arrayOf(
"§8Action",
"",
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
index 666671e9c..1c46b40d6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
@@ -8,10 +8,10 @@ import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
@@ -105,7 +105,7 @@ object LimboPlaytime {
if ((wholeMinutes % 60) == 0) {
hoursString = "$wholeHours"
} else {
- val minutes: Float = ((wholeMinutes - wholeHours * 60).toFloat() / 60).round(1)
+ val minutes: Float = ((wholeMinutes - wholeHours * 60).toFloat() / 60).roundTo(1)
hoursString = wholeHours.addSeparators()
if (findFloatDecimalPlace(minutes) != 0) {
val minutesString = minutes.toString()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt
index 62f4c4656..bfb8ce715 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt
@@ -15,7 +15,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.TimeUtils.format
@@ -116,7 +116,7 @@ object LimboTimeTracker {
if (passedSince > currentPB) {
oldPB = currentPB
storage?.personalBest = passedSince.toInt(DurationUnit.SECONDS)
- userLuck = ((storage?.personalBest ?: 0) * USER_LUCK_MULTIPLIER).round(2)
+ userLuck = ((storage?.personalBest ?: 0) * USER_LUCK_MULTIPLIER).roundTo(2)
if (onFire) userLuck *= FIRE_MULTIPLIER
ChatUtils.chat("§fYou were in Limbo for §e$duration§f! §d§lPERSONAL BEST§r§f!")
if (oldPB != 0.seconds) {
@@ -126,9 +126,9 @@ object LimboTimeTracker {
} else ChatUtils.chat("§fYou were in Limbo for §e$duration§f.")
if (userLuck > oldLuck) {
if (onFire) {
- ChatUtils.chat("§fYour §aPersonal Bests§f perk is now granting you §a+${userLuck.round(2)}§c✴ §aSkyHanni User Luck§f! ")
+ ChatUtils.chat("§fYour §aPersonal Bests§f perk is now granting you §a+${userLuck.roundTo(2)}§c✴ §aSkyHanni User Luck§f! ")
} else {
- ChatUtils.chat("§fYour §aPersonal Bests§f perk is now granting you §a+${userLuck.round(2)}✴ SkyHanni User Luck§f!")
+ ChatUtils.chat("§fYour §aPersonal Bests§f perk is now granting you §a+${userLuck.roundTo(2)}✴ SkyHanni User Luck§f!")
}
storage?.userLuck = userLuck
}
@@ -152,7 +152,7 @@ object LimboTimeTracker {
val currentPB = storage?.personalBest ?: 0
val userLuck = storage?.userLuck ?: 0f
val limboPB: Int = if (currentPB < timeInLimbo) timeInLimbo else currentPB
- var luckString = tryTruncateFloat(userLuck.round(2))
+ var luckString = tryTruncateFloat(userLuck.roundTo(2))
if (userLuck > 0) luckString = "+$luckString"
var firstMessage =
"§fYour current PB is §e${limboPB.seconds}§f, granting you §a$luckString✴ SkyHanni User Luck§f!"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetExpTooltip.kt
index 8e544a3df..e5c3179cc 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetExpTooltip.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetExpTooltip.kt
@@ -11,8 +11,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LorenzRarity
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetExp
@@ -36,7 +36,7 @@ object PetExpTooltip {
if (!KeyboardManager.isShiftKeyDown() && !config.showAlways) return
val itemStack = event.itemStack
- val petExperience = itemStack.getPetExp()?.round(1) ?: return
+ val petExperience = itemStack.getPetExp()?.roundTo(1) ?: return
val name = itemStack.name
try {
@@ -105,7 +105,7 @@ object PetExpTooltip {
val maxLevel = if (useGoldenDragonLevels) 200 else 100
val maxXp = when {
- useGoldenDragonLevels -> LEVEL_200_LEGENDARY // lvl 200 legendary
+ useGoldenDragonLevels -> LEVEL_200_LEGENDARY
petName.contains("Bingo") -> LEVEL_100_COMMON
else -> LEVEL_100_LEGENDARY
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt
index b0d4676f2..9c65a273e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt
@@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getLivingMetalProgress
import net.minecraft.item.ItemStack
@@ -39,7 +39,7 @@ object LivingMetalSuitProgress {
if (progressMap.isEmpty()) return@buildList
- val totalProgress = progressMap.values.map { it ?: 1.0 }.average().roundToPrecision(1)
+ val totalProgress = progressMap.values.map { it ?: 1.0 }.average().roundTo(1)
val formatPercentage = LorenzUtils.formatPercentage(totalProgress)
addAsSingletonList("§7Living Metal Suit Progress: ${if (isMaxed) "§a§lMAXED!" else "§a$formatPercentage"}")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt
index ccdb19fc5..c333550f6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt
@@ -11,7 +11,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -80,7 +80,7 @@ object CruxTalismanDisplay {
}
}
}
- percentValue = ((percent.toDouble() / 600) * 100).roundToPrecision(1)
+ percentValue = ((percent.toDouble() / 600) * 100).roundTo(1)
if (bonusesLine.isNotEmpty() && config.showBonuses.get()) {
addAsSingletonList("§7Bonuses:")
bonusesLine.forEach { addAsSingletonList(" $it") }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
index d1ada6a38..4fc0ccbf5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
@@ -9,8 +9,8 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled
@@ -79,7 +79,7 @@ object RiftMotesOrb {
val ageInSeconds = (System.currentTimeMillis() - orb.startTime).toDouble() / 1000
if (ageInSeconds < 0.5) continue
- val particlesPerSecond = (orb.counter.toDouble() / ageInSeconds).round(1)
+ val particlesPerSecond = (orb.counter.toDouble() / ageInSeconds).roundTo(1)
if (particlesPerSecond < 60 || particlesPerSecond > 90) continue
orb.isOrb = true
diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt
index 87228447f..a16f78b52 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt
@@ -23,7 +23,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble
import at.hannibal2.skyhanni.utils.NumberUtil.interpolate
-import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.Quad
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
@@ -441,7 +441,7 @@ object SkillProgress {
val percent = if (currentXpMax == 0L) 100F else 100F * currentXp / currentXpMax
if (config.usePercentage.get())
- append("§7(§6${percent.roundToPrecision(2)}%§7)")
+ append("§7(§6${percent.roundTo(2)}%§7)")
else {
if (currentXpMax == 0L)
append("§7(§6${currentXp.addSeparators()}§7)")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt
index 0a94f9ee8..8c1d3f618 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt
@@ -10,7 +10,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
-import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.NumberUtil.toRoman
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.StringUtils.isRoman
@@ -40,7 +40,7 @@ object SkillTooltip {
val maxReached = "§7§8Max Skill level reached!"
if (line.contains(maxReached) && overflowConfig.enableInSkillMenuTooltip) {
val progress = (skillInfo.overflowCurrentXp.toDouble() / skillInfo.overflowCurrentXpMax) * 100
- val percent = "§e${progress.roundToPrecision(1)}%"
+ val percent = "§e${progress.roundTo(1)}%"
val currentLevel = skillInfo.overflowLevel
val level = if (useRoman) currentLevel.toRoman() else currentLevel
@@ -74,7 +74,7 @@ object SkillTooltip {
val progress = have.toDouble() / need
val progressBar = StringUtils.progressBar(progress)
val nextLevel = if (useRoman) targetLevel.toRoman() else targetLevel
- val percent = "§e${(progress * 100).roundToPrecision(1)}%"
+ val percent = "§e${(progress * 100).roundTo(1)}%"
iterator.add("")
iterator.add("§7Progress to Level $nextLevel: $percent")
iterator.add("$progressBar §e${have.addSeparators()}§6/§e${need.addSeparators()}")
diff --git a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt
index 99dd9fcbf..a0ab34ede 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt
@@ -7,9 +7,9 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NumberUtil.isInt
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible
import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.toLorenzVec
@@ -187,7 +187,7 @@ object PacketTest {
}
private fun getDistance(location: LorenzVec?): Double {
- return location?.distanceToPlayer()?.round(1) ?: 0.0
+ return location?.distanceToPlayer()?.roundTo(1) ?: 0.0
}
private fun getLocation(packet: Packet<*>, entity: Entity?): LorenzVec? {
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
index c0c03b677..156ce82a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
@@ -38,7 +38,6 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzDebug
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
@@ -47,6 +46,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
@@ -324,9 +324,9 @@ object SkyHanniDebugsAndTests {
fun copyLocation(args: Array<String>) {
val location = LocationUtils.playerLocation()
- val x = (location.x + 0.001).round(1)
- val y = (location.y + 0.001).round(1)
- val z = (location.z + 0.001).round(1)
+ val x = (location.x + 0.001).roundTo(1)
+ val y = (location.y + 0.001).roundTo(1)
+ val z = (location.z + 0.001).roundTo(1)
if (args.size == 1 && args[0].equals("json", false)) {
OSUtils.copyToClipboard("\"$x:$y:$z\"")
return
@@ -576,7 +576,8 @@ object SkyHanniDebugsAndTests {
}.editCopy {
this.add(
0,
- generateSequence(scale) { it + 0.1 }.take(25).map { Renderable.string(it.round(1).toString()) }.toList(),
+ generateSequence(scale) { it + 0.1 }.take(25).map { Renderable.string(it.roundTo(1).toString()) }
+ .toList(),
)
}
config.debugItemPos.renderRenderables(
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt
index 0892d1125..69c16daeb 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt
@@ -7,8 +7,8 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
@@ -116,7 +116,7 @@ object TrackParticlesCommand {
event.drawDynamicText(key, "§7§l${particle.type}", 0.8)
event.drawDynamicText(
key.up(-0.2),
- "§7C: §e${particle.count} §7S: §a${particle.speed.round(2)}",
+ "§7C: §e${particle.count} §7S: §a${particle.speed.roundTo(2)}",
scaleMultiplier = 0.8
)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt
index 50b0c417d..1fadab62d 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt
@@ -7,8 +7,8 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.PlaySoundEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
@@ -123,7 +123,7 @@ object TrackSoundsCommand {
event.drawDynamicText(key, "§7§l${sound.soundName}", 0.8)
event.drawDynamicText(
key.up(-0.2),
- "§7P: §e${sound.pitch.round(2)} §7V: $volumeColor${sound.volume.round(2)}",
+ "§7P: §e${sound.pitch.roundTo(2)} §7V: $volumeColor${sound.volume.roundTo(2)}",
scaleMultiplier = 0.8,
)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt
index ba1081a5f..121b9cce3 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt
@@ -3,8 +3,8 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressBarConfig
import at.hannibal2.skyhanni.features.chroma.ChromaShaderManager
import at.hannibal2.skyhanni.features.chroma.ChromaType
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.fractionOf
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment
import at.hannibal2.skyhanni.utils.renderables.Renderable
import net.minecraft.client.Minecraft
@@ -204,7 +204,7 @@ object GuiRenderUtils {
scale = scale, horizontalAlign = HorizontalAlignment.LEFT,
),
Renderable.string(
- "§2${(percent * 100).round(1)}%",
+ "§2${(percent * 100).roundTo(1)}%",
scale = scale,
horizontalAlign = HorizontalAlignment.RIGHT,
),
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 1fd5419d9..cd96121c4 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.test.TestBingo
import at.hannibal2.skyhanni.utils.ChatUtils.lastButtonClicked
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow
import at.hannibal2.skyhanni.utils.StringUtils.capAtMinecraftLength
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -100,23 +101,11 @@ object LorenzUtils {
return originalMessage.stripHypixelMessage()
}
- fun Double.round(decimals: Int): Double {
- var multiplier = 1.0
- repeat(decimals) { multiplier *= 10 }
- val result = kotlin.math.round(this * multiplier) / multiplier
- val a = result.toString()
- val b = toString()
- return if (a.length > b.length) this else result
- }
+ @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(precision)"))
+ fun Double.round(decimals: Int) = this.roundTo(decimals)
- fun Float.round(decimals: Int): Float {
- var multiplier = 1.0
- repeat(decimals) { multiplier *= 10 }
- val result = kotlin.math.round(this * multiplier) / multiplier
- val a = result.toString().length
- val b = toString().length
- return if (a > b) this else result.toFloat()
- }
+ @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(precision)"))
+ fun Float.round(decimals: Int) = this.roundTo(decimals)
// TODO replace all calls with regex
@Deprecated("Do not use complicated string operations", ReplaceWith("Regex"))
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index a573ed78d..2e5748c6c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -1,6 +1,6 @@
package at.hannibal2.skyhanni.utils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.entity.Entity
import net.minecraft.network.play.server.S2APacketParticles
@@ -153,12 +153,12 @@ data class LorenzVec(
return result
}
- fun round(decimals: Int) = LorenzVec(x.round(decimals), y.round(decimals), z.round(decimals))
+ fun round(decimals: Int) = LorenzVec(x.roundTo(decimals), y.roundTo(decimals), z.roundTo(decimals))
fun roundLocationToBlock(): LorenzVec {
- val x = (x - .499999).round(0)
- val y = (y - .499999).round(0)
- val z = (z - .499999).round(0)
+ val x = (x - .499999).roundTo(0)
+ val y = (y - .499999).roundTo(0)
+ val z = (z - .499999).roundTo(0)
return LorenzVec(x, y, z)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index 4d5fe0a1d..58441ecab 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -1,13 +1,11 @@
package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import java.text.NumberFormat
import java.util.Locale
import java.util.TreeMap
import kotlin.math.pow
-import kotlin.math.roundToInt
object NumberUtil {
@@ -83,21 +81,21 @@ object NumberUtil {
* @link https://stackoverflow.com/a/22186845
* @author jpdymond
*/
- fun Double.roundToPrecision(precision: Int): Double { // TODO is this the same as LorenzUtils.round() ?
- val scale = 10.0.pow(precision).toInt()
- return (this * scale).roundToInt().toDouble() / scale
+ fun Double.roundTo(precision: Int): Double {
+ val scale = 10.0.pow(precision)
+ return kotlin.math.round(scale) / scale
}
- /**
- * This code was unmodified and taken under CC BY-SA 3.0 license
- * @link https://stackoverflow.com/a/22186845
- * @author jpdymond
- */
- fun Float.roundToPrecision(precision: Int): Float {
- val scale = 10.0.pow(precision).toInt()
- return (this * scale).roundToInt().toFloat() / scale
+ fun Float.roundTo(precision: Int): Float {
+ return toDouble().roundTo(precision).toFloat()
}
+ @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(precision)"))
+ fun Double.roundToPrecision(precision: Int) = this.roundTo(precision)
+
+ @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(precision)"))
+ fun Float.roundToPrecision(precision: Int) = this.roundTo(precision)
+
fun Number.ordinal(): String {
val long = this.toLong()
if (long % 100 in 11..13) return "th"
@@ -209,7 +207,7 @@ object NumberUtil {
fun Number.percentWithColorCode(max: Number, round: Int = 1): String {
val fraction = this.fractionOf(max)
val color = percentageColor(fraction)
- val amount = (fraction * 100.0).round(round)
+ val amount = (fraction * 100.0).roundTo(round)
return "${color.getChatColor()}$amount%"
}