aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/Danker/utils')
-rw-r--r--src/main/java/me/Danker/utils/Utils.java42
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;
+ }
+
}