From 0707ac473037146819c5a43c808b6ee41f014a63 Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Mon, 6 Sep 2021 22:16:11 -0400 Subject: Add ability cooldown display --- src/main/java/me/Danker/utils/Utils.java | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/main/java/me/Danker/utils') diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java index 71fc4ba..f7ebad6 100644 --- a/src/main/java/me/Danker/utils/Utils.java +++ b/src/main/java/me/Danker/utils/Utils.java @@ -9,6 +9,7 @@ import me.Danker.handlers.ScoreboardHandler; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; @@ -421,4 +422,45 @@ public class Utils { System.out.println("Refreshed DSM repo at " + System.currentTimeMillis()); } + public static int getCooldownFromAbility(String ability) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + boolean foundAbility = false; + + List itemsToSearch = new ArrayList<>(); + + for (int i = 0; i < 8; i++) { + ItemStack hotbarItem = player.inventory.getStackInSlot(i); + if (hotbarItem == null) continue; + itemsToSearch.add(hotbarItem); + } + + for (int i = 0; i < 4; i++) { + ItemStack armorItem = player.inventory.armorItemInSlot(0); + if (armorItem == null) continue; + itemsToSearch.add(armorItem); + } + + for (ItemStack item : itemsToSearch) { + List tooltip = item.getTooltip(player, false); + + for (String line : tooltip) { + System.out.println(line); + if (line.contains(EnumChatFormatting.GOLD + "Ability: ")) { + if (line.contains(EnumChatFormatting.GOLD + "Ability: " + ability)) { + foundAbility = true; + continue; + } else if (foundAbility) { + break; + } + } + + if (foundAbility && line.contains(EnumChatFormatting.DARK_GRAY + "Cooldown: ")) { + return Integer.parseInt(StringUtils.stripControlCodes(line).replaceAll("[^\\d]", "")); + } + } + } + + return 0; + } + } -- cgit