diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
28 files changed, 1315 insertions, 329 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index 28ac37849..0f6817dd1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -17,10 +18,21 @@ class BazaarApi { var inBazaarInventory = false fun getCleanBazaarName(name: String): String { - if (name.endsWith(" Gemstone")) { - return name.substring(6) + var newName = name + if (newName.endsWith(" Gemstone")) { + return newName.substring(6) } - return name.replace("-", " ").removeColor() + if (newName.contains("Turbo-Cocoa ")) { + newName = newName.replace("Cocoa", "Coco") + } + if (newName.contains("Turbo-Cacti ")) { + newName = newName.replace("Cacti", "Cactus") + } + newName = newName.removeColor() + if (!name.contains("Tightly-Tied")) { + newName = newName.replace("-", " ") + } + return newName } fun getBazaarDataForName(name: String): BazaarData? { @@ -37,10 +49,11 @@ class BazaarApi { fun getBazaarDataForInternalName(internalName: String) = bazaarMap.values.firstOrNull { it.apiName == internalName } - fun isBazaarItem(stack: ItemStack): Boolean { - val internalName = stack.getInternalName() - return bazaarMap.any { it.value.apiName == internalName } + fun isBazaarItem(stack: ItemStack) = isBazaarItem(stack.getInternalName()) + fun isBazaarItem(internalName: String): Boolean { + val bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalName) + return bazaarInfo != null } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt index a7f46b44d..04ad6b841 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt @@ -13,10 +13,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class BazaarBestSellMethod { - - companion object { - private var display = "" - } + private var display = "" @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt index 9ee430050..6af2932b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt @@ -52,7 +52,5 @@ class BazaarCancelledBuyOrderClipboard { } } - fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && SkyHanniMod.feature.bazaar.cancelledBuyOrderClipboard - } + fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.bazaar.cancelledBuyOrderClipboard }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt index bd9ef0a79..8fbb9b0c3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt @@ -49,7 +49,13 @@ class BazaarOrderHelper { val bazaarName = BazaarApi.getCleanBazaarName(rawName) val data = BazaarApi.getBazaarDataForName(bazaarName) if (data == null) { + LorenzUtils.debug("Bazaar data is null!") println("Bazaar data is null for '$rawName'/'$bazaarName'") +// for (key in BazaarApi.bazaarMap.keys) { +// if (key.lowercase().contains("hay")) { +// println("key: '$key'") +// } +// } continue } diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt index a3289c9e1..99cfdebb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ChatFilter { + private val config get() = SkyHanniMod.feature.chat @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { @@ -20,28 +21,28 @@ class ChatFilter { private fun block(message: String): String = when { message.startsWith("§aYou are playing on profile: §e") -> "profile"//TODO move into own class - lobby(message) && SkyHanniMod.feature.chat.hypixelHub -> "lobby" - empty(message) && SkyHanniMod.feature.chat.empty -> "empty" - warping(message) && SkyHanniMod.feature.chat.warping -> "warping" - welcome(message) && SkyHanniMod.feature.chat.welcome -> "welcome" - isGuildExp(message) && SkyHanniMod.feature.chat.guildExp -> "guild_exp" - friendJoin(message) && SkyHanniMod.feature.chat.friendJoinLeft -> "friend_join" - - killCombo(message) && SkyHanniMod.feature.chat.others -> "kill_combo" - bazaarAndAHMiniMessages(message) && SkyHanniMod.feature.chat.others -> "bz_ah_minis" - watchdogAnnouncement(message) && SkyHanniMod.feature.chat.others -> "watchdog" - slayer(message) && SkyHanniMod.feature.chat.others -> "slayer" - slayerDrop(message) && SkyHanniMod.feature.chat.others -> "slayer_drop" - uselessDrop(message) && SkyHanniMod.feature.chat.others -> "useless_drop" - uselessNotification(message) && SkyHanniMod.feature.chat.others -> "useless_notification" - party(message) && SkyHanniMod.feature.chat.others -> "party" - money(message) && SkyHanniMod.feature.chat.others -> "money" - winterIsland(message) && SkyHanniMod.feature.chat.others -> "winter_island" - uselessWarning(message) && SkyHanniMod.feature.chat.others -> "useless_warning" - annoyingSpam(message) && SkyHanniMod.feature.chat.others -> "annoying_spam" - - isWinterGift(message) && SkyHanniMod.feature.chat.winterGift -> "winter_gift" - isPowderMining(message) && SkyHanniMod.feature.chat.powderMining -> "powder_mining" + lobby(message) && config.hypixelHub -> "lobby" + empty(message) && config.empty -> "empty" + warping(message) && config.warping -> "warping" + welcome(message) && config.welcome -> "welcome" + isGuildExp(message) && config.guildExp -> "guild_exp" + friendJoin(message) && config.friendJoinLeft -> "friend_join" + killCombo(message) && config.killCombo -> "kill_combo" + watchdogAnnouncement(message) && config.watchDog -> "watchdog" + + bazaarAndAHMiniMessages(message) && config.others -> "bz_ah_minis" + slayer(message) && config.others -> "slayer" + slayerDrop(message) && config.others -> "slayer_drop" + uselessDrop(message) && config.others -> "useless_drop" + uselessNotification(message) && config.others -> "useless_notification" + party(message) && config.others -> "party" + money(message) && config.others -> "money" + winterIsland(message) && config.others -> "winter_island" + uselessWarning(message) && config.others -> "useless_warning" + annoyingSpam(message) && config.others -> "annoying_spam" + + isWinterGift(message) && config.winterGift -> "winter_gift" + isPowderMining(message) && config.powderMining -> "powder_mining" else -> "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index 5b8bc369d..eb9367776 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -40,6 +40,7 @@ class DamageIndicatorManager { private var mobFinder: MobFinder? = null private val maxHealth = mutableMapOf<UUID, Long>() + private val config get() = SkyHanniMod.feature.damageIndicator companion object { private var data = mutableMapOf<UUID, EntityData>() @@ -144,7 +145,7 @@ class DamageIndicatorManager { if (!data.ignoreBlocks) { if (!player.canEntityBeSeen(data.entity)) continue } - if (data.bossType.bossTypeToggle !in SkyHanniMod.feature.damageIndicator.bossesToShow) continue + if (data.bossType.bossTypeToggle !in config.bossesToShow) continue val entity = data.entity @@ -184,7 +185,7 @@ class DamageIndicatorManager { ) } - var bossName = when (SkyHanniMod.feature.damageIndicator.bossName) { + var bossName = when (config.bossName) { 0 -> "" 1 -> data.bossType.fullName 2 -> data.bossType.shortName @@ -199,7 +200,7 @@ class DamageIndicatorManager { } event.drawDynamicText(location, bossName, sizeBossName, -9f, smallestDistanceVew = smallestDistanceVew) - if (SkyHanniMod.feature.damageIndicator.showDamageOverTime) { + if (config.showDamageOverTime) { var diff = 13f val currentDamage = data.damageCounter.currentDamage val currentHealing = data.damageCounter.currentHealing @@ -329,7 +330,7 @@ class DamageIndicatorManager { entityData.nameAbove = "" val customHealthText = if (health == 0L) { entityData.dead = true - if (entityData.bossType.showDeathTime && SkyHanniMod.feature.damageIndicator.timeToKillSlayer) { + if (entityData.bossType.showDeathTime && config.timeToKillSlayer) { entityData.nameAbove = entityData.timeToKill } "§cDead" @@ -626,7 +627,7 @@ class DamageIndicatorManager { //val remainingTicks = 8 * 20 - ticksAlive val remainingTicks = (8.9 * 20).toLong() - ticksAlive - if (SkyHanniMod.feature.damageIndicator.showHealthDuringLaser) { + if (config.showHealthDuringLaser) { entityData.nameSuffix = " §f" + formatDelay(remainingTicks * 50) } else { return formatDelay(remainingTicks * 50) @@ -649,7 +650,7 @@ class DamageIndicatorManager { else -> { LorenzUtils.error( "Unexpected health of thorn in f4! (${ - LorenzUtils.formatDouble(realHealth.toDouble()) + LorenzUtils.formatInteger(realHealth) })" ) return null @@ -754,7 +755,7 @@ class DamageIndicatorManager { val name = entity.customNameTag.removeColor().replace(",", "") if (entityData != null) { - if (SkyHanniMod.feature.damageIndicator.hideDamageSplash) { + if (config.hideDamageSplash) { event.isCanceled = true } if (entityData.bossType == BossType.DUMMY) { @@ -768,7 +769,7 @@ class DamageIndicatorManager { } else { if (entityData != null) { if (isEnabled()) { - if (SkyHanniMod.feature.damageIndicator.hideVanillaNametag) { + if (config.hideVanillaNametag) { val name = entity.name if (name.contains("Plaesmaflux")) return if (name.contains("Overflux")) return @@ -781,7 +782,5 @@ class DamageIndicatorManager { } } - fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && SkyHanniMod.feature.damageIndicator.enabled - } + fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt index e245c77dd..702b5fb8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt @@ -23,7 +23,7 @@ class BarnFishingTimer { private var currentCount = 0 private var startTime = 0L - private var sound = object : PositionedSound(ResourceLocation("random.orb")) { + private val sound = object : PositionedSound(ResourceLocation("random.orb")) { init { volume = 50f repeat = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt new file mode 100644 index 000000000..8af8bf742 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt @@ -0,0 +1,171 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GardenToolChangeEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc +import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import kotlinx.coroutines.launch +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import java.util.* + +class CropMoneyDisplay { + private val display = mutableListOf<List<Any>>() + private val config get() = SkyHanniMod.feature.garden + private var tick = 0 + private var loaded = false + private var ready = false + private val multipliers = mutableMapOf<String, Int>() + private val cropNames = mutableMapOf<String, String>() // internalName -> cropName + private var hasCropInHand = false + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!isEnabled()) return + + config.moneyPerHourPos.renderStringsAndItems(display) + } + + @SubscribeEvent + fun onGardenToolChange(event: GardenToolChangeEvent) { + val crop = if (event.isRealCrop) event.crop else null + hasCropInHand = crop != null + update() + } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (!isEnabled()) return + if (tick++ % (20 * 5) != 0) return + if (!hasCropInHand && !config.moneyPerHourAlwaysOn) return + + update() + } + + private fun update() { + init() + + val newDisplay = drawNewDisplay() + display.clear() + display.addAll(newDisplay) + } + + private fun drawNewDisplay(): MutableList<List<Any>> { + val newDisplay = mutableListOf<List<Any>>() + + if (!ready) { + newDisplay.add(Collections.singletonList("§7Money per hour when selling:")) + newDisplay.add(Collections.singletonList("§eLoading...")) + return newDisplay + } + + if (!hasCropInHand && !config.moneyPerHourAlwaysOn) return newDisplay + + newDisplay.add(Collections.singletonList("§7Money per hour when selling:")) + + var number = 0 + val map = calculateMoneyPerHour() + if (map.isEmpty()) { + newDisplay.add(Collections.singletonList("§cFarm crops to add them to this list!")) + } else { + for ((internalName, moneyPerHour) in map.sortedDesc()) { + number++ + val cropName = cropNames[internalName] + val isCurrent = cropName == GardenAPI.cropInHand + if (number > config.moneyPerHourShowOnlyBest && !isCurrent) continue + + val list = mutableListOf<Any>() + list.add("§7$number# ") + + try { + val itemStack = NEUItems.getItemStack(internalName) + list.add(itemStack) + } catch (e: NullPointerException) { + e.printStackTrace() + } + val format = LorenzUtils.formatInteger(moneyPerHour.toLong()) + val itemName = NEUItems.getItemStack(internalName).name?.removeColor() ?: continue + val color = if (isCurrent) "§e" else "§7" + list.add("$color$itemName§7: §6$format") + + newDisplay.add(list) + } + } + + return newDisplay + } + + private fun calculateMoneyPerHour(): MutableMap<String, Double> { + val moneyPerHours = mutableMapOf<String, Double>() + for ((internalName, amount) in multipliers) { + val price = NEUItems.getPrice(internalName) + val cropName = cropNames[internalName]!! + val speed = GardenAPI.getCropsPerSecond(cropName)!! + + // No speed data for item in hand + if (speed == -1) continue + + // Price not found + if (price == -1.0) continue + + val speedPerHr = speed.toDouble() * 60 * 60 + val blocksPerHour = speedPerHr / amount.toDouble() + val moneyPerHour = price * blocksPerHour + moneyPerHours[internalName] = moneyPerHour + } + return moneyPerHours + } + + private fun init() { + if (loaded) return + + if (BazaarApi.bazaarMap.isEmpty()) { + LorenzUtils.debug("bz not ready for money/time!") + return + } + + loaded = true + + SkyHanniMod.coroutineScope.launch { + val crops = listOf( + "Wheat", + "Carrot", + "Potato", + "Pumpkin", + "Sugar Cane", + "Melon", + "Cactus", + "Cocoa Beans", + "Mushroom", + "Nether Wart", + ) + + for ((internalName, _) in NotEnoughUpdates.INSTANCE.manager.itemInformation) { + if (!BazaarApi.isBazaarItem(internalName)) continue + if (internalName == "ENCHANTED_PAPER") continue + + val (newId, amount) = NEUItems.getMultiplier(internalName) + if (amount < 10) continue + val itemName = NEUItems.getItemStack(newId).name?.removeColor() ?: continue + val cropName = GardenAPI.itemNameToCropName(itemName) + if (crops.contains(cropName)) { + multipliers[internalName] = amount + cropNames[internalName] = cropName + } + } + + + ready = true + update() + } + } + + private fun isEnabled() = GardenAPI.inGarden() && config.moneyPerHourDisplay +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt new file mode 100644 index 000000000..8547f4d51 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt @@ -0,0 +1,130 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GardenToolChangeEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc +import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class DicerRngDropCounter { + private val display = mutableListOf<String>() + private val drops = mutableMapOf<String, MutableMap<DropRarity, Int>>() + private val itemDrops = mutableListOf<ItemDrop>() + + init { + drops["Melon"] = mutableMapOf() + drops["Pumpkin"] = mutableMapOf() + + itemDrops.add(ItemDrop("Melon", DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a1x §r§aEnchanted Melon§r§e!")) + itemDrops.add(ItemDrop("Melon", DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a5x §r§aEnchanted Melon§r§e!")) + itemDrops.add(ItemDrop("Melon", DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a50x §r§aEnchanted Melon§r§e!")) + itemDrops.add(ItemDrop("Melon", DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§92x §r§9Enchanted Melon Block§r§e!")) + + itemDrops.add(ItemDrop("Pumpkin", DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§f64x §r§fPumpkin§r§e!")) + itemDrops.add(ItemDrop("Pumpkin", DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a1x §r§aEnchanted Pumpkin§r§e!")) + itemDrops.add(ItemDrop("Pumpkin", DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a10x §r§aEnchanted Pumpkin§r§e!")) + itemDrops.add(ItemDrop("Pumpkin", DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§a64x §r§aEnchanted Pumpkin§r§e!")) + } + + enum class DropRarity(val displayName: String) { + UNCOMMON("§a§lUNCOMMON DROP"), + RARE("§9§lRARE DROP"), + CRAZY_RARE("§d§lCRAZY RARE DROP"), + PRAY_TO_RNGESUS("§5§lPRAY TO RNGESUS DROP"), + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!isEnabled()) return + + val message = event.message + for (drop in itemDrops) { + if (message == drop.message) { + addDrop(drop.itemName, drop.rarity) + saveConfig() + update() + return + } + } + + if (message.contains("§r§eDicer dropped")) { + LorenzUtils.debug("Unknown dicer drop message!") + println("Unknown dicer drop message: '$message'") + } + } + + private fun update() { + val newDisplay = drawDisplay() + display.clear() + display.addAll(newDisplay) + } + + private fun drawDisplay(): List<String> { + val help = mutableListOf<String>() + val items = drops[itemInHand] ?: return help + help.add("§7RNG Drops for $toolname§7:") + for ((rarity, amount) in items.sortedDesc()) { + val displayName = rarity.displayName + help.add(" §7- §e${amount}x $displayName") + } + + return help + } + + private var itemInHand = "" + private var toolname = "" + + @SubscribeEvent + fun onGardenToolChange(event: GardenToolChangeEvent) { + val crop = event.crop + itemInHand = if (crop == "Melon" || crop == "Pumpkin") crop else "" + if (itemInHand != "") { + toolname = event.heldItem!!.name!! + } + update() + } + + private fun addDrop(item: String, rarity: DropRarity) { + val map = drops[item]!! + val old = map[rarity] ?: 0 + map[rarity] = old + 1 + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (isEnabled()) { + SkyHanniMod.feature.garden.dicerCounterPos.renderStrings(display) + } + } + + class ItemDrop(val itemName: String, val rarity: DropRarity, val message: String) + + private fun saveConfig() { + val list = SkyHanniMod.feature.hidden.gardenDicerRngDrops + list.clear() + for (drop in drops) { + val itemName = drop.key + for ((rarity, amount) in drop.value) { + list[itemName + "." + rarity.name] = amount + } + } + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + for ((internalName, amount) in SkyHanniMod.feature.hidden.gardenDicerRngDrops) { + val split = internalName.split(".") + val itemName = split[0] + val rarityName = split[1] + val rarity = DropRarity.valueOf(rarityName) + drops[itemName]!![rarity] = amount + } + } + + fun isEnabled() = GardenAPI.inGarden() && SkyHanniMod.feature.garden.dicerCounterDisplay +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt new file mode 100644 index 000000000..6676f4f77 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt @@ -0,0 +1,235 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.CollectionAPI +import at.hannibal2.skyhanni.data.HyPixelData +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.utils.APIUtil +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.round +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import net.minecraft.client.Minecraft +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +class EliteFarmingWeight { + + @SubscribeEvent + fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { + // This is still not perfect, but it's definitely better than other alternatives for the moment. + extraCollection.clear() + dirtyCropWeight = true + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (isEnabled()) { + config.eliteFarmingWeightPos.renderString(display) + } + } + + @SubscribeEvent + fun onWorldChange(event: WorldEvent.Load) { + // We want to try to connect to the api again after a world switch. + apiError = false + } + + var tick = 0 + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (tick++ % 5 != 0) return |
