From d385aee524e9c9c5178a1c8c7bd34fc4efc9befc Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 23 Mar 2023 14:52:46 +0100 Subject: Added CropType.getSpeed --- .../java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt | 3 ++- .../java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt | 3 ++- src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt | 4 +--- .../at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt index d0d1f7f8d..4e7853c38 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.features.garden.GardenAPI.Companion.getSpeed import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc @@ -107,7 +108,7 @@ class CropMoneyDisplay { for ((internalName, amount) in multipliers) { val price = NEUItems.getPrice(internalName) val cropName = cropNames[internalName]!! - val speed = GardenAPI.getCropsPerSecond(cropName) + val speed = cropName.getSpeed() // No speed data for item in hand if (speed == -1) continue diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt index 29bfd84b1..d94735ba7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HyPixelData import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI.Companion.getSpeed import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round @@ -194,7 +195,7 @@ class EliteFarmingWeight { } private fun updateWeightPerSecond(crop: CropType, before: Double, after: Double, diff: Int) { - val speed = GardenAPI.cropsPerSecond[crop]!! + val speed = crop.getSpeed() if (speed != -1) { val weightDiff = (after - before) * 1000 weightPerSecond = weightDiff / diff * speed / 1000 diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index b23387010..45cb2f0ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -101,9 +101,7 @@ class GardenAPI { return -1 } - fun getCropsPerSecond(crop: CropType): Int { - return cropsPerSecond[crop]!! - } + fun CropType.getSpeed() = cropsPerSecond[this]!! fun itemNameToCropName(itemName: String): CropType? { if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 989186679..f66697e6a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData.Companion.sidebarLinesFormatted import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* +import at.hannibal2.skyhanni.features.garden.GardenAPI.Companion.getSpeed import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -234,7 +235,7 @@ class GardenVisitorFeatures { val multiplier = NEUItems.getMultiplier(internalName) val rawName = NEUItems.getItemStack(multiplier.first).name?.removeColor() ?: continue CropType.getByName(rawName)?.let { - val speed = GardenAPI.getCropsPerSecond(it) + val speed = it.getSpeed() val cropAmount = multiplier.second.toLong() * amount val formatAmount = LorenzUtils.formatInteger(cropAmount) val formatName = "§e$formatAmount§7x ${it.cropName} " -- cgit