diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-25 15:37:01 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-25 15:37:01 +0100 |
commit | a7758737b759a5b44b93fae5b579740024cd7b2a (patch) | |
tree | 0c1f6a4f4aa537f189ff5276a5f531ffc76610e0 /src | |
parent | c038db2900f84408743c647532211d31fa5a19e7 (diff) | |
download | skyhanni-a7758737b759a5b44b93fae5b579740024cd7b2a.tar.gz skyhanni-a7758737b759a5b44b93fae5b579740024cd7b2a.tar.bz2 skyhanni-a7758737b759a5b44b93fae5b579740024cd7b2a.zip |
Added farming armor drops counter.
Added option to hide chat messages for farming armor crop counter, dicer counter, and chicken head timer.
Diffstat (limited to 'src')
8 files changed, 161 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 2075cb445..9c7538839 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -229,6 +229,7 @@ public class SkyHanniMod { loadModule(new JacobFarmingContestsInventory()); loadModule(new GardenNextJacobContest()); loadModule(new WrongFungiCutterWarning()); + loadModule(new FarmingArmorDrops()); 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 f55fdb514..469bee8db 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -443,6 +443,11 @@ public class Garden { public boolean dicerCounterDisplay = true; @Expose + @ConfigOption(name = "Hide Chat", desc = "Hide the chat message when dropping a RNG Dicer drop.") + @ConfigEditorAccordion(id = 12) + public boolean dicerCounterHideChat = false; + + @Expose // @ConfigOption(name = "Dicer Counter Position", desc = "") // @ConfigEditorButton(runnableId = "dicerCounter", buttonText = "Edit") // @ConfigAccordionId(id = 12) @@ -529,6 +534,26 @@ public class Garden { public Position nextJacobContestPos = new Position(-113, -240, false, true); @Expose + @ConfigOption(name = "Farming Armor Drops", desc = "") + @ConfigEditorAccordion(id = 12) + public boolean farmingArmorDrops = false; + + @Expose + @ConfigOption(name = "Show Counter", desc = "Count all §9Cropie§7, §5Squash §7and §6Fermento §7dropped.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 12) + public boolean farmingArmorDropsEnabled = true; + + @Expose + @ConfigOption(name = "Hide Chat", desc = "Hide the chat message when receiving a farming armor drop.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 12) + public boolean farmingArmorDropsHideChat = false; + + @Expose + public Position farmingArmorDropsPos = new Position(16, -232, 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 160d428c7..bc898c818 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java @@ -48,4 +48,7 @@ public class Hidden { @Expose public Map<Long, List<CropType>> gardenJacobFarmingContestTimes = new HashMap<>(); + + @Expose + public Map<String, Integer> gardenFarmingArmorDrops = new HashMap<>(); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index 73d301d78..4268a4286 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -216,6 +216,12 @@ public class Misc { public boolean chickenHeadTimerDisplay = false; @Expose + @ConfigOption(name = "Hide Chat", desc = "Hide the 'You lay an egg' chat message'.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 10) + public boolean chickenHeadTimerHideChat = true; + + @Expose // @ConfigOption(name = "Timer Position", desc = "") // @ConfigEditorButton(runnableId = "chickenHeadTimer", buttonText = "Edit") // @ConfigAccordionId(id = 10) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt index 04289d46c..b77ab61f0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt @@ -6,7 +6,6 @@ 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 @@ -15,6 +14,7 @@ class DicerRngDropCounter { private var display = listOf<String>() private val drops = mutableMapOf<CropType, MutableMap<DropRarity, Int>>() private val itemDrops = mutableListOf<ItemDrop>() + private val config get() = SkyHanniMod.feature.garden init { drops[CropType.MELON] = mutableMapOf() @@ -48,14 +48,12 @@ class DicerRngDropCounter { addDrop(drop.crop, drop.rarity) saveConfig() update() + if (config.dicerCounterHideChat) { + event.blockedReason = "dicer_rng_drop_counter" + } return } } - - if (message.contains("§r§eDicer dropped")) { - LorenzUtils.debug("Unknown dicer drop message!") - println("Unknown dicer drop message: '$message'") - } } private fun update() { @@ -96,19 +94,19 @@ class DicerRngDropCounter { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (isEnabled()) { - SkyHanniMod.feature.garden.dicerCounterPos.renderStrings(display, posLabel = "Dicer Counter") + config.dicerCounterPos.renderStrings(display, posLabel = "Dicer Counter") } } class ItemDrop(val crop: CropType, val rarity: DropRarity, val message: String) private fun saveConfig() { - val list = SkyHanniMod.feature.hidden.gardenDicerRngDrops - list.clear() + val map = SkyHanniMod.feature.hidden.gardenDicerRngDrops + map.clear() for (drop in drops) { val crop = drop.key for ((rarity, amount) in drop.value) { - list[crop.cropName + "." + rarity.name] = amount + map[crop.cropName + "." + rarity.name] = amount } } } @@ -124,5 +122,5 @@ class DicerRngDropCounter { } } - fun isEnabled() = GardenAPI.inGarden() && SkyHanniMod.feature.garden.dicerCounterDisplay + fun isEnabled() = GardenAPI.inGarden() && config.dicerCounterDisplay }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingArmorDrops.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingArmorDrops.kt new file mode 100644 index 000000000..33759c25f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingArmorDrops.kt @@ -0,0 +1,106 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc +import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import java.util.regex.Pattern + +class FarmingArmorDrops { + private var display = listOf<String>() + private val drops = mutableMapOf<ArmorDropType, Int>() + private var hasArmor = false + private var tick = 0 + private val armorPattern = Pattern.compile("(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)") + private val config get() = SkyHanniMod.feature.garden + + enum class ArmorDropType(val dropName: String, val chatMessage: String) { + CROPIE("§9Cropie", "§6§lRARE CROP! §r§f§r§9Cropie §r§b(Armor Set Bonus)"), + SQUASH("§5Squash", "§6§lRARE CROP! §r§f§r§5Squash §r§b(Armor Set Bonus)"), + FERMENTO("§6Fermento", "§6§lRARE CROP! §r§f§r§6Fermento §r§b(Armor Set Bonus)"), + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + for (dropType in ArmorDropType.values()) { + if (dropType.chatMessage == event.message) { + addDrop(dropType) + if (config.farmingArmorDropsEnabled && config.farmingArmorDropsHideChat) { + event.blockedReason = "farming_armor_drops" + } + } + } + } + + private fun addDrop(drop: ArmorDropType) { + val old = drops[drop] ?: 0 + drops[drop] = old + 1 + saveConfig() + update() + } + + private fun update() { + display = drawDisplay() + } + + private fun drawDisplay(): List<String> { + val help = mutableListOf<String>() + help.add("§7RNG Drops for Farming Armor:") + for ((drop, amount) in drops.sortedDesc()) { + val dropName = drop.dropName + help.add(" §7- §e${amount}x $dropName") + } + + return help + } + + private fun saveConfig() { + val map = SkyHanniMod.feature.hidden.gardenFarmingArmorDrops + map.clear() + for ((drop, amount) in drops) { + map[drop.toString()] = amount + } + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + for ((rawName, amount) in SkyHanniMod.feature.hidden.gardenFarmingArmorDrops) { + drops[ArmorDropType.valueOf(rawName)] = amount + } + update() + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!GardenAPI.inGarden()) return + if (!config.farmingArmorDropsEnabled) return + if (!hasArmor) return + + config.farmingArmorDropsPos.renderStrings(display, posLabel = "Farming Armor Drops") + } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (event.phase != TickEvent.Phase.START) return + if (!GardenAPI.inGarden()) return + if (!config.farmingArmorDropsEnabled) return + + tick++ + if (tick % 30 == 0) { + checkArmor() + } + } + + private fun checkArmor() { + val armorPieces = InventoryUtils.getArmor() + .mapNotNull { it?.getInternalName() } + .count { armorPattern.matcher(it).matches() } + hasArmor = armorPieces > 1 + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt index 895974629..89e54fbb8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt @@ -3,27 +3,27 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.TimeUtils -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 ChickenHeadTimer { - private var tick = 0 private var hasChickenHead = false private var lastTime = 0L + private val config get() = SkyHanniMod.feature.misc @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (!isEnabled()) return if (tick++ % 5 != 0) return - val itemStack = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[3] + val itemStack = InventoryUtils.getArmor()[3] val name = itemStack?.name ?: "" hasChickenHead = name.contains("Chicken Head") } @@ -39,6 +39,9 @@ class ChickenHeadTimer { if (!hasChickenHead) return if (event.message == "§aYou laid an egg!") { lastTime = System.currentTimeMillis() + if (config.chickenHeadTimerHideChat) { + event.blockedReason = "chicken_head_timer" + } } } @@ -58,8 +61,8 @@ class ChickenHeadTimer { "Chicken Head Timer: §b$formatDuration" } - SkyHanniMod.feature.misc.chickenHeadTimerPosition.renderString(displayText, posLabel = "Chicken Head Timer") + config.chickenHeadTimerPosition.renderString(displayText, posLabel = "Chicken Head Timer") } - fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.chickenHeadTimerDisplay + fun isEnabled() = LorenzUtils.inSkyBlock && config.chickenHeadTimerDisplay }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index da152a2c3..53e39e575 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -54,4 +54,7 @@ object InventoryUtils { Minecraft.getMinecraft().thePlayer.inventory.mainInventory .filter { it != null && predicate(it) } .sumOf { it.stackSize } + + fun getArmor(): Array<ItemStack?> = + Minecraft.getMinecraft().thePlayer.inventory.armorInventory }
\ No newline at end of file |