diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-13 15:26:05 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-13 15:26:05 +0100 |
commit | 26f6c844863f96f1a9dd9624667757c74deb2527 (patch) | |
tree | f64fb789bcd026a065a39053b7e65eabbc5a68a7 /src | |
parent | 8a82042d0bb17b527de76dc216d5a567df58ea22 (diff) | |
download | skyhanni-26f6c844863f96f1a9dd9624667757c74deb2527.tar.gz skyhanni-26f6c844863f96f1a9dd9624667757c74deb2527.tar.bz2 skyhanni-26f6c844863f96f1a9dd9624667757c74deb2527.zip |
Count RNG drops for Melon Dicer and Pumpkin Dicer
Diffstat (limited to 'src')
5 files changed, 160 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 4360864f5..4d9eb43ad 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -218,6 +218,7 @@ public class SkyHanniMod { loadModule(new GardenDeskInSBMenu()); loadModule(new GardenLevelDisplay()); loadModule(new EliteFarmingWeight()); + loadModule(new DicerRngDropCounter()); Commands.INSTANCE.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index ad67a647a..f0f80a66a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -213,6 +213,11 @@ public class Features extends Config { editOverlay(activeConfigCategory, 200, 16, garden.eliteFarmingWeightPos); return; } + + if (runnableId.equals("dicerCounter")) { + editOverlay(activeConfigCategory, 200, 16, garden.dicerCounterPos); + return; + } } @Expose 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 94bb36bfd..5933ed959 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -312,7 +312,7 @@ public class Garden { @Expose @ConfigOption(name = "Elite Farming Weight", desc = "") - @ConfigEditorAccordion(id = 10) + @ConfigEditorAccordion(id = 11) public boolean eliteFarmingWeight = false; @Expose @@ -320,23 +320,40 @@ public class Garden { "The calculation and api is provided by The Elite SkyBlock Farmers. " + "See §ehttps://elitebot.dev/info §7for more info.") @ConfigEditorBoolean - @ConfigAccordionId(id = 10) + @ConfigAccordionId(id = 11) public boolean eliteFarmingWeightDisplay = true; @Expose @ConfigOption(name = "Farming Weight Position", desc = "") @ConfigEditorButton(runnableId = "eliteFarmingWeight", buttonText = "Edit") - @ConfigAccordionId(id = 10) + @ConfigAccordionId(id = 11) public Position eliteFarmingWeightPos = new Position(-370, -167, false, true); @Expose @ConfigOption(name = "Leaderboard Ranking", desc = "Show your position in the farming weight leaderboard. " + "Only if your farming weight is high enough! Updates every 10 minutes.") @ConfigEditorBoolean - @ConfigAccordionId(id = 10) + @ConfigAccordionId(id = 11) public boolean eliteFarmingWeightLeaderboard = true; @Expose + @ConfigOption(name = "Dicer Counter", desc = "") + @ConfigEditorAccordion(id = 12) + public boolean dicerCounter = false; + + @Expose + @ConfigOption(name = "Rng Drop Counter", desc = "Count RNG drops for Melon Dicer and Pumpkin Dicer") + @ConfigEditorBoolean + @ConfigAccordionId(id = 12) + public boolean dicerCounterDisplay = true; + + @Expose + @ConfigOption(name = "Dicer Counter Position", desc = "") + @ConfigEditorButton(runnableId = "dicerCounter", buttonText = "Edit") + @ConfigAccordionId(id = 12) + public Position dicerCounterPos = new Position(-375, -215, false, true); + + @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 c8604aeb3..547c4a24d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java @@ -41,4 +41,7 @@ public class Hidden { @Expose public int gardenExp = -1; + + @Expose + public Map<String, Integer> gardenDicerRngDrops = new HashMap<>(); } 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..1b170bc7f --- /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 melon = drops[item]!! + val old = melon[rarity] ?: 0 + melon[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 |