diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-06-05 08:21:32 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 00:21:32 +0200 |
commit | 6a108796ed40747693277335b4d5de90c3ce7f0b (patch) | |
tree | 41424e8e809a1d7a78e8de0040d4bdff573fb8ac /src/main/java/at | |
parent | 77f1cc5d8e96ac9e0d5f4ff0aedf3a735aaf4e48 (diff) | |
download | skyhanni-6a108796ed40747693277335b4d5de90c3ce7f0b.tar.gz skyhanni-6a108796ed40747693277335b4d5de90c3ce7f0b.tar.bz2 skyhanni-6a108796ed40747693277335b4d5de90c3ce7f0b.zip |
fix (#214)
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt | 19 |
1 files changed, 10 insertions, 9 deletions
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: .* [(](?<pieces>.*)/4[)]".toPattern() + private val armorAbilityPattern = "Tiered Bonus: .* [(](?<pieces>.*)/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+(?<bonus>.*)☘".toPattern() - // todo confirm it works on Melon and Cropie armor + // todo make it work on Melon and Cropie armor val armorAbilityFortune = "§7.*§7Grants §6(?<bonus>.*)☘.*".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 |