diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-09-06 22:16:11 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-09-06 22:16:11 -0400 |
commit | 0707ac473037146819c5a43c808b6ee41f014a63 (patch) | |
tree | 52ba2e13880c3e67e03b219a03b967d3f5c913df /src/main/java/me/Danker/utils | |
parent | 6bc2a39f06664f55e8fe2eae06ddecb38173c6b5 (diff) | |
download | SkyblockMod-0707ac473037146819c5a43c808b6ee41f014a63.tar.gz SkyblockMod-0707ac473037146819c5a43c808b6ee41f014a63.tar.bz2 SkyblockMod-0707ac473037146819c5a43c808b6ee41f014a63.zip |
Add ability cooldown display
Diffstat (limited to 'src/main/java/me/Danker/utils')
-rw-r--r-- | src/main/java/me/Danker/utils/Utils.java | 42 |
1 files changed, 42 insertions, 0 deletions
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<ItemStack> 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<String> 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; + } + } |