aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2021-09-07 17:14:40 -0400
committerbowser0000 <bowser0000@gmail.com>2021-09-07 17:14:40 -0400
commit7b78e67b434e427b696a43a95b9bb6705da41ad8 (patch)
tree100fcee3e40d931eebded09297a3a02577aa8286 /src
parentf64d52798778df323f4e7778fff98e240cde4e83 (diff)
downloadSkyblockMod-7b78e67b434e427b696a43a95b9bb6705da41ad8.tar.gz
SkyblockMod-7b78e67b434e427b696a43a95b9bb6705da41ad8.tar.bz2
SkyblockMod-7b78e67b434e427b696a43a95b9bb6705da41ad8.zip
Make cooldown display work with mage cooldown reduction
Diffstat (limited to 'src')
-rw-r--r--src/main/java/me/Danker/DankersSkyblockMod.java2
-rw-r--r--src/main/java/me/Danker/features/AbilityCooldowns.java73
-rw-r--r--src/main/java/me/Danker/utils/Utils.java5
3 files changed, 66 insertions, 14 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java
index b0e0de0..1998f41 100644
--- a/src/main/java/me/Danker/DankersSkyblockMod.java
+++ b/src/main/java/me/Danker/DankersSkyblockMod.java
@@ -100,6 +100,7 @@ public class DankersSkyblockMod {
@EventHandler
public void init(FMLInitializationEvent event) throws UnsupportedAudioFileException, IOException, LineUnavailableException {
MinecraftForge.EVENT_BUS.register(this);
+ MinecraftForge.EVENT_BUS.register(new AbilityCooldowns());
MinecraftForge.EVENT_BUS.register(new ArachneESP());
MinecraftForge.EVENT_BUS.register(new AutoAcceptReparty());
MinecraftForge.EVENT_BUS.register(new AutoDisplay());
@@ -127,7 +128,6 @@ public class DankersSkyblockMod {
MinecraftForge.EVENT_BUS.register(new HideTooltipsInExperiments());
MinecraftForge.EVENT_BUS.register(new HighlightSkeletonMasters());
MinecraftForge.EVENT_BUS.register(new IceWalkSolver());
- MinecraftForge.EVENT_BUS.register(new AbilityCooldowns());
MinecraftForge.EVENT_BUS.register(new LividSolver());
MinecraftForge.EVENT_BUS.register(new LowHealthNotifications());
MinecraftForge.EVENT_BUS.register(new NecronNotifications());
diff --git a/src/main/java/me/Danker/features/AbilityCooldowns.java b/src/main/java/me/Danker/features/AbilityCooldowns.java
index ed6767e..397857a 100644
--- a/src/main/java/me/Danker/features/AbilityCooldowns.java
+++ b/src/main/java/me/Danker/features/AbilityCooldowns.java
@@ -2,45 +2,63 @@ package me.Danker.features;
import me.Danker.commands.MoveCommand;
import me.Danker.commands.ScaleCommand;
+import me.Danker.commands.ToggleCommand;
import me.Danker.events.RenderOverlayEvent;
import me.Danker.handlers.TextRenderer;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
+import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.ArrayList;
import java.util.List;
public class AbilityCooldowns {
- List<Ability> cooldowns = new ArrayList<>();
+ static List<Ability> cooldowns = new ArrayList<>();
+ static double mageReduction = 0D;
@SubscribeEvent(priority = EventPriority.LOW)
public void onChat(ClientChatReceivedEvent event) {
- if (!Utils.inSkyblock || event.type != 2) return;
+ if (!Utils.inSkyblock || !ToggleCommand.abilityCooldowns) return;
- String[] actionBarSections = StringUtils.stripControlCodes(event.message.getUnformattedText()).split(" {3,}");
+ if (event.type == 2) {
+ String[] actionBarSections = StringUtils.stripControlCodes(event.message.getUnformattedText()).split(" {3,}");
- for (String section : actionBarSections) {
- if (section.charAt(0) == '-' && section.contains("(") && section.charAt(section.length() - 1) == ')') {
- String ability = section.substring(section.indexOf("(") + 1, section.length() - 1);
+ for (String section : actionBarSections) {
+ if (section.charAt(0) == '-' && section.contains("(") && section.charAt(section.length() - 1) == ')') {
+ String ability = section.substring(section.indexOf("(") + 1, section.length() - 1);
- for (Ability cooldown : cooldowns) {
- if (cooldown.ability.equals(ability)) return;
+ for (Ability cooldown : cooldowns) {
+ if (cooldown.ability.equals(ability)) return;
+ }
+
+ cooldowns.add(new Ability(ability, Utils.getCooldownFromAbility(ability) * (1D - mageReduction)));
}
+ }
+ } else {
+ String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
- cooldowns.add(new Ability(ability, Utils.getCooldownFromAbility(ability)));
+ if (Utils.inDungeons && message.startsWith("[Mage] Cooldown Reduction ")) {
+ mageReduction = Integer.parseInt(message.substring(message.indexOf(">") + 2, message.length() - 1)) / 100D;
}
}
}
@SubscribeEvent
public void renderPlayerInfo(RenderOverlayEvent event) {
- if (Utils.inSkyblock) {
+ if (ToggleCommand.abilityCooldowns && Utils.inSkyblock) {
StringBuilder sb = new StringBuilder();
for (int i = cooldowns.size() - 1; i >= 0; i--) {
@@ -58,14 +76,45 @@ public class AbilityCooldowns {
}
}
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.START) return;
+
+ Minecraft mc = Minecraft.getMinecraft();
+ EntityPlayerSP player = mc.thePlayer;
+ if (mc.currentScreen instanceof GuiChest) {
+ if (player == null) return;
+ ContainerChest chest = (ContainerChest) player.openContainer;
+ List<Slot> invSlots = ((GuiChest) mc.currentScreen).inventorySlots.inventorySlots;
+ String chestName = chest.getLowerChestInventory().getDisplayName().getUnformattedText().trim();
+
+ if (ToggleCommand.abilityCooldowns && Utils.inDungeons && chestName.startsWith("Catacombs - ")) {
+ ItemStack mage = invSlots.get(30).getStack();
+ if (mage == null || mage.getDisplayName() == null) return;
+ if (mage.isItemEnchanted()) {
+ String display = mage.getDisplayName();
+ mageReduction = Utils.getCooldownReductionFromLevel(Integer.parseInt(display.substring(display.indexOf(" ") + 1, display.indexOf("]"))));
+ } else {
+ mageReduction = 0D;
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldChange(WorldEvent.Load event) {
+ cooldowns.clear();
+ mageReduction = 0D;
+ }
+
public static class Ability {
public final String ability;
private final long cooldown;
- public Ability(String ability, int cooldown) {
+ public Ability(String ability, double cooldown) {
this.ability = ability;
- this.cooldown = System.currentTimeMillis() + cooldown * 1000L;
+ this.cooldown = (long) (System.currentTimeMillis() + cooldown * 1000L);
}
public String getTimer() {
diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java
index f7ebad6..81a32af 100644
--- a/src/main/java/me/Danker/utils/Utils.java
+++ b/src/main/java/me/Danker/utils/Utils.java
@@ -444,7 +444,6 @@ public class Utils {
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;
@@ -463,4 +462,8 @@ public class Utils {
return 0;
}
+ public static double getCooldownReductionFromLevel(int level) {
+ return (Math.floor(level / 2D) + 25) / 100D;
+ }
+
}