From 47c13c1d63dd3662c646b399aa1c429e216ca802 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:42:48 +0100 Subject: Fixed StringIndexOutOfBoundsException in garden visitor keybinds --- .../java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 20ee57028..3f1c31fc7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -137,6 +137,8 @@ class GardenVisitorFeatures { var itemsWithSpeedCounter = 0 var endReached = false for ((i, l) in list.toMutableList().withIndex()) { + if (l.length < 4) continue + val line = l.substring(4) if (line == "") { if (!endReached) { -- cgit From fbefefef4f787b383228c6156f1e75b79f8e85bb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:43:08 +0100 Subject: Fixed typo with Rancher's Boots speed --- src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index 3575e2379..06e4d9587 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -106,7 +106,7 @@ public class Inventory { "§bKuudra Key", "§bSkill Level", "§bCollection Level", - "§bRancher Boot's speed" + "§bRancher's Boots speed" } ) public List itemNumberAsStackSize = new ArrayList<>(Arrays.asList(3, 9, 11)); -- cgit From 93c60d7bd956ca5f922c8f3bb54e8736427aef61 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:43:44 +0100 Subject: Fixed kuudra key display showing question mark --- .../skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index 2a0cfc20c..a28cd5e86 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.api.CollectionAPI import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils +import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils.between import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded @@ -26,7 +26,7 @@ class ItemDisplayOverlayFeatures { } private fun getStackTip(item: ItemStack): String { - val itemName = item.name ?: return "" + val itemName = item.cleanName() if (SkyHanniMod.feature.inventory.itemNumberAsStackSize.contains(0)) { when (itemName) { -- cgit From c68c5ab0d417b70380a47a57535034f598df4cfb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 20:06:15 +0100 Subject: Garden guis no longer show on other peoples gardens. --- src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt | 8 ++++++-- src/main/java/at/hannibal2/skyhanni/data/IslandType.kt | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt index 2893e67a4..940b955b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt @@ -112,8 +112,6 @@ class HyPixelData { bingo = true } - // TODO implemennt stranded check - " §7♲ §7Ironman" -> { ironman = true } @@ -147,6 +145,12 @@ class HyPixelData { } } + if (islandType == IslandType.GARDEN) { + if (guesting) { + islandType = IslandType.GARDEN_GUEST + } + } + if (skyBlockIsland != islandType) { IslandChangeEvent(islandType, skyBlockIsland).postAndCatch() if (islandType == IslandType.UNKNOWN) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 74081a5c4..aa6a02b13 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -16,6 +16,7 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { DEEP_CAVERNS("Deep Caverns", "deep_caverns"), GOLD_MINES("Gold Mine", "gold_mine"),//TODO confirm GARDEN("Garden"), + GARDEN_GUEST("Garden Guest"), NONE(""), UNKNOWN("???"), -- cgit From b38d02daf7e9a88b3a8079c91cf1d94bf9e80a59 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 20:54:50 +0100 Subject: deleted timeTillNextCrop --- .../hannibal2/skyhanni/config/features/Hidden.java | 3 --- .../features/garden/GardenCropMilestoneDisplay.kt | 30 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) 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 315be5382..5bd2b3ba4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java @@ -36,9 +36,6 @@ public class Hidden { @Expose public Map gardenCropCounter = new HashMap<>(); - @Expose - public Map gardenTimeTillNextCropMilestone = new HashMap<>(); - @Expose public Map gardenCropsPerSecond = new HashMap<>(); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index d43d2f428..2585278e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -18,7 +18,7 @@ class GardenCropMilestoneDisplay { private val bestCropDisplay = mutableListOf>() private var needsInventory = false private val cultivatingData = mutableMapOf() - private val timeTillNextCrop: MutableMap get() = SkyHanniMod.feature.hidden.gardenTimeTillNextCropMilestone + private val timeTillNextCrop = mutableMapOf() private val config: Garden get() = SkyHanniMod.feature.garden companion object { @@ -29,7 +29,7 @@ class GardenCropMilestoneDisplay { return cropsPerSecond[crop] } - private val cropsPerSecond: MutableMap get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond + private val cropsPerSecond: MutableMap get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond } @SubscribeEvent @@ -57,6 +57,7 @@ class GardenCropMilestoneDisplay { @SubscribeEvent fun onCropMilestoneUpdate(event: CropMilestoneUpdateEvent) { needsInventory = false + updateTimeTillNextCrop() update() } @@ -142,6 +143,10 @@ class GardenCropMilestoneDisplay { } private fun drawBestDisplay(currentCrop: String?) { + if (timeTillNextCrop.size < cropsPerSecond.size) { + updateTimeTillNextCrop() + } + val gardenExp = config.cropMilestoneBestType == 0 val sorted = if (gardenExp) { val helpMap = mutableMapOf() @@ -185,6 +190,27 @@ class GardenCropMilestoneDisplay { } } + private fun updateTimeTillNextCrop() { + for ((cropName, speed) in cropsPerSecond) { + if (speed == -1) continue + + val crops = GardenCropMilestones.cropCounter[cropName]!! + val currentTier = GardenCropMilestones.getTierForCrops(crops) + + val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier) + val nextTier = currentTier + 1 + val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier) + + val have = crops - cropsForCurrentTier + val need = cropsForNextTier - cropsForCurrentTier + + val missing = need - have + val missingTimeSeconds = missing / speed + val millis = missingTimeSeconds * 1000 + timeTillNextCrop[cropName] = millis + } + } + private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 private fun drawProgressDisplay(it: String, crops: Long) { -- cgit From e422ab4c478ce1d6032336a388a5e1d40f7315d5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 20:57:03 +0100 Subject: Formatting --- .../java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt | 2 +- .../java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt index 44a376e17..f19762920 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt @@ -46,7 +46,7 @@ class GardenVisitorTimer { val extraSpeed = if (diff in 1001..10_000) { val factor = diff / 1000 - "§f/§e" + TimeUtils.formatDuration(millis / factor) + "§7/§e" + TimeUtils.formatDuration(millis / factor) } else "" val formatDuration = TimeUtils.formatDuration(millis) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt index cc3f842aa..fce2b03f8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt @@ -58,7 +58,7 @@ class SkyMartBestProfit { iconMap[name] = NEUItems.getItemStack(internalName) val advancedStats = if (config.skyMartCopperPriceAdvancedStats) { - " §7(§6$priceFormat §f/ §c$amountFormat Copper§7)" + " §7(§6$priceFormat §7/ §c$amountFormat Copper§7)" } else "" val pair = Pair(name, "§6§l$perFormat$advancedStats") priceMap[pair] = factor -- cgit From 13991583b3c2dce985a542b33e2983009f46b71d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:22:36 +0100 Subject: Added /desk shortcut in sb menu --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../hannibal2/skyhanni/config/features/Garden.java | 5 +++ .../skyhanni/features/garden/GardenDeskInSBMenu.kt | 50 ++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 8fb90ed9c..1c1617864 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -215,6 +215,7 @@ public class SkyHanniMod { loadModule(new GardenCustomKeybinds()); loadModule(new ChickenHeadTimer()); loadModule(new GardenOptimalSpeed()); + loadModule(new GardenDeskInSBMenu()); 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 58e014ce9..a288113ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -297,4 +297,9 @@ public class Garden { @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") @ConfigEditorBoolean public boolean plotPrice = true; + + @Expose + @ConfigOption(name = "Desk in Menu", desc = "Show a Desk button in the SkyBlock Menu. Opens the /desk command on click.") + @ConfigEditorBoolean + public boolean deskInSkyBlockMenu = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt new file mode 100644 index 000000000..fc060bad5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt @@ -0,0 +1,50 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.features.Garden +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.utils.NEUItems +import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent +import io.github.moulberry.notenoughupdates.events.SlotClickEvent +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class GardenDeskInSBMenu { + + private val config: Garden get() = SkyHanniMod.feature.garden + private var showItem = false + + private val item by lazy { + val neuItem = NEUItems.getItemStack("DOUBLE_PLANT") + Utils.createItemStack(neuItem.item, "§bDesk", "§7Click here to", "§7run §e/desk") + } + + + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + showItem = GardenAPI.inGarden() && config.deskInSkyBlockMenu && event.inventoryName == "SkyBlock Menu" + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + showItem = false + } + + @SubscribeEvent + fun replaceItem(event: ReplaceItemEvent) { + if (showItem && event.slotNumber == 10) { + event.replaceWith(item) + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onStackClick(event: SlotClickEvent) { + if (showItem && event.slotId == 10) { + val thePlayer = Minecraft.getMinecraft().thePlayer + thePlayer.sendChatMessage("/desk") + } + } +} \ No newline at end of file -- cgit From 60914bbaeb703cecbb3de49859faaab2207be347 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:22:50 +0100 Subject: code cleanup --- src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt index d135c78cc..e80551dec 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt @@ -50,7 +50,7 @@ class SkillExperience { } @SubscribeEvent - fun onTick(event: InventoryOpenEvent) { + fun onInventoryOpen(event: InventoryOpenEvent) { if (event.inventoryName != "Your Skills") return for ((_, stack) in event.inventoryItems) { -- cgit From 2c40f7aca20a97482a6dc6214e3697f930127217 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:23:01 +0100 Subject: 0.17.Beta.8 --- build.gradle.kts | 2 +- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7b75d47e2..fb751b72f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } group = "at.hannibal2.skyhanni" -version = "0.17.Beta.7" +version = "0.17.Beta.8" // Toolchains: java { diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 1c1617864..1922c3492 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -73,7 +73,7 @@ import java.util.List; public class SkyHanniMod { public static final String MODID = "skyhanni"; - public static final String VERSION = "0.17.Beta.7"; + public static final String VERSION = "0.17.Beta.8"; public static Features feature; -- cgit From 0d5b256fb2f5c907ec823b393535246c5ecdd262 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:27:40 +0100 Subject: Added missing changes to md files --- CHANGELOG.md | 1 + FEATURES.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9584c1dfa..19c982423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ + Added **Copper Price** - Show the price for copper inside the visitor gui. + Added **Amount and Time** - Show the exact item amount and the remaining time when farmed manually. Especially useful for ironman. + Added **Custom Keybinds** - Use custom keybinds while having a farming tool or Daedalus Axe in the hand in the garden. ++ Added Desk shortcut in sb menu. ### Features from other Mods diff --git a/FEATURES.md b/FEATURES.md index 4fe53b9c6..a5bc4c528 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -175,6 +175,7 @@ + **Amount and Time** - Show the exact item amount and the remaining time when farmed manually. Especially useful for ironman. + **Custom Keybinds** - Use custom keybinds while having a farming tool or Daedalus Axe in the hand in the garden. + **Optimal Speed** - Show the optimal speed for your current tool in the hand. (Ty MelonKingDE for the values) ++ Added Desk shortcut in sb menu. ## Commands - /wiki (using hypixel-skyblock.fandom.com instead of Hypixel wiki) -- cgit From d0484be2c2a10402fe5dfe5c0e072f4e11954662 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:42:23 +0100 Subject: cancel click on desk item. --- .../java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt index fc060bad5..e62591e47 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt @@ -43,6 +43,7 @@ class GardenDeskInSBMenu { @SubscribeEvent(priority = EventPriority.HIGH) fun onStackClick(event: SlotClickEvent) { if (showItem && event.slotId == 10) { + event.isCanceled = true val thePlayer = Minecraft.getMinecraft().thePlayer thePlayer.sendChatMessage("/desk") } -- cgit From 5267417e9ab63cb2d8692b6052716cdbb5a31774 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:40:37 +0100 Subject: make garden desk icon only show in actual skyblock menu and not in inventory --- .../java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt index e62591e47..68c35b64d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt @@ -9,6 +9,7 @@ import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent import io.github.moulberry.notenoughupdates.events.SlotClickEvent import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.Minecraft +import net.minecraft.client.player.inventory.ContainerLocalMenu import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -35,7 +36,7 @@ class GardenDeskInSBMenu { @SubscribeEvent fun replaceItem(event: ReplaceItemEvent) { - if (showItem && event.slotNumber == 10) { + if (event.inventory is ContainerLocalMenu && showItem && event.slotNumber == 10) { event.replaceWith(item) } } -- cgit From c72293ab408aed4b15754d8ef01f01bd32ad976d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 04:41:53 +0100 Subject: Added Garden Level Display. --- CHANGELOG.md | 3 +- FEATURES.md | 3 +- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../at/hannibal2/skyhanni/config/Features.java | 5 + .../hannibal2/skyhanni/config/features/Garden.java | 19 ++- .../hannibal2/skyhanni/config/features/Hidden.java | 3 + .../skyhanni/features/garden/GardenLevelDisplay.kt | 146 +++++++++++++++++++++ 7 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c982423..baa9870df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,8 @@ + Added **Copper Price** - Show the price for copper inside the visitor gui. + Added **Amount and Time** - Show the exact item amount and the remaining time when farmed manually. Especially useful for ironman. + Added **Custom Keybinds** - Use custom keybinds while having a farming tool or Daedalus Axe in the hand in the garden. -+ Added Desk shortcut in sb menu. ++ Added Desk shortcut in SkyBlock Menu. ++ Added **Garden Level Display** - Show the current garden level and progress to the next level. ### Features from other Mods diff --git a/FEATURES.md b/FEATURES.md index a5bc4c528..8c3f47364 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -175,7 +175,8 @@ + **Amount and Time** - Show the exact item amount and the remaining time when farmed manually. Especially useful for ironman. + **Custom Keybinds** - Use custom keybinds while having a farming tool or Daedalus Axe in the hand in the garden. + **Optimal Speed** - Show the optimal speed for your current tool in the hand. (Ty MelonKingDE for the values) -+ Added Desk shortcut in sb menu. ++ Desk shortcut in SkyBlock Menu. ++ **Garden Level Display** - Show the current garden level and progress to the next level. ## Commands - /wiki (using hypixel-skyblock.fandom.com instead of Hypixel wiki) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 1922c3492..04f33c824 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -216,6 +216,7 @@ public class SkyHanniMod { loadModule(new ChickenHeadTimer()); loadModule(new GardenOptimalSpeed()); loadModule(new GardenDeskInSBMenu()); + loadModule(new GardenLevelDisplay()); 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 c9ab200ca..ec666b099 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -203,6 +203,11 @@ public class Features extends Config { editOverlay(activeConfigCategory, 200, 16, garden.optimalSpeedPos); return; } + + if (runnableId.equals("gardenLevel")) { + editOverlay(activeConfigCategory, 200, 16, garden.gardenLevelPos); + 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 a288113ed..9230247ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -282,7 +282,7 @@ public class Garden { public boolean optimalSpeedEnabled = true; @Expose - @ConfigOption(name = "Enabled", desc = "Warn via title when you don't have the optimal speed.") + @ConfigOption(name = "Warning Title", desc = "Warn via title when you don't have the optimal speed.") @ConfigEditorBoolean @ConfigAccordionId(id = 9) public boolean optimalSpeedWarning = false; @@ -293,6 +293,23 @@ public class Garden { @ConfigAccordionId(id = 9) public Position optimalSpeedPos = new Position(188, -105, false, true); + @Expose + @ConfigOption(name = "Garden Level", desc = "") + @ConfigEditorAccordion(id = 10) + public boolean gardenLevel = false; + + @Expose + @ConfigOption(name = "Display", desc = "Show the current garden level and progress to the next level.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 10) + public boolean gardenLevelDisplay = true; + + @Expose + @ConfigOption(name = "Garden Level Position", desc = "") + @ConfigEditorButton(runnableId = "gardenLevel", buttonText = "Edit") + @ConfigAccordionId(id = 10) + public Position gardenLevelPos = 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 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 5bd2b3ba4..c8604aeb3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java @@ -38,4 +38,7 @@ public class Hidden { @Expose public Map gardenCropsPerSecond = new HashMap<>(); + + @Expose + public int gardenExp = -1; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt new file mode 100644 index 000000000..f40b4edc3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -0,0 +1,146 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent +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.NumberUtil.romanToDecimalIfNeeded +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern + +class GardenLevelDisplay { + private val config get() = SkyHanniMod.feature.garden + private val overflowPattern = Pattern.compile("(?:.*) §e(.*)§6\\/(?:.*)") + private val namePattern = Pattern.compile("Garden Level (.*)") + private var gardenExp + get() = SkyHanniMod.feature.hidden.gardenExp + set(value) { + SkyHanniMod.feature.hidden.gardenExp = value + } + private var display = "" + private var visitorRewardPattern = Pattern.compile(" {4}§r§8\\+§r§2(.*) §r§7Garden Experience") + + @SubscribeEvent + fun onProfileJoin(event: ProfileJoinEvent) { + update() + } + + @SubscribeEvent(receiveCanceled = true) + fun onChatMessage(event: LorenzChatEvent) { + if (!isEnabled()) return + + val matcher = visitorRewardPattern.matcher(event.message) + if (matcher.matches()) { + val moreExp = matcher.group(1).toInt() + gardenExp += moreExp + update() + } + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + if (!isEnabled()) return + if (event.inventoryName != "Desk") return + val item = event.inventoryItems[4]!! + + val name = item.name!!.removeColor() + val nameMatcher = namePattern.matcher(name) + if (!nameMatcher.matches()) return + val currentLevel = nameMatcher.group(1).romanToDecimalIfNeeded() + var overflow = 0 + for (line in item.getLore()) { + val matcher = overflowPattern.matcher(line) + if (matcher.matches()) { + overflow = matcher.group(1).replace(",", "").toInt() + break + } + } + val expForLevel = getExpForLevel(currentLevel).toInt() + gardenExp = expForLevel + overflow + update() + } + + private fun update() { + display = drawDisplay() + } + + private fun drawDisplay(): String { + if (gardenExp == -1) return "§aGarden Level ? §cOpen the desk!" + val currentLevel = getLevelForExp(gardenExp.toLong()) + val needForLevel = getExpForLevel(currentLevel).toInt() + val nextLevel = currentLevel + 1 + val needForNextLevel = getExpForLevel(nextLevel).toInt() + + return "§aGarden Level $currentLevel" + if (needForNextLevel != 0) { + val overflow = gardenExp - needForLevel + val needForOnlyNextLvl = needForNextLevel - needForLevel + + val need = LorenzUtils.formatInteger(overflow) + val have = LorenzUtils.formatInteger(needForOnlyNextLvl) + " §7(§e$need§7/§e$have§7)" + } else "" + } + + private fun getLevelForExp(gardenExp: Long): Int { + var tier = 0 + var totalCrops = 0L + for (tierCrops in gardenExperience) { + totalCrops += tierCrops + if (totalCrops > gardenExp) { + return tier + } + tier++ + } + + return tier + } + + // TODO make table utils method + private fun getExpForLevel(requestedLevel: Int): Long { + var totalCrops = 0L + var tier = 0 + for (tierCrops in gardenExperience) { + totalCrops += tierCrops + tier++ + if (tier == requestedLevel) { + return totalCrops + } + } + + return 0 + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!isEnabled()) return + + config.gardenLevelPos.renderString(display) + } + + private fun isEnabled() = GardenAPI.inGarden() && config.gardenLevelDisplay + + // TODO use repo + private val gardenExperience = listOf( + 0, + 70, + 100, + 140, + 240, + 600, + 1500, + 2000, + 2500, + 3000, + 10000, + 10000, + 10000, + 10000, + 10000, + ) +} \ No newline at end of file -- cgit From 9fa23c62020887b3db8485a8f638b18057188ef8 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 04:42:26 +0100 Subject: Code cleanup --- src/main/java/at/hannibal2/skyhanni/config/features/Misc.java | 2 +- .../hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt | 3 +-- .../java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt | 3 +-- .../java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt | 3 +-- .../at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) 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 b72565cfa..5800caf1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -219,7 +219,7 @@ public class Misc { public Position chickenHeadTimerPosition = new Position(-372, 73, false, true); @Expose - @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience bottles lying on the ground.") + @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience orbs lying on the ground.") @ConfigEditorBoolean public boolean hideExpBottles = false; diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index 2585278e5..a3dcfd131 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.features.Garden import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LorenzUtils @@ -19,7 +18,7 @@ class GardenCropMilestoneDisplay { private var needsInventory = false private val cultivatingData = mutableMapOf() private val timeTillNextCrop = mutableMapOf() - private val config: Garden get() = SkyHanniMod.feature.garden + private val config get() = SkyHanniMod.feature.garden companion object { fun getCropsPerSecond(crop: String): Int? { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt index 68c35b64d..f84e9fa44 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.features.Garden import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.utils.NEUItems @@ -15,7 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class GardenDeskInSBMenu { - private val config: Garden get() = SkyHanniMod.feature.garden + private val config get() = SkyHanniMod.feature.garden private var showItem = false private val item by lazy { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt index 1189d69cd..bbffd92f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.features.Garden import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -13,7 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern class GardenOptimalSpeed { - private val config: Garden get() = SkyHanniMod.feature.garden + private val config get() = SkyHanniMod.feature.garden private var currentSpeed = 100 private var optimalSpeed = -1 private val currentSpeedPattern = Pattern.compile(" Speed: §r§f✦(.*)") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 3f1c31fc7..6e9d51fbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -32,7 +32,7 @@ class GardenVisitorFeatures { private var tick = 0 private val copperPattern = Pattern.compile(" §8\\+§c(.*) Copper") private val offerAcceptedPattern = Pattern.compile("§6§lOFFER ACCEPTED §r§8with §r(.*) §r.*") - private val config: Garden get() = SkyHanniMod.feature.garden + private val config get() = SkyHanniMod.feature.garden companion object { var inVisitorInventory = false -- cgit From 934e489dc2c03d32233ddee7f868ba83cd2c04a5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 04:45:17 +0100 Subject: Made Kill Combo chat message hider a separate toggle --- src/main/java/at/hannibal2/skyhanni/config/features/Chat.java | 6 ++++++ src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java index 35c764116..2175baa2c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java @@ -64,6 +64,12 @@ public class Chat { @ConfigAccordionId(id = 0) public boolean powderMining = true; + @Expose + @ConfigOption(name = "Kill Combo", desc = "Hide messages about the current kill combo from the Grandma Wolf Pet.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean killCombo = false; + //TODO remove @Expose @ConfigOption(name = "Others", desc = "Hide other annoying messages.") 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..1313e45b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -26,8 +26,8 @@ class ChatFilter { 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.killCombo -> "kill_combo" - 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" -- cgit From 9b162db4fe01adf93f5dadf61bc949ce58735138 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 04:48:51 +0100 Subject: Made watchdog announcement chat message hider a separate toggle --- .../hannibal2/skyhanni/config/features/Chat.java | 6 +++ .../hannibal2/skyhanni/features/chat/ChatFilter.kt | 45 +++++++++++----------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java index 2175baa2c..970cc43fc 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java @@ -70,6 +70,12 @@ public class Chat { @ConfigAccordionId(id = 0) public boolean killCombo = false; + @Expose + @ConfigOption(name = "Watchdog", desc = "Hide the message where hypixel is flexing how many players they have banned over the last week.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean watchDog = true; + //TODO remove @Expose @ConfigOption(name = "Others", desc = "Hide other annoying messages.") 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 1313e45b2..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.killCombo -> "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 -> "" -- cgit From 3708ce586e00ca92bdda89c2e9216c8842f7bfda Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 04:50:06 +0100 Subject: change color --- .../at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 6e9d51fbf..b783e9093 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.features.Garden import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ScoreboardData.Companion.sidebarLinesFormatted import at.hannibal2.skyhanni.data.SendTitleHelper @@ -280,7 +279,7 @@ class GardenVisitorFeatures { if (entity is EntityLivingBase) { if (visitor.done) { - val color = LorenzColor.DARK_GRAY.toColor().withAlpha(120) + val color = LorenzColor.DARK_GRAY.toColor().withAlpha(60) RenderLivingEntityHelper.setEntityColor(entity, color) { config.visitorHighlight } } else if (visitor.items.isEmpty()) { -- cgit From f3a0cc2e602879e2a3b2818a1b412aef8935aa23 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 05:05:36 +0100 Subject: 0.17.Beta.9 --- build.gradle.kts | 2 +- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index fb751b72f..43b4324c6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } group = "at.hannibal2.skyhanni" -version = "0.17.Beta.8" +version = "0.17.Beta.9" // Toolchains: java { diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 04f33c824..12fa965cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -73,7 +73,7 @@ import java.util.List; public class SkyHanniMod { public static final String MODID = "skyhanni"; - public static final String VERSION = "0.17.Beta.8"; + public static final String VERSION = "0.17.Beta.9"; public static Features feature; -- cgit From 7835491a42dbe69117dce2b2129930e90e6824ab Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 13:00:27 +0100 Subject: Fixed bug in garden level calculation --- .../java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt index f40b4edc3..afef573e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern +import kotlin.math.roundToInt class GardenLevelDisplay { private val config get() = SkyHanniMod.feature.garden @@ -57,7 +58,7 @@ class GardenLevelDisplay { for (line in item.getLore()) { val matcher = overflowPattern.matcher(line) if (matcher.matches()) { - overflow = matcher.group(1).replace(",", "").toInt() + overflow = matcher.group(1).replace(",", "").toDouble().roundToInt() break } } -- cgit From f7bf28d954a35f8a24d3a8c883d507be1722b570 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 13:02:07 +0100 Subject: Showing gui elements while pressing tab list key again --- .../skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt | 2 -- src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 3 --- 2 files changed, 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index c2da6f5c8..18659e587 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -21,7 +21,6 @@ import net.minecraft.item.ItemStack import net.minecraft.network.play.server.S45PacketTitle import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import org.lwjgl.input.Keyboard class BlazeSlayerDaggerHelper { @@ -251,7 +250,6 @@ class BlazeSlayerDaggerHelper { if (textTopLeft.isEmpty()) return if (Minecraft.getMinecraft().currentScreen != null) return - if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.keyCode)) return val scaledResolution = ScaledResolution(Minecraft.getMinecraft()) val width = scaledResolution.scaledWidth diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 742f81f38..62a8c2c61 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -430,7 +430,6 @@ object RenderUtils { fun Position.renderString(string: String?, extraOffsetX: Int = 0, offsetY: Int = 0, center: Boolean = true) { val minecraft = Minecraft.getMinecraft() - if (minecraft.gameSettings.keyBindPlayerList.isKeyDown) return if (string == null) return if (string == "") return @@ -457,7 +456,6 @@ object RenderUtils { } fun Position.renderStrings(list: List, extraSpace: Int = 0, center: Boolean = false) { - if (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isKeyDown) return if (list.isEmpty()) return var offsetY = 0 @@ -472,7 +470,6 @@ object RenderUtils { * Each line is a list of things to print. Can print String or ItemStack objects. */ fun Position.renderStringsAndItems(list: List>, extraSpace: Int = 0) { - if (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isKeyDown) return if (list.isEmpty()) return var offsetY = 0 -- cgit From 96e187cc5839c74725444dacdf854bdeebde568f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 10 Mar 2023 13:02:18 +0100 Subject: 0.17.Beta.10 --- build.gradle.kts | 2 +- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 43b4324c6..14459c0da 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } group = "at.hannibal2.skyhanni" -version = "0.17.Beta.9" +version = "0.17.Beta.10" // Toolchains: java { diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 12fa965cf..d966acab0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -73,7 +73,7 @@ import java.util.List; public class SkyHanniMod { public static final String MODID = "skyhanni"; - public static final String VERSION = "0.17.Beta.9"; + public static final String VERSION = "0.17.Beta.10"; public static Features feature; -- cgit From 200e41dd8c85d24c3d0793bd43caaed726cc1969 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 11 Mar 2023 03:39:43 +0100 Subject: Added reminder about outdated neu versions on NoSuchMethodError errors. --- src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index 95ce8823f..c499c3f34 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -38,8 +38,12 @@ abstract class LorenzEvent : Event() { } result }.onFailure { - it.printStackTrace() - LorenzUtils.chat("§cSkyHanni caught and logged an ${it::class.simpleName ?: "error"} at ${eventName}.") + if (it is NoSuchMethodError) { + LorenzUtils.chat("§c[SkyHanni] You need to use a newer version of NotEnoughUpdates (alpha-11 or newer)! If you need help downloading it, go to the skyhanni discord.") + } else { + it.printStackTrace() + LorenzUtils.chat("§cSkyHanni caught and logged an ${it::class.simpleName ?: "error"} at ${eventName}.") + } }.getOrDefault(isCanceled) } } \ No newline at end of file -- cgit From e6d4582f2e816b4645a8d1b9c1facafb16cb5e6d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 11 Mar 2023 04:04:13 +0100 Subject: moved GardenBestCropTime into a own class --- .../skyhanni/features/garden/GardenAPI.kt | 22 +++++ .../skyhanni/features/garden/GardenBestCropTime.kt | 84 ++++++++++++++++ .../features/garden/GardenCropMilestoneDisplay.kt | 106 ++------------------- .../features/garden/GardenVisitorFeatures.kt | 2 +- 4 files changed, 115 insertions(+), 99 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index a8f8e84a8..9c4b46fb8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -1,12 +1,15 @@ package at.hannibal2.skyhanni.features.garden +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GardenToolChangeEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.Minecraft import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -27,6 +30,16 @@ class GardenAPI { } } + @SubscribeEvent(priority = EventPriority.LOW) + fun onProfileJoin(event: ProfileJoinEvent) { + if (cropsPerSecond.isEmpty()) { + // TODO use enum + for (key in GardenCropMilestones.cropCounter.keys) { + cropsPerSecond[key] = -1 + } + } + } + private fun loadCropInHand(): String? { val heldItem = Minecraft.getMinecraft().thePlayer.heldItem ?: return null if (readCounter(heldItem) == -1) return null @@ -38,6 +51,7 @@ class GardenAPI { fun inGarden() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.GARDEN var cropInHand: String? = null + val cropsPerSecond: MutableMap get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond fun getCropTypeFromItem(heldItem: ItemStack): String? { val name = heldItem.name ?: return null @@ -76,5 +90,13 @@ class GardenAPI { } return -1 } + + fun getCropsPerSecond(itemName: String): Int? { + if (itemName.endsWith(" Mushroom")) { + return cropsPerSecond["Mushroom"] + } + return cropsPerSecond[itemName] + } + } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt new file mode 100644 index 000000000..d5920658f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt @@ -0,0 +1,84 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.GardenCropMilestones +import at.hannibal2.skyhanni.utils.LorenzUtils.sorted +import at.hannibal2.skyhanni.utils.TimeUtils +import java.util.* + +class GardenBestCropTime { + val display = mutableListOf>() + val timeTillNextCrop = mutableMapOf() + private val config get() = SkyHanniMod.feature.garden + + fun drawBestDisplay(currentCrop: String?) { + if (timeTillNextCrop.size < GardenAPI.cropsPerSecond.size) { + updateTimeTillNextCrop() + } + + val gardenExp = config.cropMilestoneBestType == 0 + val sorted = if (gardenExp) { + val helpMap = mutableMapOf() + for ((cropName, time) in timeTillNextCrop) { + val crops = GardenCropMilestones.cropCounter[cropName]!! + val currentTier = GardenCropMilestones.getTierForCrops(crops) + val gardenExpForTier = getGardenExpForTier(currentTier + 1) + val fakeTime = time / gardenExpForTier + helpMap[cropName] = fakeTime + } + helpMap.sorted() + } else { + timeTillNextCrop.sorted() + } + + val title = if (gardenExp) "§2Garden Experience" else "§bSkyBlock Level" + display.add(Collections.singletonList("§eBest Crop Time §7($title§7)")) + + if (sorted.isEmpty()) { + display.add(Collections.singletonList("§cFarm crops to add them to this list!")) + } + + var number = 0 + for (cropName in sorted.keys) { + val millis = timeTillNextCrop[cropName]!! + val duration = TimeUtils.formatDuration(millis) + + val isCurrent = cropName == currentCrop + val color = if (isCurrent) "§e" else "" + number++ + if (number > config.cropMilestoneShowOnlyBest && !isCurrent) continue + val cropNameDisplay = "$number# $color$cropName" + if (gardenExp) { + val crops = GardenCropMilestones.cropCounter[cropName]!! + val currentTier = GardenCropMilestones.getTierForCrops(crops) + val gardenExpForTier = getGardenExpForTier(currentTier + 1) + display.add(Collections.singletonList(" $cropNameDisplay §b$duration §7(§2$gardenExpForTier §7Exp)")) + } else { + display.add(Collections.singletonList(" $cropNameDisplay §b$duration")) + } + } + } + + private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 + + fun updateTimeTillNextCrop() { + for ((cropName, speed) in GardenAPI.cropsPerSecond) { + if (speed == -1) continue + + val crops = GardenCropMilestones.cropCounter[cropName]!! + val currentTier = GardenCropMilestones.getTierForCrops(crops) + + val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier) + val nextTier = currentTier + 1 + val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier) + + val have = crops - cropsForCurrentTier + val need = cropsForNextTier - cropsForCurrentTier + + val missing = need - have + val missingTimeSeconds = missing / speed + val millis = missingTimeSeconds * 1000 + timeTillNextCrop[cropName] = millis + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index a3dcfd131..2854aec45 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -4,7 +4,6 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.TimeUtils @@ -14,22 +13,11 @@ import java.util.* class GardenCropMilestoneDisplay { private val progressDisplay = mutableListOf>() - private val bestCropDisplay = mutableListOf>() private var needsInventory = false private val cultivatingData = mutableMapOf() - private val timeTillNextCrop = mutableMapOf() private val config get() = SkyHanniMod.feature.garden - companion object { - fun getCropsPerSecond(crop: String): Int? { - if (crop.endsWith(" Mushroom")) { - return cropsPerSecond["Mushroom"] - } - return cropsPerSecond[crop] - } - - private val cropsPerSecond: MutableMap get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond - } + private val bestCropTime = GardenBestCropTime() @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { @@ -37,7 +25,7 @@ class GardenCropMilestoneDisplay { config.cropMilestoneProgressDisplayPos.renderStringsAndItems(progressDisplay) if (config.cropMilestoneBestDisplay) { - config.cropMilestoneNextDisplayPos.renderStringsAndItems(bestCropDisplay) + config.cropMilestoneNextDisplayPos.renderStringsAndItems(bestCropTime.display) } } @@ -46,17 +34,12 @@ class GardenCropMilestoneDisplay { if (GardenCropMilestones.cropCounter.values.sum() == 0L) { needsInventory = true } - if (cropsPerSecond.isEmpty()) { - for (key in GardenCropMilestones.cropCounter.keys) { - cropsPerSecond[key] = -1 - } - } } @SubscribeEvent fun onCropMilestoneUpdate(event: CropMilestoneUpdateEvent) { needsInventory = false - updateTimeTillNextCrop() + bestCropTime.updateTimeTillNextCrop() update() } @@ -96,12 +79,10 @@ class GardenCropMilestoneDisplay { if (System.currentTimeMillis() > lastSecondStart + 1_000) { lastSecondStart = System.currentTimeMillis() if (countInLastSecond > 8) { -// println("currentSpeed: $currentSpeed") allCounters.add(currentSpeed) while (allCounters.size > 30) { allCounters.removeFirst() } -// println("allCounters: $allCounters") averageSpeedPerSecond = allCounters.average().toInt() } countInLastSecond = 0 @@ -121,7 +102,7 @@ class GardenCropMilestoneDisplay {