diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
5 files changed, 139 insertions, 52 deletions
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 2c6ad50bb..5244aac76 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -801,7 +801,7 @@ public class Garden { @Expose @ConfigOption(name = "Show money per Hour", desc = "Displays the money per hour YOU get with YOUR crop/minute value when selling the item to bazaar. " + - "Supports Bountiful and Mushroom Cow Perk.") + "Supports Bountiful, Mushroom Cow Perk and Dicer drops. Thier toggles are below.") @ConfigEditorBoolean @ConfigAccordionId(id = 13) public boolean moneyPerHourDisplay = true; @@ -881,6 +881,30 @@ public class Garden { @Expose @ConfigOption( + name = "Include Bountiful", + desc = "Includes the coins from bountiful in the calculation.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 13) + public boolean moneyPerHourBountiful = true; + + @Expose + @ConfigOption( + name = "Include Mooshroom Cow", + desc = "Includes the coins you get from selling the mushrooms from your mooshroom cow pet.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 13) + public boolean moneyPerHourMooshroom = true; + + @Expose + @ConfigOption( + name = "Include Dicer Drops", + desc = "Includes the average coins/hr from your melon or pumpkin dicer.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 13) + public boolean moneyPerHourDicer = true; + + @Expose + @ConfigOption( name = "Hide Title", desc = "Hides the first line of 'Money Per Hour' entirely.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index f72bf42cc..730306c6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList @@ -30,7 +31,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object CropMoneyDisplay { var multipliers = mapOf<String, Int>() - var showCalculation = false + private var showCalculation = false + fun toggleShowCalculation() { showCalculation = !showCalculation @@ -105,11 +107,12 @@ object CropMoneyDisplay { } var extraMushroomCowPerk = 0.0 + var extraDicerDrops = 0.0 GardenAPI.getCurrentlyFarmedCrop()?.let { val reforgeName = InventoryUtils.getItemInHand()?.getReforgeName() toolHasBountiful?.put(it, reforgeName == "bountiful") - if (GardenAPI.mushroomCowPet && it != CropType.MUSHROOM) { + if (GardenAPI.mushroomCowPet && it != CropType.MUSHROOM && config.moneyPerHourMooshroom) { val (redPrice, brownPrice) = if (LorenzUtils.noTradeMode) { val redPrice = (BazaarApi.getBazaarDataByInternalName("ENCHANTED_RED_MUSHROOM")?.npcPrice ?: 160.0) / 160 val brownPrice = (BazaarApi.getBazaarDataByInternalName("ENCHANTED_BROWN_MUSHROOM")?.npcPrice ?: 160.0) / 160 @@ -121,9 +124,26 @@ object CropMoneyDisplay { } val mushroomPrice = (redPrice + brownPrice) / 2 - val perSecond = 20.0 * it.multiplier * mushroomPrice + val perSecond = GardenCropSpeed.getRecentBPS() * it.multiplier * mushroomPrice extraMushroomCowPerk = perSecond * 60 * 60 } + + if (InventoryUtils.getItemInHand()?.getInternalName()?.contains("DICER") == true && config.moneyPerHourDicer) { + var dicerDrops = 0.0 + var bazaarData: BazaarData? = null + if (it == CropType.MELON) { + dicerDrops = GardenCropSpeed.latestMelonDicer + bazaarData = BazaarApi.getBazaarDataByInternalName("ENCHANTED_MELON") + } + if (it == CropType.PUMPKIN) { + dicerDrops = GardenCropSpeed.latestPumpkinDicer + bazaarData = BazaarApi.getBazaarDataByInternalName("ENCHANTED_PUMPKIN") + } + if (bazaarData != null) { + val price = if (LorenzUtils.noTradeMode) bazaarData.npcPrice / 160 else (bazaarData.sellPrice + bazaarData.buyPrice) / 320 + extraDicerDrops = 60 * 60 * GardenCropSpeed.getRecentBPS() * dicerDrops * price + } + } } val moneyPerHourData = calculateMoneyPerHour(newDisplay) @@ -183,11 +203,12 @@ object CropMoneyDisplay { val moneyArray = moneyPerHourData[internalName]!! for (price in moneyArray) { - val finalPrice = price + extraMushroomCowPerk + val finalPrice = price + extraMushroomCowPerk + extraDicerDrops val format = format(finalPrice) if (debug) { newDisplay.addAsSingletonList(" price: ${price.addSeparators()}") newDisplay.addAsSingletonList(" extraMushroomCowPerk: ${extraMushroomCowPerk.addSeparators()}") + newDisplay.addAsSingletonList(" extraDicerDrops: ${extraDicerDrops.addSeparators()}") newDisplay.addAsSingletonList(" finalPrice: ${finalPrice.addSeparators()}") } list.add("$coinsColor$format") @@ -270,7 +291,7 @@ object CropMoneyDisplay { } if (isSeeds) speed *= 1.36 if (crop.replenish) { - val blockPerSecond = crop.multiplier * 20 + val blockPerSecond = crop.multiplier * GardenCropSpeed.getRecentBPS() if (debug) { debugList.addAsSingletonList(" replenish blockPerSecond reduction: ${blockPerSecond.addSeparators()}") } @@ -314,7 +335,10 @@ object CropMoneyDisplay { } } - val bountifulMoney = if (toolHasBountiful?.get(crop) == true) speedPerHour * 0.2 else 0.0 + val bountifulMoney = if (toolHasBountiful?.get(crop) == true && config.moneyPerHourBountiful) speedPerHour * 0.2 else 0.0 + if (debug && bountifulMoney > 0.0) { + debugList.addAsSingletonList(" bountifulCoins: ${bountifulMoney.addSeparators()}") + } moneyPerHours[internalName] = formatNumbers(sellOffer + bountifulMoney, instantSell + bountifulMoney, npcPrice + bountifulMoney) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt index 3c5e83f7d..5aa9ebe49 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt @@ -18,45 +18,15 @@ class DicerRngDropCounter { init { initDrops() - //Melon Dicer 1.0 drops - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a2x §r§aEnchanted Melon§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a6x §r§aEnchanted Melon§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a75x §r§aEnchanted Melon§r§e!")) - //supporting the value for the drop message that differs from the wiki data - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a64x §r§aEnchanted Melon§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§93x §r§9Enchanted Melon Block§r§e!")) - - //Melon Dicer 2.0 drops - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a3x §r§aEnchanted Melon§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a13x §r§aEnchanted Melon§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§91x §r§9Enchanted Melon Block§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§96x §r§9Enchanted Melon Block§r§e!")) - - //Melon Dicer 3.0 drops - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a4x §r§aEnchanted Melon§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a16x §r§aEnchanted Melon§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§92x §r§9Enchanted Melon Block§r§e!")) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§98x §r§9Enchanted Melon Block§r§e!")) - - //Pumpkin Dicer 1.0 drops - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a1x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a2x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a18x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§a80x §r§aEnchanted Pumpkin§r§e!")) - //supporting the value for the drop message that differs from the wiki data - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§a64x §r§aEnchanted Pumpkin§r§e!")) - - //Pumpkin Dicer 2.0 drops - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a2x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a4x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a35x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§91x §r§9Polished Pumpkin§r§e!")) - - //Pumpkin Dicer 3.0 drops - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a3x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a5x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a45x §r§aEnchanted Pumpkin§r§e!")) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§92x §r§9Polished Pumpkin§r§e!")) + itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toRegex())) + itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toRegex())) + itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§[a|9]Enchanted Melon(?: Block)?§r§e!".toRegex())) + itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§9(\\d+)x §r§9Enchanted Melon Block§r§e!".toRegex())) + + itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toRegex())) + itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toRegex())) + itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toRegex())) + itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§(aEnchanted|9Polished) Pumpkin§r§e!".toRegex())) } private fun initDrops() { @@ -85,7 +55,7 @@ class DicerRngDropCounter { val message = event.message for (drop in itemDrops) { - if (message == drop.message) { + if (drop.pattern.matches(message)) { addDrop(drop.crop, drop.rarity) saveConfig() update() @@ -139,7 +109,7 @@ class DicerRngDropCounter { } } - class ItemDrop(val crop: CropType, val rarity: DropRarity, val message: String) + class ItemDrop(val crop: CropType, val rarity: DropRarity, val pattern: Regex) private fun saveConfig() { val map = GardenAPI.config?.dicerRngDrops ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index c726a11bc..460908ccd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -60,14 +60,12 @@ object GardenCropMilestoneDisplay { if (GardenAPI.hideExtraGuis()) return config.cropMilestoneProgressDisplayPos.renderStringsAndItems( - progressDisplay, - posLabel = "Crop Milestone Progress" + progressDisplay, posLabel = "Crop Milestone Progress" ) if (config.cropMilestoneMushroomPetPerkEnabled) { config.cropMilestoneMushroomPetPerkPos.renderStringsAndItems( - mushroomCowPerkDisplay, - posLabel = "Mushroom Cow Perk" + mushroomCowPerkDisplay, posLabel = "Mushroom Cow Perk" ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt index feb323ecf..dd911b723 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt @@ -8,8 +8,13 @@ import at.hannibal2.skyhanni.data.MayorElection import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LorenzUtils +import com.google.gson.JsonObject import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer @@ -27,6 +32,11 @@ object GardenCropSpeed { private var blocksBroken = 0 private var secondsStopped = 0 + private val melonDicer = mutableListOf<Double>() + private val pumpkinDicer = mutableListOf<Double>() + var latestMelonDicer = 0.0 + var latestPumpkinDicer = 0.0 + init { fixedRateTimer(name = "skyhanni-crop-milestone-speed", period = 1000L) { @@ -90,6 +100,26 @@ object GardenCropSpeed { blocksSpeedList.dropLast(1).average() } else 0.0 GardenAPI.getCurrentlyFarmedCrop()?.let { + val heldTool = InventoryUtils.getItemInHand() + val toolName = heldTool?.getInternalName() + if (toolName?.contains("DICER") == true) { + val lastCrop = lastBrokenCrop?.cropName?.lowercase() ?: "NONE" + if (toolName.lowercase().contains(lastCrop)) { + val tier = when { + toolName.endsWith("DICER") -> 0 + toolName.endsWith("DICER_2") -> 1 + toolName.endsWith("DICER_3") -> 2 + else -> -1 + } + if (tier != -1 && melonDicer.size > 0 && pumpkinDicer.size > 0) { + if (it == CropType.MELON) { + latestMelonDicer = melonDicer[tier] + } else if (it == CropType.PUMPKIN){ + latestPumpkinDicer = pumpkinDicer[tier] + } + } + } + } if (averageBlocksPerSecond > 1) { latestBlocksPerSecond?.put(it, averageBlocksPerSecond) } @@ -97,6 +127,47 @@ object GardenCropSpeed { } } + private fun calculateAverageDicer(dicerList: MutableList<Double>, dropsJson: JsonObject) { + dicerList.clear() + val totalChance = dropsJson["total chance"].asDouble + val dropTypes = dropsJson["drops"].asJsonArray + for (dropType in dropTypes) { + val dropJson = dropType.asJsonObject + val chance = (dropJson["chance"].asDouble / totalChance) + dropJson["amount"].asJsonArray.forEachIndexed { index, element -> + val amount = element.asInt * chance + if (index < dicerList.size) { + dicerList[index] += amount + } else { + dicerList.add(amount) + } + } + } + } + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + try { + val dicerJson = event.getConstant("DicerDrops")!! + calculateAverageDicer(melonDicer, dicerJson["MELON"].asJsonObject) + calculateAverageDicer(pumpkinDicer, dicerJson["PUMPKIN"].asJsonObject) + } catch (e: Exception) { + e.printStackTrace() + LorenzUtils.error("error in RepositoryReloadEvent") + } + } + + fun getRecentBPS(): Double { + val size = blocksSpeedList.size + return if (size <= 1) { + 0.0 + } else { + val startIndex = if (size >= 6) size - 6 else 0 + val validValues = blocksSpeedList.subList(startIndex, size) + validValues.dropLast(1).average() + } + } + private fun resetSpeed() { averageBlocksPerSecond = 0.0 blocksSpeedList.clear() |