summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorappable <enzospiacitelli@gmail.com>2023-04-12 06:09:48 -0700
committerGitHub <noreply@github.com>2023-04-12 15:09:48 +0200
commit6a4663673cb244fb265bb08f96165d4929e72f0c (patch)
tree9840d09dd34f4df40382574868d568373e3ee84d /src/main/java/at/hannibal2/skyhanni/features
parentd5dbe653bb865e85d0f433313ab11e21efdaed39 (diff)
downloadskyhanni-6a4663673cb244fb265bb08f96165d4929e72f0c.tar.gz
skyhanni-6a4663673cb244fb265bb08f96165d4929e72f0c.tar.bz2
skyhanni-6a4663673cb244fb265bb08f96165d4929e72f0c.zip
Farming fortune accessory support (#37)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt63
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt2
3 files changed, 72 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt
new file mode 100644
index 000000000..441453ded
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt
@@ -0,0 +1,21 @@
+package at.hannibal2.skyhanni.features.garden
+
+enum class CropAccessory(val internalName: String, private val affectedCrops: Set<CropType>, private val fortune: Double) {
+ NONE("NONE", emptySet(), 0.0),
+ CROPIE("CROPIE_TALISMAN", setOf(CropType.WHEAT, CropType.POTATO, CropType.CARROT), 10.0),
+ SQUASH(
+ "SQUASH_RING",
+ setOf(CropType.WHEAT, CropType.POTATO, CropType.CARROT, CropType.COCOA_BEANS, CropType.MELON, CropType.PUMPKIN),
+ 20.0
+ ),
+ FERMENTO("FERMENTO_ARTIFACT", CropType.values().toSet(), 30.0),
+ ;
+
+ fun getFortune(cropType: CropType): Double {
+ return if (this.affectedCrops.contains(cropType)) this.fortune else 0.0
+ }
+
+ companion object {
+ fun getByName(internalName: String) = values().firstOrNull { it.internalName == internalName }
+ }
+} \ 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
index a838eecc5..60d70e691 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.CropAccessoryData
import at.hannibal2.skyhanni.data.GardenCropMilestones
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
import at.hannibal2.skyhanni.data.GardenCropUpgrades.Companion.getUpgradeLevel
@@ -12,7 +13,9 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI.Companion.getCropType
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.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter
import net.minecraft.item.ItemStack
@@ -27,12 +30,18 @@ class FarmingFortuneDisplay {
private val tabFortunePattern = " Farming Fortune: §r§6☘(\\d+)".toRegex()
- private var display = listOf<Any>()
+ private var display = listOf<List<Any>>()
+ private var accessoryProgressDisplay = ""
private var currentCrop: CropType? = null
private var tabFortune: Double = 0.0
private var toolFortune: Double = 0.0
+ private val baseFortune: Double get() = if (config.farmingFortuneDropMultiplier) 100.0 else 0.0
private val upgradeFortune: Double? get() = currentCrop?.getUpgradeLevel()?.let { it * 5.0 }
+ private val accessoryFortune: Double?
+ get() = currentCrop?.let {
+ CropAccessoryData.cropAccessory?.getFortune(it)
+ }
private var lastToolSwitch: Long = 0
private var ticks: Int = 0
@@ -73,23 +82,47 @@ class FarmingFortuneDisplay {
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
if (!isEnabled()) return
- config.farmingFortunePos.renderSingleLineWithItems(display, posLabel = "True Farming Fortune")
+ config.farmingFortunePos.renderStringsAndItems(display, posLabel = "True Farming Fortune")
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.ChestBackgroundRenderEvent) {
+ if (!isEnabled()) return
+ if (!CropAccessoryData.isLoadingAccessories) return
+ SkyHanniMod.feature.misc.inventoryLoadPos.renderString(accessoryProgressDisplay, posLabel = "Load Accessory Bags")
}
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START || ticks++ % 5 != 0) return
val displayCrop = currentCrop ?: return
- val updatedDisplay = mutableListOf<Any>()
- updatedDisplay.addCropIcon(displayCrop)
- 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)
+
+ val updatedDisplay = mutableListOf<List<Any>>()
+ updatedDisplay.add(mutableListOf<Any>().also {
+ it.addCropIcon(displayCrop)
+ val recentlySwitchedTool = System.currentTimeMillis() < lastToolSwitch + 1000
+ it.add(
+ "§6Farming Fortune§7: §e" + if (!recentlySwitchedTool) {
+ val upgradeFortune = upgradeFortune ?: 0.0
+ val accessoryFortune = accessoryFortune ?: 0.0
+ val totalFortune = baseFortune + upgradeFortune + tabFortune + toolFortune + accessoryFortune
+ LorenzUtils.formatDouble(totalFortune, 0)
+ } else "?")
+ })
+
+ if (this.upgradeFortune == null) {
+ updatedDisplay.addAsSingletonList("§cOpen §e/cropupgrades§c for more exact data!")
+ }
+ if (accessoryFortune == null) {
+ updatedDisplay.addAsSingletonList("§cOpen Accessory Bag for more exact data!")
+ if (CropAccessoryData.isLoadingAccessories) {
+ accessoryProgressDisplay =
+ "§e${CropAccessoryData.pagesLoaded}/${CropAccessoryData.accessoryBagPageCount} pages viewed"
+ }
+ } else {
+ accessoryProgressDisplay = ""
+ }
+
display = updatedDisplay
}
@@ -104,9 +137,11 @@ class FarmingFortuneDisplay {
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")) {
@@ -148,5 +183,7 @@ class FarmingFortuneDisplay {
)
return dedicationMultiplier * cropMilestone
}
+
+
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index 398b6818f..e056ba510 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -218,7 +218,7 @@ class GardenNextJacobContest {
if (!inCalendar) return
if (display.isNotEmpty()) {
- config.nextJacobContestPos.renderSingleLineWithItems(display, posLabel = "Garden Next Jacob Contest")
+ SkyHanniMod.feature.misc.inventoryLoadPos.renderSingleLineWithItems(display, posLabel = "Load SkyBlock Calendar")
}
}