aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/Utils.java21
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java13
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java56
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java8
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleSubCommand.java62
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java6
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java22
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java12
8 files changed, 170 insertions, 30 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
index a7621ef..8598e1f 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;
@@ -20,6 +16,11 @@ 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<>();
@@ -47,6 +48,18 @@ public class Utils {
return value <= max && value >= min;
}
+ public static float lerp(float f, float g, float h) {
+ return g + f * (h - g);
+ }
+
+ public static double lerp(double d, double e, double f) {
+ return e + d * (f - e);
+ }
+
+ public static int lerp(float f, int g, int h) {
+ return (int) (g + f * (h - g));
+ }
+
public static int whatRomanNumeral(String roman) {
switch (roman.toLowerCase()) {
case "i":
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java
index b1115ae..41a4ad8 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java
@@ -1,13 +1,9 @@
package com.thatgravyboat.skyblockhud.api;
-import static com.thatgravyboat.skyblockhud.ComponentHandler.SCOREBOARD_CHARACTERS;
-
import com.thatgravyboat.skyblockhud.Utils;
import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarPreGetEvent;
-import java.util.*;
-import java.util.stream.Collectors;
import net.minecraft.client.Minecraft;
import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreObjective;
@@ -17,6 +13,11 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.thatgravyboat.skyblockhud.ComponentHandler.SCOREBOARD_CHARACTERS;
+
public class LeaderboardGetter {
private static Map<Integer, String> cachedScores = new HashMap<>();
@@ -24,6 +25,10 @@ public class LeaderboardGetter {
private static int ticks = 0;
+ public static List<String> getCachedScores() {
+ return cachedScoresList;
+ }
+
@SubscribeEvent
public void onClientUpdate(TickEvent.ClientTickEvent event) {
if (event.phase.equals(TickEvent.Phase.START)) return;
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
index ef3df57..897c088 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
@@ -1,17 +1,27 @@
package com.thatgravyboat.skyblockhud.commands;
+import com.google.common.collect.ImmutableSet;
import com.thatgravyboat.skyblockhud.SkyblockHud;
+import com.thatgravyboat.skyblockhud.api.LeaderboardGetter;
import com.thatgravyboat.skyblockhud.config.SBHConfigEditor;
import com.thatgravyboat.skyblockhud.core.GuiScreenElementWrapper;
import com.thatgravyboat.skyblockhud.handlers.MapHandler;
import com.thatgravyboat.skyblockhud.location.LocationHandler;
-import net.minecraft.client.Minecraft;
+import com.thatgravyboat.skyblockhud.playerstats.ActionBarParsing;
import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.boss.BossStatus;
+import net.minecraft.util.ChatComponentText;
+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;
+
private static final SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
if (args.length > 0) {
@@ -22,6 +32,46 @@ public class Commands {
}
};
+ private static final SimpleSubCommand devCommand = new SimpleSubCommand("sbhdev", ImmutableSet.of("copyBossBar", "copyScoreboard", "copyActionBar")) {
+
+ @Override
+ void processSubCommand(ICommandSender sender, String subCommand, String[] args) {
+ StringSelection clipboard = null;
+ switch (subCommand) {
+ case "copyBossBar":
+ clipboard = new StringSelection(BossStatus.bossName);
+ break;
+ case "copyScoreboard":
+ StringBuilder builder = new StringBuilder();
+ LeaderboardGetter.getCachedScores().forEach(s -> builder.append(s).append("\n"));
+ clipboard = new StringSelection(builder.toString());
+ break;
+ case "copyActionBar":
+ clipboard = new StringSelection(ActionBarParsing.lastLowActionBar);
+ break;
+ }
+ 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!"
+ ));
+ }
+ }
+
+ @Override
+ void processNoSubCommand(ICommandSender sender) {
+ devMode = !devMode;
+ sender.addChatMessage(new ChatComponentText("Dev Mode " + (devMode ? "Enabled" : "Disabled") + "!"));
+ }
+ };
+
private static final SimpleCommand settingsCommand = new SimpleCommand("sbh", settingsRunnable);
private static final SimpleCommand settingsCommand2 = new SimpleCommand("sbhsettings", settingsRunnable);
private static final SimpleCommand settingsCommand3 = new SimpleCommand("sbhud", settingsRunnable);
@@ -30,7 +80,8 @@ public class Commands {
"sbhmap",
new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
- if (LocationHandler.getCurrentLocation().getCategory().getMap() != null) SkyblockHud.screenToOpen = new MapHandler.MapScreen();
+ if (LocationHandler.getCurrentLocation().getCategory().getMap() != null && SkyblockHud.hasSkyblockScoreboard())
+ SkyblockHud.screenToOpen = new MapHandler.MapScreen();
}
}
);
@@ -40,5 +91,6 @@ public class Commands {
ClientCommandHandler.instance.registerCommand(settingsCommand2);
ClientCommandHandler.instance.registerCommand(settingsCommand3);
ClientCommandHandler.instance.registerCommand(mapCommand);
+ ClientCommandHandler.instance.registerCommand(devCommand);
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java
index db23b8e..d5d3c57 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java
@@ -1,11 +1,11 @@
package com.thatgravyboat.skyblockhud.commands;
-import java.util.List;
import net.minecraft.command.CommandBase;
-import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.BlockPos;
+import java.util.List;
+
/**
@author Moulberry
**/
@@ -48,10 +48,12 @@ public class SimpleCommand extends CommandBase {
return "/" + commandName;
}
- public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
runnable.processCommand(sender, args);
}
+ @Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
if (tabRunnable != null) return tabRunnable.tabComplete(sender, args, pos);
return null;
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleSubCommand.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleSubCommand.java
new file mode 100644
index 0000000..7169c6d
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleSubCommand.java
@@ -0,0 +1,62 @@
+package com.thatgravyboat.skyblockhud.commands;
+
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.BlockPos;
+import org.apache.commons.lang3.ArrayUtils;
+
+import java.util.List;
+import java.util.Set;
+
+public abstract class SimpleSubCommand extends CommandBase {
+
+ private final String commandName;
+ private final Set<String> subCommands;
+
+ public SimpleSubCommand(String commandName, Set<String> subCommands) {
+ this.commandName = commandName;
+ this.subCommands = subCommands;
+ }
+
+ @Override
+ public String getCommandName() {
+ return commandName;
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender sender) {
+ return "/"+commandName;
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ if (args.length == 0) {
+ processNoSubCommand(sender);
+ return;
+ }
+ if (subCommands.contains(args[0])){
+ processSubCommand(sender, args[0], ArrayUtils.remove(args, 0));
+ return;
+ }
+ processBadSubCommand(sender, args[0]);
+ }
+
+ @Override
+ public boolean canCommandSenderUseCommand(ICommandSender sender) {
+ return true;
+ }
+
+ @Override
+ public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
+ if (args.length == 1){
+ return getListOfStringsMatchingLastWord(args,subCommands);
+ }
+ return null;
+ }
+
+ abstract void processSubCommand(ICommandSender sender, String subCommand, String[] args);
+
+ abstract void processNoSubCommand(ICommandSender sender);
+
+ public void processBadSubCommand(ICommandSender sender, String subCommand){}
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
index 74e7ae1..703da19 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
@@ -86,6 +86,7 @@ public enum Locations {
THELIFT("thelift", "The Lift", LocationCategory.DWARVENMINES),
DWARVENVILLAGE("dwarvenvillage", "Dwarven Village", LocationCategory.DWARVENMINES),
DWARVENMINES("dwarvenmines", "Dwarven Mines", LocationCategory.DWARVENMINES),
+ DWARVENTAVERN("dwarvemtavern", "Dwarven Tavern", LocationCategory.DWARVENMINES),
LAVASPRINGS("lavasprings", "Lava Springs", LocationCategory.DWARVENMINES),
PALACEBRIDGE("palacebridge", "Palace Bridge", LocationCategory.DWARVENMINES),
ROYALPALACE("royalpalace", "Royal Palace", LocationCategory.DWARVENMINES),
@@ -110,11 +111,14 @@ public enum Locations {
MINERSGUILD("minersguild", "Miner's Guild", LocationCategory.DWARVENMINES),
//CRYSTALHOLLOWS
JUNGLE("jungle", "Jungle", LocationCategory.CRYSTALHOLLOWS),
+ MINESOFDIVAN("minesofdivan", "Mines of Divan", LocationCategory.CRYSTALHOLLOWS),
MAMGAFIELDS("magmafields", "Magma Fields", LocationCategory.CRYSTALHOLLOWS),
GOBLINHOLDOUT("goblinholdout", "Goblin Holdout", LocationCategory.CRYSTALHOLLOWS),
CRYSTALNUCLEUS("crystalnucleus", "Crystal Nucleus", LocationCategory.CRYSTALHOLLOWS),
PERCURSORREMNANTS("precursorremnants", "Precursor Remnants", LocationCategory.CRYSTALHOLLOWS),
- MITHRILDEPOSITS("mithrildeposits", "Mithril Deposits", LocationCategory.CRYSTALHOLLOWS);
+ MITHRILDEPOSITS("mithrildeposits", "Mithril Deposits", LocationCategory.CRYSTALHOLLOWS),
+ LOSTPRECURSORCITY("lostprecursorcity", "Lost Precursor City", LocationCategory.CRYSTALHOLLOWS),
+ CRYSTALHOLLOWS("crystalhollows", "Crystal Hollows", LocationCategory.CRYSTALHOLLOWS);
private final String name;
private final String displayName;
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java
index d6a9709..ee23b7e 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java
@@ -5,8 +5,6 @@ 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 net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -15,6 +13,9 @@ 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;
@@ -83,22 +84,19 @@ public class RPGHud extends Gui {
drawTexturedModalRect(rightAligned ? x + 3 : 47 + x, 22 + y, rightAligned ? 186 : 0, 77, (int) absorptionWidth, 5);
}
- float xpWidth = 67 * mc.thePlayer.experience;
- drawTexturedModalRect(rightAligned ? x + 7 : 45 + x, 28 + y, rightAligned ? 189 : 0, 73, (int) xpWidth, 4);
+ drawTexturedModalRect(rightAligned ? x + 7 : 45 + x, 28 + y, rightAligned ? 189 : 0, 73, Utils.lerp(mc.thePlayer.experience, 0, 67), 4);
//Air in water
NumberFormat myFormat = NumberFormat.getInstance();
myFormat.setGroupingUsed(true);
if (mc.thePlayer.getAir() < 300) {
- float airWidth = 60 * ((float) mc.thePlayer.getAir() / 300);
drawTexturedModalRect(rightAligned ? x + 17 : 39 + x, 33 + y, rightAligned ? 192 : 0, 82, 64, 6);
- drawTexturedModalRect(rightAligned ? x + 19 : 41 + x, 33 + y, rightAligned ? 196 : 0, 88, (int) airWidth, 4);
+ drawTexturedModalRect(rightAligned ? x + 19 : 41 + x, 33 + y, rightAligned ? 196 : 0, 88, Utils.lerp(mc.thePlayer.getAir() / 300f, 0, 60), 4);
}
- GlStateManager.scale(0.75f, 0.75f, 1);
- drawCenteredString(mc.fontRendererObj, "" + mc.thePlayer.experienceLevel, (rightAligned ? 130 : 0) + (int) (15 + x / 0.75f), (int) (45 + y / 0.75f), 8453920);
- GlStateManager.scale(1 / 0.75f, 1 / 0.75f, 1);
- GlStateManager.scale(0.75f, 0.75f, 1);
- font.drawString(ChatFormatting.RED + " \u2764 " + health + "/" + maxHealth, (rightAligned ? -40 : 0) + (int) (64 + x / 0.75f), (int) (8 + y / 0.75f), 0xffffff, true);
- GlStateManager.scale(1 / 0.75f, 1 / 0.75f, 1);
+
+ 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(ChatFormatting.RED + " \u2764 " + health + "/" + maxHealth, mc.fontRendererObj, (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 4e895f9..5340fad 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java
@@ -3,8 +3,6 @@ package com.thatgravyboat.skyblockhud.playerstats;
import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.Utils;
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,10 +10,13 @@ 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 = "";
- private static String lastLowActionBar = "";
+ public static String lastLowActionBar = "";
private static IChatComponent lastLowEditedActionBar = null;
private static final Pattern HealthRegex = Pattern.compile("([0-9]+)/([0-9]+)\u2764");
@@ -64,7 +65,10 @@ public class ActionBarParsing {
message = HealthAbsorptionReplaceRegex.matcher(message).replaceAll("");
message = DefenseReplaceRegex.matcher(message).replaceAll("");
message = ManaReplaceRegex.matcher(message).replaceAll("");
- message = ManaOverflowReplaceRegex.matcher(message).replaceAll("");
+ Matcher overflowMatcher = ManaOverflowReplaceRegex.matcher(message);
+ if (overflowMatcher.find()){
+ message = overflowMatcher.replaceAll("\u00A73\u02AC " + overflowMatcher.group(3));
+ }
lastLowEditedActionBar = new ChatComponentText(message.trim());
}