From 6a108796ed40747693277335b4d5de90c3ce7f0b Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Mon, 5 Jun 2023 08:21:32 +1000 Subject: fix (#214) --- .../skyhanni/features/garden/FarmingFortuneDisplay.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/main/java/at/hannibal2') 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 555af2d4f..fb6e76bb0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummiesCount import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -151,7 +152,7 @@ class FarmingFortuneDisplay { private val collectionPattern = "§7You have §6\\+([\\d]{1,3})☘ Farming Fortune".toRegex() private val tooltipFortunePattern = "^§7Farming Fortune: §a\\+([\\d.]+)(?: §2\\(\\+\\d\\))?(?: §9\\(\\+(\\d+)\\))?$".toRegex() - private val armorAbilityPattern = "§6Tiered Bonus: .* [(](?.*)/4[)]".toPattern() + private val armorAbilityPattern = "Tiered Bonus: .* [(](?.*)/4[)]".toPattern() var displayedFortune = 0.0 var reforgeFortune = 0.0 @@ -207,23 +208,23 @@ class FarmingFortuneDisplay { fun getHarvestingFortune(tool: ItemStack?): Double { return (tool?.getEnchantments()?.get("harvesting") ?: 0) * 12.5 } fun getCultivatingFortune(tool: ItemStack?): Double { return (tool?.getEnchantments()?.get("cultivating") ?: 0).toDouble()} - fun getAbilityFortune(tool: ItemStack?): Double { + fun getAbilityFortune(item: ItemStack?): Double { val lotusAbilityPattern = "§7Piece Bonus: §6+(?.*)☘".toPattern() - // todo confirm it works on Melon and Cropie armor + // todo make it work on Melon and Cropie armor val armorAbilityFortune = "§7.*§7Grants §6(?.*)☘.*".toPattern() - var pieces = 0.0 - for (line in tool?.getLore()!!) { - if (tool.getInternalName().contains("LOTUS")) { + var pieces = 0 + for (line in item?.getLore()!!) { + if (item.getInternalName().contains("LOTUS")) { lotusAbilityPattern.matchMatcher(line) { return group("bonus").toDouble() } } - armorAbilityPattern.matchMatcher(line) { - pieces = group("pieces").toDouble() + armorAbilityPattern.matchMatcher(line.removeColor()) { + pieces = group("pieces").toInt() } armorAbilityFortune.matchMatcher(line) { - return group("bonus").toDouble() / pieces + return if (pieces < 2) 0.0 else group("bonus").toDouble() / pieces } } return 0.0 -- cgit