diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-09-24 01:16:31 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-23 17:16:31 +0200 |
| commit | 2eed7efac2dab7ec54043d188d814b17052cebdd (patch) | |
| tree | 118428ce5d5ef9b2c463e9fa3b7ecc93e4913daa /src | |
| parent | f71458b10781f366d6220b662dba42abe0aa80b3 (diff) | |
| download | skyhanni-2eed7efac2dab7ec54043d188d814b17052cebdd.tar.gz skyhanni-2eed7efac2dab7ec54043d188d814b17052cebdd.tar.bz2 skyhanni-2eed7efac2dab7ec54043d188d814b17052cebdd.zip | |
Backend: Replace round and roundToPrecision with roundTo (#1931)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src')
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 |
