aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorThatGravyBoat <thatgravyboat@gmail.com>2021-07-27 04:38:13 -0230
committerThatGravyBoat <thatgravyboat@gmail.com>2021-07-27 04:38:13 -0230
commit7809a1362c9644c9bfb69d8563a13e3f1ed3354a (patch)
treed8e1a33db7656aa2aeaa9fcc44e2310df35b774d /src/main
parent39749967fc92a3976b231285492d71f8782e93da (diff)
downloadSkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.tar.gz
SkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.tar.bz2
SkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.zip
Added Dynamic Item Cooldowns.
Updated Profile Events to contain profile name. Added copy NPC skin command. Added warphandler gives me access to what warps you have. Moved all config and data files into its own folder. Added option to turn off adding back overflow mana.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java35
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileJoinedEvent.java12
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileSwitchedEvent.java10
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/item/IAbility.java8
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java13
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java12
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java98
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java172
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java2
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java13
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java42
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java41
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java2
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java9
-rw-r--r--src/main/resources/mixins.skyblockhud.json5
16 files changed, 456 insertions, 22 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
index 4741a1b..9b3da58 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
@@ -5,6 +5,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.thatgravyboat.skyblockhud.api.KillTracking;
import com.thatgravyboat.skyblockhud.api.LeaderboardGetter;
+import com.thatgravyboat.skyblockhud.api.events.ProfileJoinedEvent;
import com.thatgravyboat.skyblockhud.api.events.ProfileSwitchedEvent;
import com.thatgravyboat.skyblockhud.commands.Commands;
import com.thatgravyboat.skyblockhud.config.KeyBindings;
@@ -51,7 +52,7 @@ import org.lwjgl.input.Keyboard;
public class SkyblockHud {
public static final String MODID = "skyblockhud";
- public static final String VERSION = "1.12";
+ public static final String VERSION = "1.13";
public static SBHConfig config;
@@ -61,7 +62,7 @@ public class SkyblockHud {
private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
- private static File configDirectory;
+ public static File configDirectory;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
@@ -88,12 +89,17 @@ public class SkyblockHud {
MinecraftForge.EVENT_BUS.register(new ActionBarParsing());
MinecraftForge.EVENT_BUS.register(new CrystalWaypoints());
MinecraftForge.EVENT_BUS.register(new FarmHouseHandler());
+ MinecraftForge.EVENT_BUS.register(new WarpHandler());
+ MinecraftForge.EVENT_BUS.register(new CooldownHandler());
Commands.init();
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new NpcDialogue());
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new Textures());
- configFile = new File(event.getModConfigurationDirectory(), "sbh-config.json");
+ configDirectory = new File(event.getModConfigurationDirectory(), "skyblockhud");
+ try { configDirectory.mkdir(); } catch (Exception ignored){}
+
+ configFile = new File(configDirectory, "sbh-config.json");
if (configFile.exists()) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) {
@@ -108,10 +114,12 @@ public class SkyblockHud {
Textures.setTexture(config.misc.style);
- configDirectory = event.getModConfigurationDirectory();
+ if (WarpHandler.load()) {
+ WarpHandler.save();
+ }
Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig));
- Runtime.getRuntime().addShutdownHook(new Thread(() -> TrackerFileLoader.saveTrackerStatsFile(event.getModConfigurationDirectory())));
+ Runtime.getRuntime().addShutdownHook(new Thread(TrackerFileLoader::saveTrackerStatsFile));
}
public void saveConfig() {
@@ -139,14 +147,14 @@ public class SkyblockHud {
public void loadComplete(FMLLoadCompleteEvent event) {
TrackerFileLoader.loadTrackersFile();
- if (TrackerFileLoader.loadTrackerStatsFile(configDirectory)) {
- TrackerFileLoader.saveTrackerStatsFile(configDirectory);
+ if (TrackerFileLoader.loadTrackerStatsFile()) {
+ TrackerFileLoader.saveTrackerStatsFile();
}
}
@SubscribeEvent
public void onLeaveServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
- TrackerFileLoader.saveTrackerStatsFile(configDirectory);
+ TrackerFileLoader.saveTrackerStatsFile();
}
public static boolean hasSkyblockScoreboard() {
@@ -180,8 +188,15 @@ public class SkyblockHud {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onStatusBar(ClientChatReceivedEvent event) {
- if (Utils.removeColor(event.message.getUnformattedText()).toLowerCase().trim().startsWith("your profile was changed to:")) {
- MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent());
+ String message = Utils.removeColor(event.message.getUnformattedText()).toLowerCase().trim();
+
+ if (message.startsWith("your profile was changed to:")) {
+ String stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim();
+ MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent(stripped));
+ }
+ if (message.startsWith("you are playing on profile:")){
+ String stripped = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim();
+ MinecraftForge.EVENT_BUS.post(new ProfileJoinedEvent(stripped));
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileJoinedEvent.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileJoinedEvent.java
new file mode 100644
index 0000000..ba24a5d
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileJoinedEvent.java
@@ -0,0 +1,12 @@
+package com.thatgravyboat.skyblockhud.api.events;
+
+import net.minecraftforge.fml.common.eventhandler.Event;
+
+public class ProfileJoinedEvent extends Event {
+
+ public String profile;
+
+ public ProfileJoinedEvent(String profile){
+ this.profile = profile;
+ }
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileSwitchedEvent.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileSwitchedEvent.java
index 9402858..e8561c6 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileSwitchedEvent.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileSwitchedEvent.java
@@ -2,4 +2,12 @@ package com.thatgravyboat.skyblockhud.api.events;
import net.minecraftforge.fml.common.eventhandler.Event;
-public class ProfileSwitchedEvent extends Event {}
+public class ProfileSwitchedEvent extends Event {
+
+ public String profile;
+
+ public ProfileSwitchedEvent(String profile){
+ this.profile = profile;
+ }
+
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/item/IAbility.java b/src/main/java/com/thatgravyboat/skyblockhud/api/item/IAbility.java
new file mode 100644
index 0000000..bd7e81f
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/item/IAbility.java
@@ -0,0 +1,8 @@
+package com.thatgravyboat.skyblockhud.api.item;
+
+public interface IAbility {
+
+ String getAbility();
+
+ int getAbilityTime();
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
index b3f73cb..90333b5 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
@@ -12,7 +12,10 @@ import com.thatgravyboat.skyblockhud.location.LocationHandler;
import com.thatgravyboat.skyblockhud.playerstats.ActionBarParsing;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.Entity;
import net.minecraft.entity.boss.BossStatus;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
@@ -33,7 +36,7 @@ public class Commands {
}
};
- private static final SimpleSubCommand devCommand = new SimpleSubCommand("sbhdev", ImmutableSet.of("copyBossBar", "copyScoreboard", "copyActionBar", "mobDeathLogging")) {
+ private static final SimpleSubCommand devCommand = new SimpleSubCommand("sbhdev", ImmutableSet.of("copyNpcSkin", "copyBossBar", "copyScoreboard", "copyActionBar", "mobDeathLogging")) {
@Override
void processSubCommand(ICommandSender sender, String subCommand, String[] args) {
StringSelection clipboard = null;
@@ -49,6 +52,14 @@ public class Commands {
case "copyActionBar":
clipboard = new StringSelection(ActionBarParsing.lastLowActionBar);
break;
+ case "copySkin":
+ Entity entity = Minecraft.getMinecraft().objectMouseOver.entityHit;
+ if (entity instanceof AbstractClientPlayer){
+ clipboard = new StringSelection("http://textures.minecraft.net/texture/"+((AbstractClientPlayer) entity).getLocationSkin().getResourcePath().replace("skins/", ""));
+ }else {
+ sendSBHMessage(sender, "Not a player!");
+ }
+ break;
case "mobDeathLogging":
DevModeConstants.mobDeathLogging = !DevModeConstants.mobDeathLogging;
sendSBHMessage(sender, "Mob Death Logging " + (DevModeConstants.mobDeathLogging ? "Enabled!" : "Disabled!"));
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
index d84d52d..cd67f78 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java
@@ -121,6 +121,11 @@ public class SBHConfig extends Config {
@ConfigOption(name = "Dialogue Box", desc = "")
@ConfigEditorButton(runnableId = "dialogue", buttonText = "Edit")
public Position dialoguePos = new Position(0, -50, true, false);
+
+ @Expose
+ @ConfigOption(name = "Hide Item Cooldowns", desc = "Hides item cooldowns")
+ @ConfigEditorBoolean
+ public boolean hideItemCooldowns = false;
}
public static class MainHud {
@@ -252,6 +257,11 @@ public class SBHConfig extends Config {
public static class Renderer {
@Expose
+ @ConfigOption(name = "Add Overflow Mana Back", desc = "Adds overflow mana back to the actionbar")
+ @ConfigEditorBoolean
+ public boolean addOverflowMana = false;
+
+ @Expose
@ConfigOption(name = "Hide Boss Bar", desc = "Hides Boss Bar when certain conditions are met such as the name is just wither or it starts with objective:")
@ConfigEditorBoolean
public boolean hideBossBar = true;
@@ -301,7 +311,7 @@ public class SBHConfig extends Config {
@Expose
@ConfigOption(name = "Map Locations", desc = "Remove a location from this list if you would like the map to not show up in that location. This is so you can use other mods maps.")
- @ConfigEditorDraggableList(exampleText = { "HUB", "BARN", "MUSHROOMDESERT", "GOLDMINE (No Map Yet)", "DEEPCAVERNS (No Map Yet)", "SPIDERSDEN", "PARK", "FORTRESS", "DUNGEONHUB (No Map Yet)", "JERRY (No Map Yet)", "THEEND (No Map Yet)", "DWARVENMINES", "CRYSTALHOLLOWS (No Map Yet)" })
+ @ConfigEditorDraggableList(exampleText = { "HUB", "BARN", "MUSHROOMDESERT", "GOLDMINE (No Map Yet)", "DEEPCAVERNS (No Map Yet)", "SPIDERSDEN", "PARK", "FORTRESS", "DUNGEONHUB (No Map Yet)", "JERRY (No Map Yet)", "THEEND (No Map Yet)", "DWARVENMINES", "CRYSTALHOLLOWS" })
public List<Integer> mapLocations = new ArrayList<>(Arrays.asList(0, 1, 2, 5, 6, 7, 11));
@Expose
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java
new file mode 100644
index 0000000..d7d3a41
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java
@@ -0,0 +1,98 @@
+package com.thatgravyboat.skyblockhud.handlers;
+
+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 java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+
+public class CooldownHandler {
+
+ private static final Pattern ABILITY_REGEX = Pattern.compile("\u00A76Ability: (.*) \u00A7e\u00A7lRIGHT CLICK .* \u00A78Cooldown: \u00A7a(\\d*)s");
+
+ private static final Map<String, Cooldown> COOLDOWNS = new HashMap<>();
+
+ 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");
+ if (display != null && display.hasKey("Lore")){
+ NBTTagList lore = display.getTagList("Lore", 8);
+ List<String> loreList = new ArrayList<>();
+ for (int i = 0; i < lore.tagCount(); i++) {
+ String loreLine = lore.getStringTagAt(i).trim();
+ if (!loreLine.isEmpty()) loreList.add(loreLine);
+ }
+ Matcher abilityMatcher = ABILITY_REGEX.matcher(String.join(" ", loreList));
+ if (abilityMatcher.find()){
+ return abilityMatcher;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static void addCooldown(IAbility ability) {
+ COOLDOWNS.putIfAbsent(ability.getAbility(), new Cooldown(ability.getAbilityTime()*20));
+ }
+
+ @SubscribeEvent
+ public void tick(TickEvent.ClientTickEvent event){
+ if (SkyblockHud.config.misc.hideItemCooldowns) return;
+ if (event.phase.equals(TickEvent.Phase.END)) {
+ COOLDOWNS.values().forEach(Cooldown::tick);
+ COOLDOWNS.entrySet().removeIf(entry -> entry.getValue().isOver());
+ }
+ }
+
+ @SubscribeEvent
+ public void onPlayerInteract(PlayerInteractEvent event) {
+ if (SkyblockHud.config.misc.hideItemCooldowns) return;
+ if (event.action.equals(PlayerInteractEvent.Action.RIGHT_CLICK_AIR) || event.action.equals(PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)){
+ if (event.entityPlayer.getHeldItem() != null) {
+ IAbility ability = (IAbility)((Object) event.entityPlayer.getHeldItem());
+ if (ability.getAbility() != null) {
+ addCooldown(ability);
+ }
+ }
+ }
+ }
+
+ public static float getAbilityTime(ItemStack stack){
+ IAbility ability = (IAbility)((Object) stack);
+ if (ability.getAbility() != null) {
+ return COOLDOWNS.containsKey(ability.getAbility()) ? COOLDOWNS.get(ability.getAbility()).getTime() : -1f;
+ }
+ return -1f;
+ }
+
+ private static class Cooldown {
+ public int current;
+ public final int end;
+
+ Cooldown(int end){
+ this.end = end;
+ }
+
+ public boolean isOver() {
+ return current >= end;
+ }
+
+ public void tick() {
+ current++;
+ }
+
+ public float getTime() {
+ return current/(float)end;
+ }
+ }
+
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java
new file mode 100644
index 0000000..71079b6
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java
@@ -0,0 +1,172 @@
+package com.thatgravyboat.skyblockhud.handlers;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.SetMultimap;
+import com.google.gson.*;
+import com.thatgravyboat.skyblockhud.SkyblockHud;
+import com.thatgravyboat.skyblockhud.api.events.ProfileJoinedEvent;
+import com.thatgravyboat.skyblockhud.api.events.ProfileSwitchedEvent;
+import com.thatgravyboat.skyblockhud.mixins.GuiChestAccessor;
+import com.thatgravyboat.skyblockhud.utils.Utils;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraftforge.client.event.GuiOpenEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+public class WarpHandler {
+
+ private static String profile = null;
+ private static File warpConfig;
+ private static final Gson GSON = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
+ private static final SetMultimap<String, Warp> PLAYER_WARPS = HashMultimap.create();
+
+ public static Collection<Warp> getWarps() {
+ return PLAYER_WARPS.get(profile);
+ }
+
+ @SubscribeEvent
+ public void profileChange(ProfileSwitchedEvent event){
+ if (profile != null && !profile.equals(event.profile)){
+ load();
+ }
+ profile = event.profile;
+ }
+
+ @SubscribeEvent
+ public void profileJoined(ProfileJoinedEvent event){
+ if (profile != null && !profile.equals(event.profile)){
+ load();
+ }
+ profile = event.profile;
+ }
+
+ @SubscribeEvent
+ public void onGuiClosed(GuiOpenEvent event) {
+ boolean changed = false;
+ GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
+ if (currentScreen instanceof GuiChest){
+ GuiChestAccessor accessor = (GuiChestAccessor) currentScreen;
+ if (accessor.getLowerChestInventory().getDisplayName().getUnformattedText().contains("Fast Travel")){
+ for (int i = 9; i < Math.min(36, accessor.getLowerChestInventory().getSizeInventory()); i++) {
+ ItemStack stack = accessor.getLowerChestInventory().getStackInSlot(i);
+ if (stack != null && stack.getItem().equals(Items.skull) && stack.getTagCompound().hasKey("display")){
+ NBTTagList lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8);
+
+ String warpLine = Utils.removeColor(lore.getStringTagAt(0)).trim();
+
+ if (warpLine.equals("Unknown island!")) continue;
+
+ String disabledLine = Utils.removeColor(lore.getStringTagAt(lore.tagCount()-1)).trim();
+
+ Warp warp = Warp.fromId(warpLine.replace("/warp", "").trim());
+
+ if (warp != null && !disabledLine.equals("Warp not unlocked!")) {
+ if (PLAYER_WARPS.put(profile, warp)){
+ changed = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (changed) save();
+ }
+
+ public static void save() {
+ JsonObject json = new JsonObject();
+ JsonArray array = new JsonArray();
+ PLAYER_WARPS.asMap().forEach((profile, warps) -> {
+ JsonObject profileObject = new JsonObject();
+ profileObject.addProperty("profile", profile);
+ JsonArray warpArray = new JsonArray();
+ warps.forEach(warp -> warpArray.add(new JsonPrimitive(warp.name())));
+ profileObject.add("warps", warpArray);
+ array.add(profileObject);
+ });
+ json.add("profileWarps", array);
+
+ warpConfig = new File(SkyblockHud.configDirectory, "sbh-warps.json");
+
+ try {
+ warpConfig.createNewFile();
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(warpConfig), StandardCharsets.UTF_8))) {
+ writer.write(GSON.toJson(json));
+ }
+ } catch (IOException ignored) {}
+ }
+
+ public static boolean load() {
+ warpConfig = new File(SkyblockHud.configDirectory, "sbh-warps.json");
+
+ try {
+ if (warpConfig.createNewFile()) return true;
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(warpConfig), StandardCharsets.UTF_8))) {
+ JsonObject json = GSON.fromJson(reader, JsonObject.class);
+ json.get("profileWarps").getAsJsonArray().forEach(jsonElement -> {
+ JsonObject profileObject = jsonElement.getAsJsonObject();
+ List<Warp> warps = new ArrayList<>();
+ profileObject.get("warps").getAsJsonArray().forEach(warpId -> {
+ Warp warp = Warp.safeValueOf(warpId.getAsString());
+ if (warp != null) warps.add(warp);
+ });
+ PLAYER_WARPS.putAll(profileObject.get("profile").getAsString(), warps);
+ });
+ }
+ } catch (Exception ignored) {}
+ return false;
+ }
+
+ public enum Warp {
+ HUB("hub"),
+ PRIVATE("home"),
+ SPIDERSDEN("spider"),
+ BLAZINGFORTRESS("nether"),
+ THEEND("end"),
+ THEPARK("park"),
+ GOLDMINE("gold"),
+ DEEPCAVERNS("deep"),
+ DWARVENMINES("mines"),
+ THEBARN("barn"),
+ MUSHROOMDESERT("desert"),
+ THECASTLE("castle"),
+ SIRIUSSHACK("da"),
+ GRAVEYARDCAVES("crypt"),
+ SPIDERSNEST("nest"),
+ MAGMACUBE("magma"),
+ DRAGONNEST("drag"),
+ JUNGLE("jungle"),
+ HOWLINGCAVE("howl"),
+ DUNGEONHUB("dungeon_hub");
+
+ public String warpId;
+
+ Warp(String warpId){
+ this.warpId = warpId;
+ }
+
+ public static Warp fromId(String id){
+ for (Warp value : Warp.values()) {
+ if (value.warpId.equals(id)) return value;
+ }
+ return null;
+ }
+
+ public static Warp safeValueOf(String value){
+ try {
+ return Warp.valueOf(value);
+ }catch (Exception e) {
+ return null;
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java
index b112ad8..dd6adb2 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java
@@ -113,7 +113,7 @@ public class MinesHandler {
}
if (MinesHandler.currentEvent != Event.NONE) {
- if (MinesHandler.currentEvent == Event.TICKET && event.formattedLine.toLowerCase().contains("tickets:")) {
+ if (MinesHandler.currentEvent == Event.TICKET) {
if (event.formattedLine.toLowerCase().contains("pool:")) {
try {
eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim());
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java
new file mode 100644
index 0000000..a300f9e
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java
@@ -0,0 +1,13 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.inventory.IInventory;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(GuiChest.class)
+public interface GuiChestAccessor {
+
+ @Accessor
+ IInventory getLowerChestInventory();
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java
new file mode 100644
index 0000000..1f372ad
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java
@@ -0,0 +1,42 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import com.thatgravyboat.skyblockhud.SkyblockHud;
+import com.thatgravyboat.skyblockhud.api.item.IAbility;
+import com.thatgravyboat.skyblockhud.handlers.CooldownHandler;
+import java.util.regex.Matcher;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(ItemStack.class)
+public class MixinItemStack implements IAbility {
+
+ private String ability;
+ private int abilityTime;
+
+ @Inject(method = "setTagCompound", at = @At("HEAD"))
+ public void onNbt(NBTTagCompound nbt, CallbackInfo ci) {
+ if (SkyblockHud.config != null && !SkyblockHud.config.misc.hideItemCooldowns) {
+ Matcher abilityMatcher = CooldownHandler.getAbility(nbt);
+ if (abilityMatcher != null) {
+ ability = abilityMatcher.group(1);
+ try {
+ abilityTime = Integer.parseInt(abilityMatcher.group(2).trim());
+ } catch (Exception ignored) {}
+ }
+ }
+ }
+
+ @Override
+ public String getAbility() {
+ return ability;
+ }
+
+ @Override
+ public int getAbilityTime() {
+ return abilityTime;
+ }
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java
new file mode 100644
index 0000000..08f9314
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java
@@ -0,0 +1,41 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import com.thatgravyboat.skyblockhud.handlers.CooldownHandler;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.item.ItemStack;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(RenderItem.class)
+public abstract class MixinRenderItem {
+
+ @Shadow protected abstract void draw(WorldRenderer renderer, int x, int y, int width, int height, int red, int green, int blue, int alpha);
+
+ @Inject(method="renderItemOverlayIntoGUI", at=@At("RETURN"))
+ public void renderItemOverlayIntoGUI(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) {
+ if(stack == null) return;
+ float cooldown = CooldownHandler.getAbilityTime(stack);
+
+ if (cooldown > -1){
+ GlStateManager.disableLighting();
+ GlStateManager.disableDepth();
+ GlStateManager.disableTexture2D();
+ GlStateManager.disableAlpha();
+ GlStateManager.disableBlend();
+ WorldRenderer worldrenderer = Tessellator.getInstance().getWorldRenderer();
+ this.draw(worldrenderer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
+ this.draw(worldrenderer, xPosition + 2, yPosition + 13, Math.round(cooldown * 13f), 1, 102, 102, 255, 255);
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableLighting();
+ GlStateManager.enableDepth();
+ }
+ }
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java
index 3c39877..eb13a83 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java
@@ -45,8 +45,8 @@ public class OverlayHud extends Gui {
String normalTime = (time12Hour == 0 ? "12" : String.valueOf(time12Hour)) + ":" + (timeMin == 0 ? "00" : timeMin) + (timeHour >= 12 ? "pm" : "am");
drawTexturedModalRect((width / 2) - 17, offset + (bossBarVisible ? 17 : 0), 0, 0, 34, 34);
- drawTexturedModalRect((width / 2) - 4, offset + (bossBarVisible ? 24 : 7), (timeHour > 19 || timeHour < 4) ? 43 : 43 + 8, 0, 8, 8);
- if (SkyblockHud.config.main.twelveHourClock) drawScaledString(0.8f, width / 2, offset + (bossBarVisible ? 38 : 21), normalTime, (timeHour > 19 || timeHour < 4) ? 0xAFB8CC : 0xFFFF55); else drawCenteredString(font, militaryTime, (width / 2), offset + (bossBarVisible ? 38 : 21), (timeHour > 19 || timeHour < 4) ? 0xAFB8CC : 0xFFFF55);
+ drawTexturedModalRect((width / 2) - 4, offset + (bossBarVisible ? 24 : 7), (timeHour > 19 || timeHour < 6) ? 43 : 43 + 8, 0, 8, 8);
+ if (SkyblockHud.config.main.twelveHourClock) drawScaledString(0.8f, width / 2, offset + (bossBarVisible ? 38 : 21), normalTime, (timeHour > 19 || timeHour < 6) ? 0xAFB8CC : 0xFFFF55); else drawCenteredString(font, militaryTime, (width / 2), offset + (bossBarVisible ? 38 : 21), (timeHour > 19 || timeHour < 4) ? 0xAFB8CC : 0xFFFF55);
//PURSE
drawPurseAndBits(width, offset, mc);
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java
index 5027704..f82c2f2 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java
@@ -82,7 +82,7 @@ public class ActionBarParsing {
message = DefenseReplaceRegex.matcher(message).replaceAll("");
message = ManaReplaceRegex.matcher(message).replaceAll("");
Matcher overflowMatcher = ManaOverflowReplaceRegex.matcher(message);
- if (overflowMatcher.find()) {
+ if (overflowMatcher.find() && SkyblockHud.config.renderer.addOverflowMana) {
message = overflowMatcher.replaceAll("\u00A73\u02AC " + overflowMatcher.group(3));
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
index 81e8ed1..1e7d64e 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
@@ -1,6 +1,7 @@
package com.thatgravyboat.skyblockhud.tracker;
import com.google.gson.*;
+import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.location.Locations;
import java.io.*;
import java.nio.charset.StandardCharsets;
@@ -85,8 +86,8 @@ public class TrackerFileLoader {
return stats;
}
- public static boolean loadTrackerStatsFile(File configDirectory) {
- File configFile = new File(configDirectory, "sbh-trackers-stats.json");
+ public static boolean loadTrackerStatsFile() {
+ File configFile = new File(SkyblockHud.configDirectory, "sbh-trackers-stats.json");
try {
if (configFile.createNewFile()) {
@@ -127,8 +128,8 @@ public class TrackerFileLoader {
return false;
}
- public static void saveTrackerStatsFile(File configDirectory) {
- File configFile = new File(configDirectory, "sbh-trackers-stats.json");
+ public static void saveTrackerStatsFile() {
+ File configFile = new File(SkyblockHud.configDirectory, "sbh-trackers-stats.json");
try {
configFile.createNewFile();
diff --git a/src/main/resources/mixins.skyblockhud.json b/src/main/resources/mixins.skyblockhud.json
index a729fef..efe7b15 100644
--- a/src/main/resources/mixins.skyblockhud.json
+++ b/src/main/resources/mixins.skyblockhud.json
@@ -3,8 +3,11 @@
"refmap": "mixins.skyblockhud.refmap.json",
"compatibilityLevel": "JAVA_8",
"mixins": [
+ "GuiChestAccessor",
"MixinEntityArrow",
"MixinGuiIngameForge",
- "MixinNetHandlerPlayClient"
+ "MixinItemStack",
+ "MixinNetHandlerPlayClient",
+ "MixinRenderItem"
]
}