aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/handlers
diff options
context:
space:
mode:
authorThatGravyBoat <thatgravyboat@gmail.com>2021-09-27 14:17:41 -0230
committerThatGravyBoat <thatgravyboat@gmail.com>2021-09-27 14:17:41 -0230
commitf1fd06d889162ac72395ef66043970cfe42cde5e (patch)
tree1e306d5817eac77ac44ef59085120882f8824d7a /src/main/java/com/thatgravyboat/skyblockhud/handlers
parent7809a1362c9644c9bfb69d8563a13e3f1ed3354a (diff)
downloadSkyblockHud-Death-Defied-f1fd06d889162ac72395ef66043970cfe42cde5e.tar.gz
SkyblockHud-Death-Defied-f1fd06d889162ac72395ef66043970cfe42cde5e.tar.bz2
SkyblockHud-Death-Defied-f1fd06d889162ac72395ef66043970cfe42cde5e.zip
I dont even know when I coded this.
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/handlers')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java3
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java38
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java42
4 files changed, 59 insertions, 28 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java
index 1467b48..d605d81 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java
@@ -3,7 +3,6 @@ package com.thatgravyboat.skyblockhud.handlers;
import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.location.LocationHandler;
import com.thatgravyboat.skyblockhud.location.Locations;
-import com.thatgravyboat.skyblockhud.location.MinesHandler;
import com.thatgravyboat.skyblockhud.utils.Utils;
import net.minecraft.entity.boss.BossStatus;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
@@ -22,7 +21,7 @@ public class BossbarHandler {
bossBarRendered = false;
}
String bossName = Utils.removeColor(BossStatus.bossName);
- if (SkyblockHud.config.renderer.hideBossBar && MinesHandler.currentEvent == MinesHandler.Event.NONE && !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) {
+ if (SkyblockHud.config.renderer.hideBossBar && !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) {
if (bossName.equalsIgnoreCase("wither")) {
event.setCanceled(true);
bossBarRendered = false;
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java
index d7d3a41..8704bdb 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java
@@ -1,17 +1,19 @@
package com.thatgravyboat.skyblockhud.handlers;
+import com.google.common.collect.Sets;
import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.api.item.IAbility;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.thatgravyboat.skyblockhud.utils.Utils;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
+import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
@@ -21,6 +23,9 @@ public class CooldownHandler {
private static final Map<String, Cooldown> COOLDOWNS = new HashMap<>();
+ private static final Set<String> CUSTOM_HANDLED_COOLDOWNS = Sets.newHashSet("Mining Speed Boost");
+
+
public static Matcher getAbility(NBTTagCompound nbt) {
if (nbt != null && nbt.hasKey("ExtraAttributes") && nbt.getCompoundTag("ExtraAttributes").hasKey("uuid") && nbt.hasKey("display")){
NBTTagCompound display = nbt.getCompoundTag("display");
@@ -40,8 +45,27 @@ public class CooldownHandler {
return null;
}
- private static void addCooldown(IAbility ability) {
- COOLDOWNS.putIfAbsent(ability.getAbility(), new Cooldown(ability.getAbilityTime()*20));
+ private static void addCooldown(String id, int time) {
+ COOLDOWNS.putIfAbsent(id, new Cooldown(time*20));
+ }
+
+ private static void addCooldown(IAbility ability, boolean isForced) {
+ if (isForced || !CUSTOM_HANDLED_COOLDOWNS.contains(ability.getAbility())) {
+ addCooldown(ability.getAbility(), ability.getAbilityTime());
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ public void onChat(ClientChatReceivedEvent event){
+ String message = Utils.removeColor(event.message.getUnformattedText());
+ if (event.type != 2 && message.equals("You used your Mining Speed Boost Pickaxe Ability!")){
+ if (Minecraft.getMinecraft().thePlayer.getHeldItem() != null) {
+ IAbility ability = (IAbility) (Object) Minecraft.getMinecraft().thePlayer.getHeldItem();
+ if (ability.getAbility().equals("Mining Speed Boost")) {
+ addCooldown("Mining Speed Boost", ability.getAbilityTime());
+ }
+ }
+ }
}
@SubscribeEvent
@@ -60,7 +84,7 @@ public class CooldownHandler {
if (event.entityPlayer.getHeldItem() != null) {
IAbility ability = (IAbility)((Object) event.entityPlayer.getHeldItem());
if (ability.getAbility() != null) {
- addCooldown(ability);
+ addCooldown(ability, false);
}
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java
index 482dbe1..7bbfaa0 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java
@@ -51,7 +51,7 @@ public class CurrencyHandler {
public static String getCoinsFormatted() {
DecimalFormat formatter = new DecimalFormat("#,###.0", DecimalFormatSymbols.getInstance(Locale.CANADA));
- String output = formatter.format(coins);
+ String output = formatter.format(getCoins());
if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0";
return output;
}
@@ -59,7 +59,7 @@ public class CurrencyHandler {
public static String getBitsFormatted() {
DecimalFormat formatter = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA));
formatter.setRoundingMode(RoundingMode.FLOOR);
- return bits > 999 ? formatter.format((double) bits / 1000) + "k" : String.valueOf(bits);
+ return getBits() > 999 ? formatter.format((double) getBits() / 1000) + "k" : String.valueOf(getBits());
}
public static void checkCoins(String formatedScoreboardLine) {
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java
index 1e67034..a1764bd 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java
@@ -23,6 +23,7 @@ import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
+import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
@@ -36,9 +37,8 @@ public class NpcDialogue implements IResourceManagerReloadListener {
private static boolean showDialogue = false;
private static int ticks = 0;
- private static final Queue<String> DIALOGUE = new ArrayDeque<>();
- private static String currentNpc = "Unknown";
- private static String currentDialogue = null;
+ private static final Queue<Dialogue> DIALOGUE = new ArrayDeque<>();
+ private static Dialogue currentDialogue = null;
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
@@ -50,12 +50,11 @@ public class NpcDialogue implements IResourceManagerReloadListener {
if (currentDialogue == null) {
showDialogue = false;
- currentNpc = "Unknown";
}
}
}
- @SubscribeEvent
+ @SubscribeEvent(priority = EventPriority.LOWEST)
public void onChat(ClientChatReceivedEvent event) {
if (event.type != 2 && !SkyblockHud.config.misc.hideDialogueBox) {
String message = Utils.removeColor(event.message.getUnformattedText());
@@ -64,12 +63,10 @@ public class NpcDialogue implements IResourceManagerReloadListener {
if (matcher.find()) {
showDialogue = true;
event.setCanceled(true);
- currentNpc = matcher.group(1);
- if (currentDialogue != null) {
- DIALOGUE.add(matcher.group(2));
- } else {
- currentDialogue = matcher.group(2);
- }
+
+ Dialogue dialogue = new Dialogue(matcher.group(1), matcher.group(2));
+ if (currentDialogue == null) currentDialogue = dialogue;
+ else DIALOGUE.add(dialogue);
}
}
}
@@ -87,7 +84,7 @@ public class NpcDialogue implements IResourceManagerReloadListener {
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, 182, 68, 256, 256);
- String npcID = currentNpc.toLowerCase(Locale.ENGLISH).replace(" ", "_");
+ String npcID = currentDialogue.name.toLowerCase(Locale.ENGLISH).replace(" ", "_");
if (NPCS.containsKey(npcID)) {
mc.renderEngine.bindTexture(NPCS.get(npcID));
@@ -96,12 +93,10 @@ public class NpcDialogue implements IResourceManagerReloadListener {
FontRenderer font = mc.fontRendererObj;
- font.drawString(currentNpc, x + 40, y + 10, 0xffffff);
-
- List<String> text = font.listFormattedStringToWidth(currentDialogue, 160);
+ font.drawString(currentDialogue.name, x + 40, y + 10, 0xffffff);
- for (int i = 0; i < text.size(); i++) {
- Utils.drawStringScaled(text.get(i), font, x + 40, y + 10 + font.FONT_HEIGHT + 6 + (i * font.FONT_HEIGHT + 3), false, 0xffffff, 0.75f);
+ for (int i = 0; i < currentDialogue.dialogue.size(); i++) {
+ Utils.drawStringScaled(currentDialogue.dialogue.get(i), font, x + 40, y + 10 + font.FONT_HEIGHT + 6 + (i * font.FONT_HEIGHT + 3), false, 0xffffff, 0.75f);
}
}
}
@@ -123,4 +118,17 @@ public class NpcDialogue implements IResourceManagerReloadListener {
}
} catch (Exception ignored) {}
}
+
+
+ static class Dialogue {
+
+ public List<String> dialogue;
+ public String name;
+
+ public Dialogue(String name, String dialogue) {
+ this.dialogue = Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(dialogue, 160);
+ this.name = name;
+ }
+
+ }
}