aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorappable <enzospiacitelli@gmail.com>2023-04-10 17:44:46 -0700
committerGitHub <noreply@github.com>2023-04-11 02:44:46 +0200
commit04cfe48dbbc58da81c8390dfb20216a7258cba3e (patch)
tree09b517607af1cb71b2207981fc13115eb6696d91 /src/main/java
parent65d8a310f7880d1acfe799dbc0c90cc9cef08610 (diff)
downloadskyhanni-04cfe48dbbc58da81c8390dfb20216a7258cba3e.tar.gz
skyhanni-04cfe48dbbc58da81c8390dfb20216a7258cba3e.tar.bz2
skyhanni-04cfe48dbbc58da81c8390dfb20216a7258cba3e.zip
Farming fortune display (#34)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java51
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt54
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/CropUpgradeUpdateEvent.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt148
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt116
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt24
10 files changed, 433 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index e5169ab86..6f586b142 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -122,6 +122,7 @@ public class SkyHanniMod {
loadModule(new TabListData());
loadModule(new RenderGuiData());
loadModule(new GardenCropMilestones());
+ loadModule(new GardenCropUpgrades());
loadModule(new OwnInventoryData());
loadModule(new ToolTipData());
loadModule(new GuiEditManager());
@@ -244,6 +245,8 @@ public class SkyHanniMod {
loadModule(new PasteIntoSigns());
loadModule(new EstimatedItemValue());
loadModule(new ComposterInventoryNumbers());
+ loadModule(new FarmingFortuneDisplay());
+ loadModule(new ToolTooltipTweaks());
Commands.INSTANCE.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
index 336e83755..1e01135ce 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -758,6 +758,57 @@ public class Garden {
public boolean composterInventoryNumbers = true;
@Expose
+ @ConfigOption(name = "True Farming Fortune", desc = "")
+ @ConfigEditorAccordion(id = 18)
+ public boolean farmingFortune = false;
+
+ @Expose
+ @ConfigOption(
+ name = "FF Display",
+ desc = "Displays current farming fortune, including crop-specific bonuses."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 18)
+ public boolean farmingFortuneDisplay = true;
+
+ @Expose
+ public Position farmingFortunePos = new Position(-375, -200, false, true);
+
+ @Expose
+ @ConfigOption(name = "Tooltip Tweaks", desc = "")
+ @ConfigEditorAccordion(id = 20)
+ public boolean tooltipTweaks = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Compact Descriptions",
+ desc = "Hides redundant parts of reforge descriptions, generic counter description, and Farmhand perk explanation."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 20)
+ public boolean compactToolTooltips = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Breakdown Hotkey",
+ desc = "When the keybind is pressed, show a breakdown of all fortune sources on a tool."
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_LSHIFT)
+ @ConfigAccordionId(id = 20)
+ public int fortuneTooltipKeybind = Keyboard.KEY_LSHIFT;
+
+ @Expose
+ @ConfigOption(
+ name = "Tooltip Format",
+ desc = "Show crop-specific farming fortune in tooltip.\n" +
+ "§fShow: §7Crop-specific fortune indicated as §6[+196]\n" +
+ "§fReplace: §7Edits the total fortune to include crop-specific fortune."
+ )
+ @ConfigEditorDropdown(values = {"Default", "Show", "Replace"})
+ @ConfigAccordionId(id = 20)
+ public int cropTooltipFortune = 1;
+
+ @Expose
@ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.")
@ConfigEditorBoolean
public boolean plotPrice = true;
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java
index bc898c818..1aa26dd72 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java
@@ -38,6 +38,9 @@ public class Hidden {
public Map<CropType, Long> gardenCropCounter = new HashMap<>();
@Expose
+ public Map<CropType, Integer> gardenCropUpgrades = new HashMap<>();
+
+ @Expose
public Map<CropType, Integer> gardenCropsPerSecond = new HashMap<>();
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt
new file mode 100644
index 000000000..c9bf25047
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt
@@ -0,0 +1,54 @@
+package at.hannibal2.skyhanni.data
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.CropUpgradeUpdateEvent
+import at.hannibal2.skyhanni.events.InventoryOpenEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.features.garden.CropType
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import io.github.moulberry.notenoughupdates.util.stripControlCodes
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class GardenCropUpgrades {
+ private val tierPattern = "§7Current Tier: §[0-9a-e](\\d)§7/§a9".toRegex()
+ private val chatUpgradePattern = " {2}§r§6§lCROP UPGRADE §e§f([\\w ]+)§7 #(\\d)".toRegex()
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ chatUpgradePattern.matchEntire(event.message)?.groups?.let { matches ->
+ val crop = CropType.getByItemName(matches[1]!!.value) ?: return
+ val level = matches[2]!!.value.toInt()
+ crop.setUpgradeLevel(level)
+ }
+ CropUpgradeUpdateEvent().postAndCatch()
+ }
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryOpenEvent) {
+ if (event.inventoryName != "Crop Upgrades") return
+ event.inventoryItems.forEach { (_, item) ->
+ val crop = item.name?.stripControlCodes()?.let {
+ CropType.getByName(it)
+ } ?: return@forEach
+ val level = item.getLore().firstNotNullOfOrNull {
+ tierPattern.matchEntire(it)?.groups?.get(1)?.value?.toIntOrNull()
+ } ?: return@forEach
+ crop.setUpgradeLevel(level)
+ }
+ CropUpgradeUpdateEvent().postAndCatch()
+ }
+
+ companion object {
+ private val cropUpgrades: MutableMap<CropType, Int> get() =
+ SkyHanniMod.feature.hidden.gardenCropUpgrades
+
+ fun CropType.getUpgradeLevel() = cropUpgrades[this]
+
+ fun CropType.setUpgradeLevel(level: Int) {
+ cropUpgrades[this] = level
+ }
+
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/CropUpgradeUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/CropUpgradeUpdateEvent.kt
new file mode 100644
index 000000000..554cbdb8d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/CropUpgradeUpdateEvent.kt
@@ -0,0 +1,3 @@
+package at.hannibal2.skyhanni.events
+
+class CropUpgradeUpdateEvent: LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
index d83399c77..d8c05dff0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.garden
+import net.minecraft.block.state.IBlockState
import net.minecraft.init.Blocks
import net.minecraft.init.Items
import net.minecraft.item.EnumDyeColor
@@ -33,5 +34,32 @@ enum class CropType(val cropName: String, val toolName: String, iconSupplier: ()
}
return getByName(itemName)
}
+
+ fun getByBlock(blockState: IBlockState): CropType? {
+ return when (blockState.block) {
+ Blocks.wheat -> WHEAT
+ Blocks.carrots -> CARROT
+ Blocks.potatoes -> POTATO
+ Blocks.pumpkin -> PUMPKIN
+ Blocks.reeds -> SUGAR_CANE
+ Blocks.melon_block -> MELON
+ Blocks.cactus -> CACTUS
+ Blocks.cocoa -> COCOA_BEANS
+ Blocks.red_mushroom -> MUSHROOM
+ Blocks.brown_mushroom -> MUSHROOM
+ Blocks.nether_wart -> NETHER_WART
+ else -> null
+ }
+ }
+
+ fun CropType.getTurboCrop(): String {
+ return when (this) {
+ COCOA_BEANS -> "turbo_coco"
+ SUGAR_CANE -> "turbo_cane"
+ NETHER_WART -> "turbo_warts"
+ MUSHROOM -> "turbo_mushrooms"
+ else -> "turbo_${this.cropName.lowercase()}"
+ }
+ }
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
new file mode 100644
index 000000000..781691546
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -0,0 +1,148 @@
+package at.hannibal2.skyhanni.features.garden
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.GardenCropMilestones
+import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
+import at.hannibal2.skyhanni.data.GardenCropUpgrades.Companion.getUpgradeLevel
+import at.hannibal2.skyhanni.events.*
+import at.hannibal2.skyhanni.features.garden.CropType.Companion.getTurboCrop
+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.RenderUtils.renderSingleLineWithItems
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCounter
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import kotlin.math.floor
+import kotlin.math.log10
+
+class FarmingFortuneDisplay {
+ private val config get() = SkyHanniMod.feature.garden
+
+ private val tabFortunePattern = " Farming Fortune: §r§6☘(\\d+)".toRegex()
+
+ private var display = listOf<Any>()
+ private var currentCrop: CropType? = null
+
+ private var tabFortune: Double = 0.0
+ private var toolFortune: Double = 0.0
+ private val upgradeFortune: Double? get() = currentCrop?.getUpgradeLevel()?.let { it * 5.0 }
+
+ private var lastToolSwitch: Long = 0
+ private var ticks: Int = 0
+
+ @SubscribeEvent
+ fun onTabListUpdate(event: TabListUpdateEvent) {
+ if (!GardenAPI.inGarden()) return
+ tabFortune = event.tabList.firstNotNullOfOrNull {
+ tabFortunePattern.matchEntire(it)?.groups?.get(1)?.value?.toDoubleOrNull()
+ } ?: tabFortune
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ fun onInventoryUpdate(event: OwnInventorItemUpdateEvent) {
+ if (!GardenAPI.inGarden()) return
+ if (GardenAPI.getCropTypeFromItem(event.itemStack) == null) return
+ updateToolFortune(event.itemStack)
+ }
+
+ @SubscribeEvent
+ fun onBlockBreak(event: BlockClickEvent) {
+ if (!GardenAPI.inGarden()) return
+ val cropBroken = CropType.getByBlock(event.getBlockState) ?: return
+ if (cropBroken != currentCrop) {
+ currentCrop = cropBroken
+ updateToolFortune(event.itemInHand)
+ }
+ }
+
+ @SubscribeEvent
+ fun onGardenToolChange(event: GardenToolChangeEvent) {
+ lastToolSwitch = System.currentTimeMillis()
+ val heldTool = event.toolItem
+ currentCrop = event.crop ?: currentCrop
+ updateToolFortune(heldTool)
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!isEnabled()) return
+ config.farmingFortunePos.renderSingleLineWithItems(display, posLabel = "Farming Fortune")
+ }
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (event.phase != TickEvent.Phase.START || ticks++ % 5 != 0) return
+ val displayCrop = currentCrop ?: return
+ val updatedDisplay = mutableListOf<Any>()
+ GardenAPI.addGardenCropToList(displayCrop, updatedDisplay)
+ val recentlySwitchedTool = System.currentTimeMillis() < lastToolSwitch + 1000
+ val displayString = upgradeFortune?.let {
+ "§6Farming Fortune§7: §e" + if (!recentlySwitchedTool) {
+ val totalFortune = it + tabFortune + toolFortune
+ LorenzUtils.formatDouble(totalFortune, 0)
+ } else "?"
+ } ?: "§cOpen §e/cropupgrades§c to use!"
+ updatedDisplay.add(displayString)
+ display = updatedDisplay
+ }
+
+ private fun updateToolFortune(tool: ItemStack?) {
+ val cropMatchesTool = currentCrop == GardenAPI.getCropTypeFromItem(tool)
+ val toolCounterFortune = if (cropMatchesTool) {
+ getToolFortune(tool) + getCounterFortune(tool) + getCollectionFortune(tool)
+ } else 0.0
+ toolFortune = toolCounterFortune + getTurboCropFortune(tool, currentCrop) + getDedicationFortune(tool, currentCrop)
+ }
+
+ private fun isEnabled(): Boolean = GardenAPI.inGarden() && config.farmingFortuneDisplay
+
+ companion object {
+ private val collectionPattern = "§7You have §6\\+([\\d]{1,3})☘ Farming Fortune".toRegex()
+
+ fun getToolFortune(tool: ItemStack?): Double {
+ val internalName = tool?.getInternalName() ?: return 0.0
+ return if (internalName.startsWith("THEORETICAL_HOE")) {
+ listOf(10.0, 25.0, 50.0)[internalName.last().digitToInt() - 1]
+ } else when (internalName) {
+ "FUNGI_CUTTER" -> 30.0
+ "COCO_CHOPPER" -> 20.0
+ else -> 0.0
+ }
+ }
+
+ fun getTurboCropFortune(tool: ItemStack?, cropType: CropType?): Double {
+ val crop = cropType ?: return 0.0
+ return tool?.getEnchantments()?.get(crop.getTurboCrop())?.let { it * 5.0 } ?: 0.0
+ }
+
+ fun getCollectionFortune(tool: ItemStack?): Double {
+ val lore = tool?.getLore() ?: return 0.0
+ var hasCollectionAbility = false
+ return lore.firstNotNullOfOrNull {
+ if (hasCollectionAbility || it == "§6Collection Analysis") {
+ hasCollectionAbility = true
+ collectionPattern.matchEntire(it)?.groups?.get(1)?.value?.toDoubleOrNull()
+ } else null
+ } ?: 0.0
+ }
+
+ fun getCounterFortune(tool: ItemStack?): Double {
+ val counter = tool?.getCounter() ?: return 0.0
+ val digits = floor(log10(counter.toDouble()))
+ return (16 * digits - 48).takeIf { it > 0.0 } ?: 0.0
+ }
+
+ fun getDedicationFortune(tool: ItemStack?, cropType: CropType?): Double {
+ val dedicationLevel = tool?.getEnchantments()?.get("dedication") ?: 0
+ val dedicationMultiplier = listOf(0.0, 0.5, 0.75, 1.0, 2.0)[dedicationLevel]
+ val cropMilestone = GardenCropMilestones.getTierForCrops(
+ cropType?.getCounter() ?: 0
+ )
+ return dedicationMultiplier * cropMilestone
+ }
+ }
+} \ No newline at end of file
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 534c88ac4..086c31d66 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -6,6 +6,8 @@ import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCounter
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCultivatingCount
import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
import net.minecraft.network.play.client.C09PacketHeldItemChange
@@ -91,23 +93,7 @@ class GardenAPI {
return CropType.values().firstOrNull { internalName.startsWith(it.toolName) }
}
- fun readCounter(itemStack: ItemStack): Int {
- if (itemStack.hasTagCompound()) {
- val tag = itemStack.tagCompound
- if (tag.hasKey("ExtraAttributes", 10)) {
- val ea = tag.getCompoundTag("ExtraAttributes")
- if (ea.hasKey("mined_crops", 99)) {
- return ea.getInteger("mined_crops")
- }
-
- // only using cultivating when no crops counter is there
- if (ea.hasKey("farmed_cultivating", 99)) {
- return ea.getInteger("farmed_cultivating")
- }
- }
- }
- return -1
- }
+ fun readCounter(itemStack: ItemStack): Int = itemStack.getCounter() ?: itemStack.getCultivatingCount() ?: -1
fun CropType.getSpeed(): Int {
val speed = cropsPerSecond[this]
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
new file mode 100644
index 000000000..4368ac0f9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
@@ -0,0 +1,116 @@
+package at.hannibal2.skyhanni.features.garden
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummiesCount
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName
+import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import org.lwjgl.input.Keyboard
+import java.text.DecimalFormat
+import kotlin.math.roundToInt
+
+class ToolTooltipTweaks {
+ private val config get() = SkyHanniMod.feature.garden
+ private val tooltipFortunePattern = "^§5§o§7Farming Fortune: §a\\+([\\d.]+)(?: §2\\(\\+\\d\\))?(?: §9\\(\\+(\\d+)\\))\$".toRegex()
+ private val counterStartLine = setOf("§5§o§6Logarithmic Counter", "§5§o§6Collection Analysis")
+
+ private val reforgeEndLine = setOf("§5§o", "§5§o§7chance for multiple crops.")
+
+ @SubscribeEvent
+ fun onTooltip(event: LorenzToolTipEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ val crop = GardenAPI.getCropTypeFromItem(event.itemStack) ?: return
+ val toolFortune = FarmingFortuneDisplay.getToolFortune(event.itemStack)
+ val counterFortune = FarmingFortuneDisplay.getCounterFortune(event.itemStack)
+ val collectionFortune = FarmingFortuneDisplay.getCollectionFortune(event.itemStack)
+ val turboCropFortune = FarmingFortuneDisplay.getTurboCropFortune(event.itemStack, crop)
+ val dedicationFortune = FarmingFortuneDisplay.getDedicationFortune(event.itemStack, crop)
+
+ val reforgeName = event.itemStack.getReforgeName()?.firstLetterUppercase()
+ val enchantments = event.itemStack.getEnchantments()
+ val sunderFortune = (enchantments["sunder"] ?: 0) * 12.5
+ val harvestingFortune = (enchantments["harvesting"] ?: 0) * 12.5
+ val cultivatingFortune = (enchantments["cultivating"] ?: 0).toDouble()
+
+ val ffdFortune = event.itemStack.getFarmingForDummiesCount().toDouble()
+ val cropFortune = (toolFortune + counterFortune + collectionFortune + turboCropFortune + dedicationFortune)
+ val iterator = event.toolTip.listIterator()
+
+ var removingFarmhandDescription = false
+ var removingCounterDescription = false
+ var removingReforgeDescription = false
+
+ for (line in iterator) {
+ val match = tooltipFortunePattern.matchEntire(line)?.groups
+ if (match != null) {
+ val displayedFortune = match[1]!!.value.toDouble()
+ val reforgeFortune = match[2]!!.value.toDouble()
+ val totalFortune = displayedFortune + cropFortune
+
+ val ffdString = if (ffdFortune != 0.0) " §2(+${ffdFortune.formatStat()})" else ""
+ val reforgeString = if (reforgeFortune != 0.0) " §9(+${reforgeFortune.formatStat()})" else ""
+ val cropString = if (cropFortune != 0.0) " §6[+${cropFortune.roundToInt()}]" else ""
+
+ val fortuneLine = when (config.cropTooltipFortune) {
+ 0 -> "§7Farming Fortune: §a+${displayedFortune.formatStat()}$ffdString$reforgeString"
+ 1 -> "§7Farming Fortune: §a+${displayedFortune.formatStat()}$ffdString$reforgeString$cropString"
+ else -> "§7Farming Fortune: §a+${totalFortune.formatStat()}$ffdString$reforgeString$cropString"
+ }
+ iterator.set(fortuneLine)
+
+ if (Keyboard.isKeyDown(config.fortuneTooltipKeybind)) {
+ iterator.addStat(" §7Sunder: §a+", sunderFortune)
+ iterator.addStat(" §7Harvesting: §a+", harvestingFortune)
+ iterator.addStat(" §7Cultivating: §a+", cultivatingFortune)
+ iterator.addStat(" §7Farming for Dummies: §2+", ffdFortune)
+ iterator.addStat(" §7$reforgeName: §9+", reforgeFortune)
+ iterator.addStat(" §7Tool: §6+", toolFortune)
+ iterator.addStat(" §7Counter: §6+", counterFortune)
+ iterator.addStat(" §7Collection: §6+", collectionFortune)
+ iterator.addStat(" §7Dedication: §6+", dedicationFortune)
+ iterator.addStat(" §7Turbo-Crop: §6+", turboCropFortune)
+ }
+ }
+ // Beware, dubious control flow beyond these lines
+ if (config.compactToolTooltips) {
+ if (line.startsWith("§5§o§7§8Bonus ")) removingFarmhandDescription = true
+ if (removingFarmhandDescription) {
+ iterator.remove()
+ removingFarmhandDescription = line != "§5§o"
+ }
+
+ if (removingCounterDescription && !line.startsWith("§5§o§7You have")) {
+ iterator.remove()
+ } else {
+ removingCounterDescription = false
+ }
+ if (counterStartLine.contains(line)) removingCounterDescription = true
+
+ if (line == "§5§o§9Blessed Bonus") removingReforgeDescription = true
+ if (removingReforgeDescription ) {
+ iterator.remove()
+ removingReforgeDescription = !reforgeEndLine.contains(line)
+ }
+ if (line == "§5§o§9Bountiful Bonus") removingReforgeDescription = true
+ }
+
+ }
+ }
+
+ companion object {
+ private fun Double.formatStat(): String {
+ val formatter = DecimalFormat("0.##")
+ return formatter.format(this)
+ }
+
+
+ private fun MutableListIterator<String>.addStat(description: String, value: Double) {
+ if (value != 0.0) {
+ this.add("$description${value.formatStat()}")
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
index 15bd4ff0b..a7e97bb0e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
@@ -31,6 +31,30 @@ object SkyBlockItemModifierUtils {
return 0
}
+ fun ItemStack.getCultivatingCount(): Int? {
+ for (tags in tagCompound.keySet) {
+ if (tags != "ExtraAttributes") continue
+ val extraAttributes = tagCompound.getCompoundTag(tags)
+ for (attributes in extraAttributes.keySet) {
+ if (attributes != "farmed_cultivating") continue
+ return extraAttributes.getInteger(attributes)
+ }
+ }
+ return null
+ }
+
+ fun ItemStack.getCounter(): Int? {
+ for (tags in tagCompound.keySet) {
+ if (tags != "ExtraAttributes") continue
+ val extraAttributes = tagCompound.getCompoundTag(tags)
+ for (attributes in extraAttributes.keySet) {
+ if (attributes != "mined_crops") continue
+ return extraAttributes.getInteger(attributes)
+ }
+ }
+ return null
+ }
+
fun ItemStack.getSilexCount(): Int {
var silexTier = 0
for ((name, amount) in getEnchantments()) {