diff options
Diffstat (limited to 'src/main')
34 files changed, 518 insertions, 301 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java index d56fd30..dc997cb 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java @@ -5,9 +5,6 @@ import com.google.common.collect.Ordering; import com.thatgravyboat.skyblockhud.dungeons.DungeonHandler; import com.thatgravyboat.skyblockhud.location.*; import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler; -import java.util.Comparator; -import java.util.List; -import java.util.regex.Pattern; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.scoreboard.ScorePlayerTeam; @@ -20,6 +17,10 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.Comparator; +import java.util.List; +import java.util.regex.Pattern; + public class ComponentHandler { public static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile("[^]\\[a-z A-Z:0-9/'.()+\\d-§?]"); @@ -45,7 +46,10 @@ public class ComponentHandler { if (formattedTabListPlayer.toLowerCase().contains("crypts:")) DungeonHandler.parseCrypts(formattedTabListPlayer); } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)) { if (formattedTabListPlayer.toLowerCase().contains("mithril powder:")) { - DwarvenMineHandler.parseMithril(formattedTabListPlayer); + MinesHandler.parseMithril(formattedTabListPlayer); + } + if (formattedTabListPlayer.toLowerCase().contains("gemstone powder:")) { + MinesHandler.parseGemstone(formattedTabListPlayer); } } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.MUSHROOMDESERT)) { if (formattedTabListPlayer.toLowerCase().contains("pelts:")) { @@ -64,8 +68,10 @@ public class ComponentHandler { if (i < 80) { if (players.get(i + 1).getDisplayName() != null) { String secondLine = SCOREBOARD_CHARACTERS.matcher(Utils.removeColor(players.get(i + 1).getDisplayName().getFormattedText())).replaceAll(""); - SeasonDateHandler.setCurrentEvent(formattedTabListPlayer.replace("Event:", ""), secondLine); - eventPass = true; + if (!formattedTabListPlayer.contains("N/A")) { + SeasonDateHandler.setCurrentEvent(formattedTabListPlayer.replace("Event:", ""), secondLine); + eventPass = true; + } } } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/DevModeConstants.java b/src/main/java/com/thatgravyboat/skyblockhud/DevModeConstants.java new file mode 100644 index 0000000..89df438 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/DevModeConstants.java @@ -0,0 +1,6 @@ +package com.thatgravyboat.skyblockhud; + +public class DevModeConstants { + + public static boolean mobDeathLogging = false; +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java index 9198433..cd8c25f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java @@ -33,4 +33,5 @@ public class GuiTextures { public static final ResourceLocation playerStat = new ResourceLocation("skyblockhud", "playerstats.png"); public static final ResourceLocation bars = new ResourceLocation("skyblockhud", "bars.png"); public static final ResourceLocation mapOverlay = new ResourceLocation("skyblockhud", "maps/map_overlay.png"); + public static final ResourceLocation mining = new ResourceLocation("skyblockhud", "mines.png"); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java index f461f6d..7352f20 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java @@ -10,20 +10,16 @@ import com.thatgravyboat.skyblockhud.config.KeyBindings; import com.thatgravyboat.skyblockhud.config.SBHConfig; import com.thatgravyboat.skyblockhud.dungeons.DungeonHandler; import com.thatgravyboat.skyblockhud.handlers.*; -import com.thatgravyboat.skyblockhud.location.DwarvenMineHandler; import com.thatgravyboat.skyblockhud.location.FarmingIslandHandler; import com.thatgravyboat.skyblockhud.location.IslandHandler; import com.thatgravyboat.skyblockhud.location.LocationHandler; +import com.thatgravyboat.skyblockhud.location.MinesHandler; import com.thatgravyboat.skyblockhud.overlay.DungeonOverlay; +import com.thatgravyboat.skyblockhud.overlay.MiningHud; import com.thatgravyboat.skyblockhud.overlay.OverlayHud; import com.thatgravyboat.skyblockhud.overlay.RPGHud; import com.thatgravyboat.skyblockhud.playerstats.ActionBarParsing; import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler; -import java.awt.*; -import java.awt.datatransfer.StringSelection; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Set; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.scoreboard.ScoreObjective; @@ -41,6 +37,12 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.input.Keyboard; +import java.awt.*; +import java.awt.datatransfer.StringSelection; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.Set; + @Mod(modid = SkyblockHud.MODID, version = SkyblockHud.VERSION) public class SkyblockHud { @@ -68,7 +70,7 @@ public class SkyblockHud { MinecraftForge.EVENT_BUS.register(new CurrencyHandler()); MinecraftForge.EVENT_BUS.register(new SlayerHandler()); MinecraftForge.EVENT_BUS.register(new DungeonHandler()); - MinecraftForge.EVENT_BUS.register(new DwarvenMineHandler()); + MinecraftForge.EVENT_BUS.register(new MinesHandler()); MinecraftForge.EVENT_BUS.register(new FarmingIslandHandler()); /* DISABLE UNTIL NEW SYSTEM @@ -119,6 +121,7 @@ public class SkyblockHud { MinecraftForge.EVENT_BUS.register(new DungeonOverlay()); MinecraftForge.EVENT_BUS.register(new BossbarHandler()); MinecraftForge.EVENT_BUS.register(new MapHandler()); + MinecraftForge.EVENT_BUS.register(new MiningHud()); } /* DISABLE UNTIL NEW SYSTEM diff --git a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java index 62cf6a3..3d176c9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java @@ -1,9 +1,5 @@ package com.thatgravyboat.skyblockhud; -import java.nio.FloatBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.FontRenderer; @@ -14,12 +10,19 @@ import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.Loader; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; + public class Utils { private static LinkedList<Integer> guiScales = new LinkedList<>(); @@ -59,6 +62,18 @@ public class Utils { return (int) (g + f * (h - g)); } + public static NBTTagCompound getSkyBlockTag(ItemStack stack){ + if (stack == null) return null; + if (!stack.hasTagCompound()) return null; + if (!stack.getTagCompound().hasKey("ExtraAttributes")) return null; + return stack.getTagCompound().getCompoundTag("ExtraAttributes"); + } + + public static boolean isDrill(ItemStack stack){ + NBTTagCompound tag = getSkyBlockTag(stack); + return tag != null && tag.hasKey("drill_fuel"); + } + public static int whatRomanNumeral(String roman) { switch (roman.toLowerCase()) { case "i": @@ -119,17 +134,13 @@ public class Utils { public static boolean overlayShouldRender(boolean hideOnf3, RenderGameOverlayEvent.ElementType type, RenderGameOverlayEvent.ElementType checkType, boolean... booleans) { Minecraft mc = Minecraft.getMinecraft(); - boolean shouldRender; - if (booleans.length > 1) { - for (boolean aBoolean : booleans) if (!aBoolean) return false; - shouldRender = true; - } else shouldRender = booleans.length != 1 || booleans[0]; + for (boolean aBoolean : booleans) if (!aBoolean) return false; if (hideOnf3) { if (mc.gameSettings.showDebugInfo || (mc.gameSettings.keyBindPlayerList.isKeyDown() && (!mc.isIntegratedServerRunning() || mc.thePlayer.sendQueue.getPlayerInfoMap().size() > 1))) { return false; } } - return (shouldRender && ((type == null && Loader.isModLoaded("labymod")) || type == checkType)); + return ((type == null && Loader.isModLoaded("labymod")) || type == checkType); } public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java index 5d5615f..9aad4c6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java @@ -1,17 +1,21 @@ -package com.thatgravyboat.skyblockhud.tracker; +package com.thatgravyboat.skyblockhud.api; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; +import com.thatgravyboat.skyblockhud.DevModeConstants; +import com.thatgravyboat.skyblockhud.api.events.SkyBlockEntityKilled; +import com.thatgravyboat.skyblockhud.api.sbentities.EntityTypeRegistry; import net.minecraft.client.Minecraft; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -public class KillTrackerHandler { +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class KillTracking { public static final Set<UUID> attackedEntities = new HashSet<>(); @@ -24,19 +28,22 @@ public class KillTrackerHandler { @SubscribeEvent public void onDeath(LivingDeathEvent event) { - if (false) { + if (DevModeConstants.mobDeathLogging) { //Used for testing System.out.println("----------------------------------------------------------------------------------------------------------------"); System.out.println("Name : " + event.entity.getName()); System.out.println("UUID : " + event.entity.getUniqueID()); - NBTTagCompound tag = new NBTTagCompound(); - event.entity.writeToNBT(tag); - System.out.println("Tag : " + tag); + System.out.println("Tag : " + event.entity.serializeNBT()); System.out.println("Damage : " + getDamageSourceString(event.source)); + System.out.println("SBH Entity ID: " + EntityTypeRegistry.getEntityId(event.entity)); System.out.println("----------------------------------------------------------------------------------------------------------------"); } - - attackedEntities.remove(event.entity.getUniqueID()); + if (attackedEntities.contains(event.entity.getUniqueID())) { + if (EntityTypeRegistry.getEntityId(event.entity) != null) { + MinecraftForge.EVENT_BUS.post(new SkyBlockEntityKilled(EntityTypeRegistry.getEntityId(event.entity), event.entity)); + } + attackedEntities.remove(event.entity.getUniqueID()); + } } public static String getDamageSourceString(DamageSource source) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java new file mode 100644 index 0000000..9d02993 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java @@ -0,0 +1,16 @@ +package com.thatgravyboat.skyblockhud.api.events; + +import net.minecraft.entity.Entity; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class SkyBlockEntityKilled extends Event { + + public String id; + public Entity entity; + + public SkyBlockEntityKilled(String id, Entity entity) { + this.id = id; + this.entity = entity; + } + +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java index afff109..d1ad8d2 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java @@ -1,4 +1,4 @@ -package com.thatgravyboat.skyblockhud.handlers.sbentities; +package com.thatgravyboat.skyblockhud.api.sbentities; import com.thatgravyboat.skyblockhud.location.LocationHandler; import com.thatgravyboat.skyblockhud.location.Locations; @@ -12,7 +12,7 @@ public class EntityTypeHelper { if (entity instanceof EntityEnderman) { EntityEnderman enderman = ((EntityEnderman) entity); double maxHealthBase = enderman.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getBaseValue(); - if (maxHealthBase == 13000d || (maxHealthBase == 2000d && enderman.getHeldBlockState().getBlock().equals(Blocks.end_portal_frame))) { + if (maxHealthBase == 13000 || (maxHealthBase == 2000d && enderman.getHeldBlockState().getBlock().equals(Blocks.end_portal_frame))) { return LocationHandler.getCurrentLocation().equals(Locations.DRAGONSNEST); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java index 40076d9..995bc9b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java @@ -1,12 +1,13 @@ -package com.thatgravyboat.skyblockhud.handlers.sbentities; +package com.thatgravyboat.skyblockhud.api.sbentities; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; -import java.util.List; -import java.util.Map; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityEnderman; +import java.util.List; +import java.util.Map; + public class EntityTypeRegistry { private static final Map<Class<? extends Entity>, List<SkyBlockEntity>> entities = Maps.newHashMap(); @@ -17,7 +18,9 @@ public class EntityTypeRegistry { public static String getEntityId(Entity entity) { if (!entities.containsKey(entity.getClass())) return null; - for (SkyBlockEntity skyBlockEntity : entities.get(entity.getClass())) if (skyBlockEntity.isEntity(entity)) return skyBlockEntity.getName(); + for (SkyBlockEntity skyBlockEntity : entities.get(entity.getClass())) { + if (skyBlockEntity.isEntity(entity)) return skyBlockEntity.getName(); + } return null; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/SkyBlockEntity.java b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java index ee8c3a7..78b48df 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/SkyBlockEntity.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java @@ -1,8 +1,9 @@ -package com.thatgravyboat.skyblockhud.handlers.sbentities; +package com.thatgravyboat.skyblockhud.api.sbentities; -import java.util.function.Predicate; import net.minecraft.entity.Entity; +import java.util.function.Predicate; + public class SkyBlockEntity { private final String name; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java index 9f0a22d..ee2eb2b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java @@ -1,6 +1,7 @@ package com.thatgravyboat.skyblockhud.commands; import com.google.common.collect.ImmutableSet; +import com.thatgravyboat.skyblockhud.DevModeConstants; import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.api.LeaderboardGetter; import com.thatgravyboat.skyblockhud.config.SBHConfigEditor; @@ -8,8 +9,6 @@ import com.thatgravyboat.skyblockhud.core.GuiScreenElementWrapper; import com.thatgravyboat.skyblockhud.handlers.MapHandler; import com.thatgravyboat.skyblockhud.location.LocationHandler; import com.thatgravyboat.skyblockhud.playerstats.ActionBarParsing; -import java.awt.*; -import java.awt.datatransfer.StringSelection; import net.minecraft.command.ICommandSender; import net.minecraft.entity.boss.BossStatus; import net.minecraft.util.ChatComponentText; @@ -17,6 +16,9 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.ClientCommandHandler; import org.apache.commons.lang3.StringUtils; +import java.awt.*; +import java.awt.datatransfer.StringSelection; + public class Commands { private static boolean devMode = false; @@ -31,7 +33,7 @@ public class Commands { } }; - private static final SimpleSubCommand devCommand = new SimpleSubCommand("sbhdev", ImmutableSet.of("copyBossBar", "copyScoreboard", "copyActionBar")) { + private static final SimpleSubCommand devCommand = new SimpleSubCommand("sbhdev", ImmutableSet.of("copyBossBar", "copyScoreboard", "copyActionBar", "mobDeathLogging")) { @Override void processSubCommand(ICommandSender sender, String subCommand, String[] args) { StringSelection clipboard = null; @@ -47,17 +49,20 @@ public class Commands { case "copyActionBar": clipboard = new StringSelection(ActionBarParsing.lastLowActionBar); break; + case "mobDeathLogging": + DevModeConstants.mobDeathLogging = !DevModeConstants.mobDeathLogging; + sendSBHMessage(sender,"Mob Death Logging " + (DevModeConstants.mobDeathLogging?"Enabled!":"Disabled!")); } if (clipboard != null) { Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); - sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + "Info copied to clipboard!")); + sendSBHMessage(sender,"Info copied to clipboard!"); } } @Override void processNoSubCommand(ICommandSender sender) { devMode = !devMode; - sender.addChatMessage(new ChatComponentText("Dev Mode " + (devMode ? "Enabled" : "Disabled") + "!")); + sender.addChatMessage(new ChatComponentText("Dev Mode " + (devMode ? "Enabled!" : "Disabled!"))); } }; @@ -81,4 +86,9 @@ public class Commands { ClientCommandHandler.instance.registerCommand(mapCommand); ClientCommandHandler.instance.registerCommand(devCommand); } + + + private static void sendSBHMessage(ICommandSender sender, String message){ + sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + message)); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java index 90f4c19..9c00a92 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java @@ -50,9 +50,9 @@ public class SBHConfig extends Config { case "map": editOverlay(activeConfigCategory, 72, 72, map.miniMapPosition); return; - case "tracker": - editOverlay(activeConfigCategory, 120, 70, trackers.trackerPosition); - return; +// case "tracker": +// editOverlay(activeConfigCategory, 120, 70, trackers.trackerPosition); +// return; } } @@ -81,8 +81,13 @@ public class SBHConfig extends Config { public Map map = new Map(); @Expose - @Category(name = "Tracker", desc = "All Options for the Trackers.") - public Trackers trackers = new Trackers(); + @Category(name = "Mining Hud", desc = "All Options for the Mining Hud.") + public MiningHud miningHud = new MiningHud(); + +//TODO ENABLED WHEN TRACKER GETS ADDED BACK +// @Expose +// @Category(name = "Tracker", desc = "All Options for the Trackers.") +// public Trackers trackers = new Trackers(); public static class Misc { @@ -304,6 +309,20 @@ public class SBHConfig extends Config { public boolean showQuestIcons = false; } + public static class MiningHud { + + @Expose + @ConfigOption(name = "Show Drill Bar", desc = "Allows you to show or hide the Drill Bar.") + @ConfigEditorBoolean + public boolean showDrillBar = true; + + @Expose + @ConfigOption(name = "Show Heat Bar", desc = "Allows you to show or hide the Heat Bar.") + @ConfigEditorBoolean + public boolean showHeatBar = true; + + } + public static class Trackers { @Expose diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java index 0496a8f..58a9f24 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java @@ -1,7 +1,5 @@ package com.thatgravyboat.skyblockhud.config; -import static com.thatgravyboat.skyblockhud.GuiTextures.*; - import com.google.common.collect.Lists; import com.thatgravyboat.skyblockhud.core.GlScissorStack; import com.thatgravyboat.skyblockhud.core.GuiElement; @@ -13,10 +11,6 @@ import com.thatgravyboat.skyblockhud.core.util.lerp.LerpUtils; import com.thatgravyboat.skyblockhud.core.util.lerp.LerpingInteger; import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils; import com.thatgravyboat.skyblockhud.core.util.render.TextRenderUtils; -import java.awt.*; -import java.net.URI; -import java.util.*; -import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -27,10 +21,18 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; +import java.awt.*; +import java.net.URI; +import java.util.List; +import java.util.*; + +import static com.thatgravyboat.skyblockhud.GuiTextures.DISCORD; +import static com.thatgravyboat.skyblockhud.GuiTextures.TWITTER; + public class SBHConfigEditor extends GuiElement { private static final ResourceLocation[] socialsIco = new ResourceLocation[] { DISCORD, TWITTER }; - private static final String[] socialsLink = new String[] { "https://discord.gg/moulberry", "https://twitter.com/thatgravytboat/" }; + private static final String[] socialsLink = new String[] { "https://discord.gg/moulberry", "https://twitter.com/thatgravyboat/" }; private final long openedMillis; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java index b2a148d..7cc6061 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java @@ -2,7 +2,7 @@ package com.thatgravyboat.skyblockhud.handlers; import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; -import com.thatgravyboat.skyblockhud.location.DwarvenMineHandler; +import com.thatgravyboat.skyblockhud.location.MinesHandler; import com.thatgravyboat.skyblockhud.location.LocationHandler; import com.thatgravyboat.skyblockhud.location.Locations; import net.minecraft.entity.boss.BossStatus; @@ -22,7 +22,7 @@ public class BossbarHandler { bossBarRendered = false; } String bossName = Utils.removeColor(BossStatus.bossName); - if (SkyblockHud.config.renderer.hideBossBar && DwarvenMineHandler.currentEvent == DwarvenMineHandler.Event.NONE && !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { + if (SkyblockHud.config.renderer.hideBossBar && MinesHandler.currentEvent == MinesHandler.Event.NONE && !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { if (bossName.equalsIgnoreCase("wither")) { event.setCanceled(true); bossBarRendered = false; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java index da27590..c44c8bc 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java @@ -1,58 +1,32 @@ package com.thatgravyboat.skyblockhud.handlers; -import com.thatgravyboat.skyblockhud.Utils; -import com.thatgravyboat.skyblockhud.overlay.GenericOverlays; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class HeldItemHandler extends Gui { - public void drawFuelBar(Minecraft mc, int current, int max) { - GenericOverlays.drawSmallBar(mc, 100, 100, (double) current / (double) max, 1.0d, 0xff00ff, 0xffff00, 0); - drawString(mc.fontRendererObj, "Fuel - " + Math.round(((double) current / (double) max) * 100) + "%", 100, 100, 0xffffff); - } + private static final Pattern MANA_COST_REGEX = Pattern.compile("Mana Cost: \u00A73([0-9]+)"); - public boolean isDrill(ItemStack stack) { + public static boolean hasManaCost(ItemStack stack){ if (stack == null) return false; - if (!stack.getTagCompound().hasKey("ExtraAttributes")) return false; - return stack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("drill_fuel"); - } - - public String getDrillFuel(ItemStack stack) { - NBTTagCompound display = stack.getTagCompound().getCompoundTag("display"); - NBTTagList lore = display.getTagList("Lore", 8); - for (int i = lore.tagCount() - 1; i >= 0; i--) { - String line = Utils.removeColor(lore.getStringTagAt(i)); - if (line.trim().startsWith("Fuel:")) { - return line; - } - } - return ""; + if (!stack.hasTagCompound()) return false; + if (!stack.getTagCompound().hasKey("display")) return false; + if (!stack.getTagCompound().getCompoundTag("display").hasKey("Lore")) return false; + String lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8).toString(); + return MANA_COST_REGEX.matcher(lore).find(); } - @SubscribeEvent - public void drawOverlay(RenderGameOverlayEvent.Post event) { - /* - if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard())){ - Minecraft mc = Minecraft.getMinecraft(); - ItemStack stack = mc.thePlayer.getHeldItem(); - if (isDrill(stack)){ - try { - String drill = getDrillFuel(stack).replace("Fuel:", "").trim(); - String[] fuel = drill.split("/"); - if (fuel.length == 2) { - int current = Integer.parseInt(fuel[0].replace(",", "")); - int max = Integer.parseInt(fuel[1].replace("k", "")) * 1000; - drawFuelBar(mc, current, max); - } - }catch (Exception ignored){} - } + public static int getManaCost(ItemStack stack){ + String lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8).toString(); + Matcher matcher = MANA_COST_REGEX.matcher(lore); + if (matcher.find()){ + try { + return Integer.parseInt(matcher.group(1)); + }catch (Exception ignored){} } - */ + return 0; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java index b7b232f..4491e9d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java @@ -1,7 +1,5 @@ package com.thatgravyboat.skyblockhud.handlers; -import static com.thatgravyboat.skyblockhud.GuiTextures.mapOverlay; - import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.config.KeyBindings; @@ -10,10 +8,6 @@ import com.thatgravyboat.skyblockhud.core.config.Position; import com.thatgravyboat.skyblockhud.handlers.mapicons.DwarvenIcons; import com.thatgravyboat.skyblockhud.handlers.mapicons.HubIcons; import com.thatgravyboat.skyblockhud.location.LocationHandler; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import javax.vecmath.Vector2f; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; @@ -26,6 +20,13 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.opengl.GL11; +import javax.vecmath.Vector2f; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static com.thatgravyboat.skyblockhud.GuiTextures.mapOverlay; + public class MapHandler { public enum MapIconTypes { @@ -69,7 +70,7 @@ public class MapHandler { NETHER(0.5f, 257, 371, 436, 732, 433, 736, new ResourceLocation("skyblockhud", "maps/fort.png"), Collections.emptyList()), BARN(1.5f, 135, 130, -82, 320, -81, 318, new ResourceLocation("skyblockhud", "maps/barn.png"), Collections.emptyList()), DWARVEN(0.5f, 409, 461, 206, 160, 202, 166, new ResourceLocation("skyblockhud", "maps/dwarven.png"), DwarvenIcons.dwarvenIcons), - PARK(1.0f, 211, 230, 480, 133, 478, 134, new ResourceLocation("skyblockhud", "maps/park.png"), Collections.emptyList()); + PARK(1f, 211, 230, 480, 133, 478, 134, new ResourceLocation("skyblockhud", "maps/park.png"), Collections.emptyList()); public float scaleFactor; public int width; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java index fbb95eb..dcdc10e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java @@ -3,11 +3,12 @@ package com.thatgravyboat.skyblockhud.handlers; import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent; import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + import java.util.Arrays; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SlayerHandler { @@ -19,7 +20,7 @@ public class SlayerHandler { ZOMBIE(34, "Revenant Horror"), WOLF(42, "Sven Packmaster"), SPIDER(50, "Tarantula Broodfather"), - VOIDGLOOMSERAPH(50, "Voidgloom Seraph"), + VOIDGLOOMSERAPH(58, "Voidgloom Seraph"), NONE(0, ""); private final String displayName; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java deleted file mode 100644 index 3b17899..0000000 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.thatgravyboat.skyblockhud.location; - -import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent; -import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Arrays; -import java.util.Locale; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class DwarvenMineHandler { - - public enum Event { - NONE(0, "Unknown"), - TICKET(107, "Raffle"), - GOBLIN(99, "Goblin Raid"); - - public int x; - public String displayName; - - Event(int x, String displayName) { - this.x = x; - this.displayName = displayName; - } - } - - public static int mithril; - - public static int eventMax; - public static int eventProgress; - public static Event currentEvent; - - private static final DecimalFormat formatter = new DecimalFormat("#,###", DecimalFormatSymbols.getInstance(Locale.CANADA)); - - public static String getMithrilFormatted() { - String output = formatter.format(mithril); - if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0"; - return output; - } - - public static void parseMithril(String line) { - try { - mithril = Integer.parseInt(line.toLowerCase().replace("mithril powder:", "").trim()); - } catch (Exception ignored) {} - } - - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if (event.formattedLine.toLowerCase().contains("mithril")) { - try { - mithril = Integer.parseInt(event.formattedLine.toLowerCase().replace("mithril:", "").trim()); - } catch (Exception ignored) {} - } - if (event.formattedLine.toLowerCase().contains("event")) { - if (event.formattedLine.toLowerCase().contains("raffle")) { - DwarvenMineHandler.currentEvent = Event.TICKET; - } else if (event.formattedLine.toLowerCase().contains("goblin raid")) { - DwarvenMineHandler.currentEvent = Event.GOBLIN; - } - } - if (DwarvenMineHandler.currentEvent != Event.NONE) { - if (DwarvenMineHandler.currentEvent == Event.TICKET && event.formattedLine.toLowerCase().contains("tickets:")) { - if (event.formattedLine.toLowerCase().contains("pool:")) { - try { - eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim()); - } catch (Exception ignored) {} - } else if (event.formattedLine.toLowerCase().contains("tickets:")) { - try { - eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("tickets:", "").split("\\(")[0].trim()); - } catch (Exception ignored) {} - } - } else if (DwarvenMineHandler.currentEvent == Event.GOBLIN) { - if (event.formattedLine.toLowerCase().contains("remaining:")) { - try { - eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("goblins", "").replace("remaining:", "").trim()); - } catch (Exception ignored) {} - } else if (event.formattedLine.toLowerCase().contains("your kills:") && !event.formattedLine.toLowerCase().contains("(")) { - try { - eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("your kills:", "").trim()); - } catch (Exception ignored) {} - } - } - } - } - - @SubscribeEvent - public void onSidebarPost(SidebarPostEvent event) { - String arrayString = Arrays.toString(event.arrayScores); - if (!arrayString.toLowerCase().contains("event:")) { - DwarvenMineHandler.currentEvent = Event.NONE; - DwarvenMineHandler.eventProgress = 0; - DwarvenMineHandler.eventMax = 0; - } - } -} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java index a337f3d..f37a22d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java @@ -1,9 +1,9 @@ package com.thatgravyboat.skyblockhud.location; -import static com.thatgravyboat.skyblockhud.handlers.MapHandler.Maps; - import com.thatgravyboat.skyblockhud.handlers.MapHandler; +import static com.thatgravyboat.skyblockhud.handlers.MapHandler.Maps; + public enum LocationCategory { ERROR("error", 34), ISLAND("island", 43), @@ -19,7 +19,7 @@ public enum LocationCategory { JERRY("jerry", 59), THEEND("the_end", 123), DWARVENMINES("dwarven_mines", 131, Maps.DWARVEN), - CRYSTALHOLLOWS("crystal_hollows", 131); + CRYSTALHOLLOWS("crystal_hollows", 139); private final String name; private final int texturePos; @@ -46,4 +46,9 @@ public enum LocationCategory { public MapHandler.Maps getMap() { return this.map; } + + public boolean isMiningCategory() { + return this == LocationCategory.DWARVENMINES || this == LocationCategory.CRYSTALHOLLOWS; + } + } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java index bf55db6..6abc7b7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java @@ -1,15 +1,13 @@ package com.thatgravyboat.skyblockhud.location; import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import java.util.Locale; + public class LocationHandler { private static Locations currentLocation = Locations.NONE; - private static final List<String> UndocumentedLocations = new ArrayList<>(); @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { @@ -41,11 +39,4 @@ public class LocationHandler { currentLocation = Locations.CATACOMBS; } else setCurrentLocation(location.replaceAll("[^A-Za-z0-9]", "")); } - - public static void reportUndocumentedLocation(String locationId) { - if (!UndocumentedLocations.contains(locationId)) { - UndocumentedLocations.add(locationId); - System.out.println("Missing Location value for: " + locationId); - } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java index f887b1d..722d9f9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java @@ -114,14 +114,15 @@ public enum Locations { JUNGLETEMPLE("jungletemple", "Jungle Temple", LocationCategory.CRYSTALHOLLOWS), MITHRILDEPOSITS("mithrildeposits", "Mithril Deposits", LocationCategory.CRYSTALHOLLOWS), MINESOFDIVAN("minesofdivan", "Mines of Divan", LocationCategory.CRYSTALHOLLOWS), - MAMGAFIELDS("magmafields", "Magma Fields", LocationCategory.CRYSTALHOLLOWS), - KHAZADDM("khzaddm", "Khazad-dûm", LocationCategory.CRYSTALHOLLOWS), + MAGMAFIELDS("magmafields", "Magma Fields", LocationCategory.CRYSTALHOLLOWS), + KHAZADDM("khzaddm", "Khazad-d\u00FBm", LocationCategory.CRYSTALHOLLOWS), GOBLINHOLDOUT("goblinholdout", "Goblin Holdout", LocationCategory.CRYSTALHOLLOWS), GOBLINQUEENSDEN("goblinqueensden", "Goblin Queens Den", LocationCategory.CRYSTALHOLLOWS), - PERCURSORREMNANTS("precursorremnants", "Precursor Remnants", LocationCategory.CRYSTALHOLLOWS), + PRECURSORREMNANTS("precursorremnants", "Precursor Remnants", LocationCategory.CRYSTALHOLLOWS), LOSTPRECURSORCITY("lostprecursorcity", "Lost Precursor City", LocationCategory.CRYSTALHOLLOWS), CRYSTALNUCLEUS("crystalnucleus", "Crystal Nucleus", LocationCategory.CRYSTALHOLLOWS), - CRYSTALHOLLOWS("crystalhollows", "Crystal Hollows", LocationCategory.CRYSTALHOLLOWS); + CRYSTALHOLLOWS("crystalhollows", "Crystal Hollows", LocationCategory.CRYSTALHOLLOWS), + FAIRYGROTTO("fairygrotto", "Fairy Grotto", LocationCategory.CRYSTALHOLLOWS); private final String name; private final String displayName; @@ -149,7 +150,6 @@ public enum Locations { try { return Locations.valueOf(id.replace(" ", "").toUpperCase()); } catch (IllegalArgumentException ex) { - LocationHandler.reportUndocumentedLocation(id); return DEFAULT; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java new file mode 100644 index 0000000..1e1a065 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java @@ -0,0 +1,157 @@ +package com.thatgravyboat.skyblockhud.location; + +import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent; +import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent; +import com.thatgravyboat.skyblockhud.overlay.MiningHud; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Arrays; +import java.util.Locale; + +public class MinesHandler { + + public enum Event { + NONE(0, "Unknown", false, false), + TICKET(107, "Raffle", true, true), + GOBLIN(99, "Goblin Raid", true, true), + WIND(107, "Gone With The Wind", false, false), + TOGETHER(107, "Better Together", false, true); + + public int x; + public String displayName; + public boolean needsMax; + public boolean display; + + Event(int x, String displayName, boolean needsMax, boolean display) { + this.x = x; + this.displayName = displayName; + this.needsMax = needsMax; + this.display = display; + } + } + + public static int mithril; + public static int gemstone; + + public static int eventMax; + public static int eventProgress; + public static Event currentEvent; + + private static final DecimalFormat NORMAL_FORMATTER = new DecimalFormat("#,###", DecimalFormatSymbols.getInstance(Locale.CANADA)); + private static final DecimalFormat SHORT_FORMATTER = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA)); + + static { + SHORT_FORMATTER.setRoundingMode(RoundingMode.FLOOR); + } + + public static String getMithrilFormatted() { + String output = NORMAL_FORMATTER.format(mithril); + if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0"; + return output; + } + + public static String getMithrilShortFormatted() { + return mithril > 999 ? SHORT_FORMATTER.format((double) mithril / 1000) + "k" : String.valueOf(mithril); + } + + public static String getGemstoneFormatted() { + String output = NORMAL_FORMATTER.format(gemstone); + if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0"; + return output; + } + + public static String getGemstoneShortFormatted() { + return gemstone > 999 ? SHORT_FORMATTER.format((double) gemstone / 1000) + "k" : String.valueOf(gemstone); + } + + public static void parseMithril(String line) { + try { + mithril = Integer.parseInt(line.toLowerCase().replace("mithril powder:", "").trim()); + } catch (Exception ignored) {} + } + + public static void parseGemstone(String line) { + try { + gemstone = Integer.parseInt(line.toLowerCase().replace("gemstone powder:", "").trim()); + } catch (Exception ignored) {} + } + + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if (event.formattedLine.toLowerCase().contains("heat")){ + try { + MiningHud.setHeat(Integer.parseInt(event.formattedLine.toLowerCase().replace("heat:", "").trim())); + } catch (Exception ignored) {} + } + if (event.formattedLine.toLowerCase().contains("mithril")) { + try { + mithril = Integer.parseInt(event.formattedLine.toLowerCase().replace("mithril:", "").trim()); + } catch (Exception ignored) {} + } + if (event.formattedLine.toLowerCase().contains("gemstone")) { + try { + gemstone = Integer.parseInt(event.formattedLine.toLowerCase().replace("gemstone:", "").trim()); + } catch (Exception ignored) {} + } + if (event.formattedLine.toLowerCase().contains("event")) { + if (event.formattedLine.toLowerCase().contains("raffle")) { + MinesHandler.currentEvent = Event.TICKET; + } else if (event.formattedLine.toLowerCase().contains("goblin raid")) { + MinesHandler.currentEvent = Event.GOBLIN; + } + } + if (event.formattedLine.equalsIgnoreCase("wind compass")) { + MinesHandler.currentEvent = Event.WIND; + } + if (event.formattedLine.equalsIgnoreCase("nearby players")){ + MinesHandler.currentEvent = Event.TOGETHER; + try { + MinesHandler.eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("nearby players", "")); + } catch (Exception ignored) {} + } + + if (MinesHandler.currentEvent != Event.NONE) { + if (MinesHandler.currentEvent == Event.TICKET && event.formattedLine.toLowerCase().contains("tickets:")) { + if (event.formattedLine.toLowerCase().contains("pool:")) { + try { + eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim()); + } catch (Exception ignored) {} + } else if (event.formattedLine.toLowerCase().contains("tickets:")) { + try { + eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("tickets:", "").split("\\(")[0].trim()); + } catch (Exception ignored) {} + } + } else if (MinesHandler.currentEvent == Event.GOBLIN) { + if (event.formattedLine.toLowerCase().contains("remaining:")) { + try { + eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("goblins", "").replace("remaining:", "").trim()); + } catch (Exception ignored) {} + } else if (event.formattedLine.toLowerCase().contains("your kills:") && !event.formattedLine.toLowerCase().contains("(")) { + try { + eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("your kills:", "").trim()); + } catch (Exception ignored) {} + } + } + } + } + + @SubscribeEvent + public void onSidebarPost(SidebarPostEvent event) { + String arrayString = Arrays.toString(event.arrayScores); + boolean hasEvent = arrayString.toLowerCase().contains("event:"); + boolean hasWind = arrayString.toLowerCase().contains("wind compass"); + boolean hasNearbyPlayers = arrayString.toLowerCase().contains("nearby players"); + + if (!hasEvent && !hasWind && !hasNearbyPlayers) { + MinesHandler.currentEvent = Event.NONE; + MinesHandler.eventProgress = 0; + MinesHandler.eventMax = 0; + } + if (!arrayString.toLowerCase().contains("heat:")){ + MiningHud.setHeat(0); + } + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java deleted file mode 100644 index 7363a45..0000000 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.thatgravyboat.skyblockhud.mixins; - -import com.thatgravyboat.skyblockhud.SpecialColour; -import com.thatgravyboat.skyblockhud.handlers.sbentities.EntityTypeHelper; -import java.awt.*; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderEnderman; -import net.minecraft.entity.monster.EntityEnderman; -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(RenderEnderman.class) -public class MixinEndermanRenderer { - - @Inject(method = "doRender(Lnet/minecraft/entity/monster/EntityEnderman;DDDFF)V", at = @At("HEAD")) - public void onRender(EntityEnderman entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { - if (EntityTypeHelper.isZealot(entity)) { - Color color = new Color(SpecialColour.specialToChromaRGB("255:255:0:48:255")); - GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 255f); - } - } -} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java index cc1edaf..dbde075 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java @@ -1,6 +1,6 @@ package com.thatgravyboat.skyblockhud.mixins; -import com.thatgravyboat.skyblockhud.tracker.KillTrackerHandler; +import com.thatgravyboat.skyblockhud.api.KillTracking; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.EntityArrow; @@ -13,14 +13,13 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(EntityArrow.class) public class MixinEntityArrow { - //Disabled as kill tracker stuff not fully added yet. @Shadow public Entity shootingEntity; @ModifyVariable(method = "onUpdate", at = @At(value = "STORE", ordinal = 1)) public MovingObjectPosition onUpdate(MovingObjectPosition position) { if (position != null && position.entityHit != null && this.shootingEntity != null && this.shootingEntity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { - KillTrackerHandler.attackedEntities.add(position.entityHit.getUniqueID()); + KillTracking.attackedEntities.add(position.entityHit.getUniqueID()); } return position; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java index df36b8f..e5c1aa0 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java @@ -2,6 +2,7 @@ package com.thatgravyboat.skyblockhud.mixins; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.network.play.server.S3EPacketTeams; +import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -49,4 +50,10 @@ public class MixinNetHandlerPlayClient { //This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things. if (scoreboard.getTeam(packetIn.getName()) != null && packetIn.getAction() == 0) ci.cancel(); } + + @Inject(method = "handleTeams", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", ordinal = 6, shift = At.Shift.BEFORE), cancellable = true) + public void handleTeamRemove(S3EPacketTeams packetIn, CallbackInfo ci, Scoreboard scoreboard, ScorePlayerTeam scoreplayerteam){ + if (scoreplayerteam == null) ci.cancel(); + } + } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/MiningHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/MiningHud.java new file mode 100644 index 0000000..57044df --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/MiningHud.java @@ -0,0 +1,60 @@ +package com.thatgravyboat.skyblockhud.overlay; + +import com.thatgravyboat.skyblockhud.GuiTextures; +import com.thatgravyboat.skyblockhud.SkyblockHud; +import com.thatgravyboat.skyblockhud.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class MiningHud extends Gui { + + private static int fuel, maxFuel; + private static int heat; + + public static void setFuel(int fuel, int maxFuel){ + MiningHud.fuel = fuel; + MiningHud.maxFuel = maxFuel; + } + + public static void setHeat(int heat){ + MiningHud.heat = heat; + } + + @SubscribeEvent + public void renderOverlay(RenderGameOverlayEvent.Post event) { + if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), SkyblockHud.config.miningHud.showDrillBar || SkyblockHud.config.miningHud.showHeatBar)) { + Minecraft mc = Minecraft.getMinecraft(); + + if (heat > 0 && Utils.isDrill(mc.thePlayer.getHeldItem()) && SkyblockHud.config.miningHud.showDrillBar && SkyblockHud.config.miningHud.showHeatBar) { + renderFuelBar(mc, (event.resolution.getScaledWidth() / 2) - 91, event.resolution.getScaledHeight() - 31); + renderHeatBar(mc, (event.resolution.getScaledWidth() / 2) + 46, event.resolution.getScaledHeight() - 31); + }else if(Utils.isDrill(mc.thePlayer.getHeldItem()) && SkyblockHud.config.miningHud.showDrillBar) { + renderFuelBar(mc, (event.resolution.getScaledWidth() / 2) - 68, event.resolution.getScaledHeight() - 31); + }else if (heat > 0 && SkyblockHud.config.miningHud.showHeatBar){ + renderHeatBar(mc, (event.resolution.getScaledWidth() / 2) - 22, event.resolution.getScaledHeight() - 31); + } + } + } + + private void renderFuelBar(Minecraft mc, int x, int y){ + if (maxFuel == 0)return; + GlStateManager.enableBlend(); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + mc.renderEngine.bindTexture(GuiTextures.mining); + drawTexturedModalRect(x, y, 0, 0, 136, 7); + drawTexturedModalRect(x, y, 0, 7, Utils.lerp((float)fuel/(float)maxFuel,0,136), 7); + String percentageText = Math.round(((float)fuel/(float)maxFuel)*100) +"%"; + this.drawCenteredString(mc.fontRendererObj, percentageText, x + 68, y-2, 0xffffff); + } + + private void renderHeatBar(Minecraft mc, int x, int y){ + GlStateManager.enableBlend(); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + mc.renderEngine.bindTexture(GuiTextures.mining); + drawTexturedModalRect(x, y, 137, 0, 45, 7); + drawTexturedModalRect(x, y, 137, 7, Utils.lerp(heat/100f,0,45), 7); + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java index 23b9df0..a7a8b4e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -10,9 +10,6 @@ import com.thatgravyboat.skyblockhud.handlers.TimeHandler; import com.thatgravyboat.skyblockhud.location.*; import com.thatgravyboat.skyblockhud.seasons.Season; import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -23,6 +20,10 @@ import net.minecraftforge.client.GuiIngameForge; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; + public class OverlayHud extends Gui { private static final FontRenderer font = Minecraft.getMinecraft().fontRendererObj; @@ -65,11 +66,11 @@ public class OverlayHud extends Gui { if (IslandHandler.flightTime > 0) drawFlightDuration(width, offset, mc); } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.MUSHROOMDESERT)) { drawTrapperOrPelts(width, offset, mc); - } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)) { - if (DwarvenMineHandler.currentEvent != DwarvenMineHandler.Event.NONE) { + } else if (LocationHandler.getCurrentLocation().getCategory().isMiningCategory()) { + if (MinesHandler.currentEvent.display && LocationHandler.getCurrentLocation().getCategory() == LocationCategory.DWARVENMINES) { drawDwarvenEvent(width, offset, mc); } else { - drawMithril(width, offset, mc); + drawMiningPowders(width, offset, mc); } } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK) && ParkIslandHandler.isRaining()) { if (LocationHandler.getCurrentLocation().equals(Locations.HOWLINGCAVE)) { @@ -206,15 +207,38 @@ public class OverlayHud extends Gui { } } - public void drawMithril(int width, int offset, Minecraft mc) { - if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)) { + public void drawMiningPowders(int width, int offset, Minecraft mc) { + if (MinesHandler.gemstone == 0) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(GuiTextures.overlay); - String mithril = DwarvenMineHandler.getMithrilFormatted(); + String mithril = MinesHandler.getMithrilFormatted(); drawTexturedModalRect((width / 2) - 33 - (font.getStringWidth(mithril)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(mithril))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(mithril) + 14, 14); drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(mithril))) + 4, offset + (bossBarVisible ? 38 : 21), 91, 0, 8, 8); drawString(font, mithril, (width / 2) - 19 - (font.getStringWidth(mithril)), offset + (bossBarVisible ? 38 : 21), 0x00C896); + }else { + LocationCategory locationCategory = LocationHandler.getCurrentLocation().getCategory(); + String mithril = locationCategory == LocationCategory.DWARVENMINES ? MinesHandler.getMithrilFormatted() : MinesHandler.getMithrilShortFormatted(); + String gemstone = locationCategory == LocationCategory.CRYSTALHOLLOWS ? MinesHandler.getGemstoneFormatted() : MinesHandler.getGemstoneShortFormatted(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + + int edge = (width / 2) - 33; + + int barWidth = font.getStringWidth(mithril) + 12 + font.getStringWidth(gemstone); + + int firstText = locationCategory == LocationCategory.DWARVENMINES ? font.getStringWidth(mithril) : font.getStringWidth(gemstone); + + //Bar + drawTexturedModalRect(edge - barWidth, offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); + drawTexturedModalRect(edge - barWidth + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, barWidth + 14, 14); + + //Icons + drawTexturedModalRect(edge - barWidth + 4, offset + (bossBarVisible ? 38 : 21), locationCategory == LocationCategory.DWARVENMINES ? 91 : 131, 0, 8, 8); + drawTexturedModalRect(edge - barWidth + 16 + firstText, offset + (bossBarVisible ? 38 : 21), locationCategory == LocationCategory.DWARVENMINES ? 131 : 91, 0, 8, 8); + + drawString(font, locationCategory == LocationCategory.DWARVENMINES ? mithril : gemstone, edge - barWidth + 14, offset + (bossBarVisible ? 38 : 21), locationCategory == LocationCategory.DWARVENMINES ? 0x00C896 : 0xFF55FF); + drawString(font, locationCategory == LocationCategory.DWARVENMINES ? gemstone : mithril, edge - barWidth + 26 + firstText, offset + (bossBarVisible ? 38 : 21), locationCategory == LocationCategory.DWARVENMINES ? 0xFF55FF : 0x00C896); } } @@ -234,17 +258,17 @@ public class OverlayHud extends Gui { if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(GuiTextures.overlay); - if (DwarvenMineHandler.eventMax > 0) { - String duration = DwarvenMineHandler.eventProgress + "/" + DwarvenMineHandler.eventMax; + if (MinesHandler.eventMax > 0 || !MinesHandler.currentEvent.needsMax) { + String duration = MinesHandler.currentEvent.needsMax ? MinesHandler.eventProgress + "/" + MinesHandler.eventMax : String.valueOf(MinesHandler.eventProgress); drawTexturedModalRect((width / 2) - 33 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(duration))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(duration) + 14, 14); - drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(duration))) + 4, offset + (bossBarVisible ? 38 : 21), DwarvenMineHandler.currentEvent.x, 0, 8, 8); + drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(duration))) + 4, offset + (bossBarVisible ? 38 : 21), MinesHandler.currentEvent.x, 0, 8, 8); drawString(font, duration, (width / 2) - 19 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); } else { - String text = DwarvenMineHandler.currentEvent.displayName; + String text = MinesHandler.currentEvent.displayName; drawTexturedModalRect((width / 2) - 33 - (font.getStringWidth(text)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(text))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(text) + 14, 14); - drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(text))) + 4, offset + (bossBarVisible ? 38 : 21), DwarvenMineHandler.currentEvent.x, 0, 8, 8); + drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(text))) + 4, offset + (bossBarVisible ? 38 : 21), MinesHandler.currentEvent.x, 0, 8, 8); drawString(font, text, (width / 2) - 19 - (font.getStringWidth(text)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java index 47e69b9..3914392 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java @@ -5,16 +5,17 @@ import com.thatgravyboat.skyblockhud.GuiTextures; import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.core.config.Position; -import java.text.DecimalFormat; -import java.text.NumberFormat; +import com.thatgravyboat.skyblockhud.handlers.HeldItemHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import java.text.DecimalFormat; +import java.text.NumberFormat; + public class RPGHud extends Gui { private static int mana, maxMana, overflow = 0; @@ -52,7 +53,6 @@ public class RPGHud extends Gui { @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post event) { - if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), SkyblockHud.config.renderer.hideXpBar)) MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(new RenderGameOverlayEvent(event.partialTicks, event.resolution), RenderGameOverlayEvent.ElementType.EXPERIENCE)); if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), SkyblockHud.config.rpg.showRpgHud)) { Minecraft mc = Minecraft.getMinecraft(); GlStateManager.enableBlend(); @@ -73,14 +73,24 @@ public class RPGHud extends Gui { drawTexturedModalRect(x, y, rightAligned ? 131 : 5, 6, 120, 47); float manaWidth = Math.min(57 * ((float) mana / (float) maxMana), 57); - drawTexturedModalRect(rightAligned ? x + 16 : 47 + x, 17 + y, rightAligned ? 199 : 0, 64, (int) manaWidth, 4); + int manaX = rightAligned ? x + 16 : 47 + x; + if (HeldItemHandler.hasManaCost(mc.thePlayer.getHeldItem())){ + int manaCost = HeldItemHandler.getManaCost(mc.thePlayer.getHeldItem()); + drawTexturedModalRect(manaX, 17 + y, rightAligned ? 199 : 0, manaCost > mana ? 96 : 64, (int) manaWidth, 4); + if (manaCost <= mana) { + drawTexturedModalRect(manaX, 17 + y, rightAligned ? 199 : 0, 92, Utils.lerp((float) manaCost / (float) maxMana,0, 57), 4); + } + }else { + drawTexturedModalRect(manaX, 17 + y, rightAligned ? 199 : 0, 64, (int) manaWidth, 4); + } float healthWidth = Math.min(70 * ((float) health / (float) maxHealth), 70); - drawTexturedModalRect(rightAligned ? x + 3 : 47 + x, 22 + y, rightAligned ? 186 : 0, 68, (int) healthWidth, 5); + int healthX = rightAligned ? x + 3 : 47 + x; + drawTexturedModalRect(healthX, 22 + y, rightAligned ? 186 : 0, 68, (int) healthWidth, 5); if (health > maxHealth) { float absorptionWidth = Math.min(70 * ((float) (health - maxHealth) / (float) maxHealth), 70); - drawTexturedModalRect(rightAligned ? x + 3 : 47 + x, 22 + y, rightAligned ? 186 : 0, 77, (int) absorptionWidth, 5); + drawTexturedModalRect(healthX, 22 + y, rightAligned ? 186 : 0, 77, (int) absorptionWidth, 5); } drawTexturedModalRect(rightAligned ? x + 7 : 45 + x, 28 + y, rightAligned ? 189 : 0, 73, Utils.lerp(mc.thePlayer.experience, 0, 67), 4); @@ -92,9 +102,9 @@ public class RPGHud extends Gui { drawTexturedModalRect(rightAligned ? x + 19 : 41 + x, 33 + y, rightAligned ? 196 : 0, 88, Utils.lerp(mc.thePlayer.getAir() / 300f, 0, 60), 4); } - Utils.drawStringScaled("" + mc.thePlayer.experienceLevel, mc.fontRendererObj, (rightAligned ? 130 : 14) + x - (mc.fontRendererObj.getStringWidth("" + mc.thePlayer.experienceLevel) / 2f), 34 + y, false, 8453920, 0.75f); + Utils.drawStringScaled("" + mc.thePlayer.experienceLevel, font, (rightAligned ? 112 : 14) + x - (font.getStringWidth("" + mc.thePlayer.experienceLevel) / 2f), 34 + y, false, 8453920, 0.75f); - Utils.drawStringScaled(ChatFormatting.RED + " \u2764 " + health + "/" + maxHealth, mc.fontRendererObj, (rightAligned ? 10 : 42) + x, 8 + y, true, 0xffffff, 0.75f); + Utils.drawStringScaled(ChatFormatting.RED + " \u2764 " + health + "/" + maxHealth, font, (rightAligned ? 10 : 42) + x, 8 + y, true, 0xffffff, 0.75f); GlStateManager.color(255, 255, 255); GlStateManager.disableBlend(); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java index 32e23a3..dc60304 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java @@ -2,9 +2,8 @@ package com.thatgravyboat.skyblockhud.playerstats; import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; +import com.thatgravyboat.skyblockhud.overlay.MiningHud; import com.thatgravyboat.skyblockhud.overlay.RPGHud; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.ClientChatReceivedEvent; @@ -12,6 +11,9 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class ActionBarParsing { private static String lastActionBar = ""; @@ -24,6 +26,7 @@ public class ActionBarParsing { private static final Pattern ManaRegex = Pattern.compile("([0-9]+)/([0-9]+)\u270E Mana"); private static final Pattern ManaOverflowRegex = Pattern.compile("([0-9]+)/([0-9]+)\u270E ([0-9]+)\u02AC"); private static final Pattern ManaDecreaseRegex = Pattern.compile("-([0-9]+) Mana \\("); + private static final Pattern DrillFuelRegex = Pattern.compile("([0-9,]+)/([0-9,]+k) Drill Fuel"); private static final Pattern XpGainRegex = Pattern.compile("\\+(\\d*\\.?\\d*) (Farming|Mining|Combat|Foraging|Fishing|Enchanting|Alchemy|Carpentry|Runecrafting) \\((\\d*\\.?\\d*)%\\)"); private static final Pattern HealthReplaceRegex = Pattern.compile("\u00A7c([0-9]+)/([0-9]+)\u2764"); @@ -32,6 +35,7 @@ public class ActionBarParsing { private static final Pattern DefenseReplaceRegex = Pattern.compile("\u00A7a([0-9]+)\u00A7a\u2748 Defense"); private static final Pattern ManaReplaceRegex = Pattern.compile("\u00A7b([0-9]+)/([0-9]+)\u270E Mana"); private static final Pattern ManaOverflowReplaceRegex = Pattern.compile("\u00A7b([0-9]+)/([0-9]+)\u270E \u00A73([0-9]+)\u02AC"); + private static final Pattern DrillFuelReplaceRegex = Pattern.compile("\u00A72([0-9,]+)/([0-9,]+k) Drill Fuel"); private static int ticksSinceLastPrediction = 0; private static boolean predict = false; @@ -49,29 +53,47 @@ public class ActionBarParsing { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onStatusBarHigh(ClientChatReceivedEvent event) { - if (event.type == 2 && SkyblockHud.hasSkyblockScoreboard() && SkyblockHud.config.rpg.showRpgHud) { - parseActionBar(event.message.getUnformattedText()); + if (event.type == 2) { + if (SkyblockHud.hasSkyblockScoreboard() && SkyblockHud.config.rpg.showRpgHud) { + parseActionBar(event.message.getUnformattedText()); + } + if (SkyblockHud.config.miningHud.showDrillBar) { + String bar = Utils.removeColor(event.message.getUnformattedText()); + Matcher DrillFuelMatcher = DrillFuelRegex.matcher(bar); + if (DrillFuelMatcher.find()) { + try { + MiningHud.setFuel(Integer.parseInt(DrillFuelMatcher.group(1).replace(",", "")), Integer.parseInt(DrillFuelMatcher.group(2).replace("k", "")) * 1000); + } catch (Exception ignored) { + MiningHud.setFuel(0, 0); + } + } + } } } @SubscribeEvent(priority = EventPriority.LOW) public void onStatusBarLow(ClientChatReceivedEvent event) { - if (event.type == 2 && SkyblockHud.hasSkyblockScoreboard() && SkyblockHud.config.rpg.showRpgHud) { - String message = event.message.getUnformattedText(); - if (lastLowEditedActionBar == null || !lastLowActionBar.equals(message)) { - lastLowActionBar = message; - message = HealthReplaceRegex.matcher(message).replaceAll(""); - message = HealthAbsorptionReplaceRegex.matcher(message).replaceAll(""); - message = DefenseReplaceRegex.matcher(message).replaceAll(""); - message = ManaReplaceRegex.matcher(message).replaceAll(""); - Matcher overflowMatcher = ManaOverflowReplaceRegex.matcher(message); - if (overflowMatcher.find()) { - message = overflowMatcher.replaceAll("\u00A73\u02AC " + overflowMatcher.group(3)); - } + if (event.type == 2) { + if (SkyblockHud.hasSkyblockScoreboard() && SkyblockHud.config.rpg.showRpgHud) { + String message = event.message.getUnformattedText(); + if (lastLowEditedActionBar == null || !lastLowActionBar.equals(message)) { + lastLowActionBar = message; + message = HealthReplaceRegex.matcher(message).replaceAll(""); + message = HealthAbsorptionReplaceRegex.matcher(message).replaceAll(""); + message = DefenseReplaceRegex.matcher(message).replaceAll(""); + message = ManaReplaceRegex.matcher(message).replaceAll(""); + Matcher overflowMatcher = ManaOverflowReplaceRegex.matcher(message); + if (overflowMatcher.find()) { + message = overflowMatcher.replaceAll("\u00A73\u02AC " + overflowMatcher.group(3)); + } - lastLowEditedActionBar = new ChatComponentText(message.trim()); + lastLowEditedActionBar = new ChatComponentText(message.trim()); + } + event.message = lastLowEditedActionBar; + } + if (SkyblockHud.config.miningHud.showDrillBar) { + event.message = new ChatComponentText(DrillFuelReplaceRegex.matcher(event.message.getUnformattedText()).replaceAll("").trim()); } - event.message = lastLowEditedActionBar; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java index fa2bacf..f1862d6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java @@ -6,7 +6,6 @@ import com.thatgravyboat.skyblockhud.core.config.Position; import com.thatgravyboat.skyblockhud.location.LocationHandler; import com.thatgravyboat.skyblockhud.location.Locations; import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler; -import java.util.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; @@ -16,6 +15,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import java.util.*; + public class TrackerHandler { public static class TrackerData { @@ -82,14 +83,14 @@ public class TrackerHandler { @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post event) { - if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), trackerIds.containsKey(LocationHandler.getCurrentLocation()), !SkyblockHud.config.trackers.hideTracker)) { + if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), trackerIds.containsKey(LocationHandler.getCurrentLocation())/*,!SkyblockHud.config.trackers.hideTracker*/)) { String trackerId = trackerIds.get(LocationHandler.getCurrentLocation()); Minecraft mc = Minecraft.getMinecraft(); TrackerData tracked = trackers.get(trackerId); Map<String, ItemStack> tracker = tracked.dropTrackers.get(tracked.getDropId(SeasonDateHandler.getCurrentEvent())); if (tracker != null) { - Position pos = SkyblockHud.config.trackers.trackerPosition; + Position pos = null;// SkyblockHud.config.trackers.trackerPosition; int startPos = pos.getAbsX(event.resolution, (tracker.size() >= 6 ? 120 : tracker.size() * 20)); int y = pos.getAbsY(event.resolution, (int) (10 + Math.ceil(tracker.size() / 5d) * 20)); diff --git a/src/main/resources/assets/skyblockhud/mines.png b/src/main/resources/assets/skyblockhud/mines.png Binary files differnew file mode 100644 index 0000000..a4e6144 --- /dev/null +++ b/src/main/resources/assets/skyblockhud/mines.png diff --git a/src/main/resources/assets/skyblockhud/playerstats.png b/src/main/resources/assets/skyblockhud/playerstats.png Binary files differindex f4aa1ee..71a47b4 100644 --- a/src/main/resources/assets/skyblockhud/playerstats.png +++ b/src/main/resources/assets/skyblockhud/playerstats.png diff --git a/src/main/resources/assets/skyblockhud/stats.png b/src/main/resources/assets/skyblockhud/stats.png Binary files differindex 7751a57..a55157f 100644 --- a/src/main/resources/assets/skyblockhud/stats.png +++ b/src/main/resources/assets/skyblockhud/stats.png diff --git a/src/main/resources/mixins.skyblockhud.json b/src/main/resources/mixins.skyblockhud.json index 3763236..d928e55 100644 --- a/src/main/resources/mixins.skyblockhud.json +++ b/src/main/resources/mixins.skyblockhud.json @@ -3,7 +3,6 @@ "refmap": "mixins.skyblockhud.refmap.json", "compatibilityLevel": "JAVA_8", "mixins": [ - "MixinEndermanRenderer", "MixinGuiIngameForge", "MixinNetHandlerPlayClient" ] |