Skip to content

Commit

Permalink
Merge pull request #645 from AzureAaron/glaciate-tunnels
Browse files Browse the repository at this point in the history
Glacite Mining Updates & Fixes
  • Loading branch information
kevinthegreat1 authored Apr 12, 2024
2 parents a8ab2df + 05a0e43 commit 5041bde
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 25 deletions.
48 changes: 28 additions & 20 deletions src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,33 @@

public class DwarvenHud {

public static final MinecraftClient client = MinecraftClient.getInstance();
public static List<Commission> commissionList = new ArrayList<>();
private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
private static List<Commission> commissionList = new ArrayList<>();

public static String mithrilPowder = "0";
public static String gemStonePowder = "0";
public static String glacitePowder = "0";

public static final List<Pattern> COMMISSIONS = Stream.of(
private static final List<Pattern> COMMISSIONS = Stream.of(
"(?:Titanium|Mithril|Hard Stone) Miner",
"(?:Ice Walker|Golden Goblin|(?<!Golden )Goblin|Goblin Raid|Automaton|Sludge|Team Treasurite Member|Yog|Boss Corleone|Thyst) Slayer",
"(?:Glacite Walker|Golden Goblin|(?<!Golden )Goblin|Goblin Raid|Treasure Hoarder|Automaton|Sludge|Team Treasurite Member|Yog|Boss Corleone|Thyst) Slayer",
"(?:Lava Springs|Cliffside Veins|Rampart's Quarry|Upper Mines|Royal Mines) Mithril",
"(?:Lava Springs|Cliffside Veins|Rampart's Quarry|Upper Mines|Royal Mines) Titanium",
"Goblin Raid",
"(?:Powder Ghast|Star Sentry|Treasure Hoarder) Puncher",
"(?:Star Sentry|Treasure Hoarder) Puncher",
"(?<!Lucky )Raffle",
"Lucky Raffle",
"2x Mithril Powder Collector",
"First Event",
"(?:Ruby|Amber|Sapphire|Jade|Amethyst|Topaz) Gemstone Collector",
"(?:Ruby|Amber|Sapphire|Jade|Amethyst|Topaz|Onyx|Aquamarine|Citrine|Peridot) Gemstone Collector",
"(?:Amber|Sapphire|Jade|Amethyst|Topaz) Crystal Hunter",
"Chest Looter").map(s -> Pattern.compile("(" + s + "): (\\d+\\.?\\d*%|DONE)")
"(?:Umber|Tungsten|Glacite|Scrap) Collector",
"Mineshaft Explorer",
"(?:Chest|Corpse) Looter").map(s -> Pattern.compile("(" + s + "): (\\d+\\.?\\d*%|DONE)")
).collect(Collectors.toList());
public static final Pattern MITHRIL_PATTERN = Pattern.compile("Mithril Powder: [0-9,]+");
public static final Pattern GEMSTONE_PATTERN = Pattern.compile("Gemstone Powder: [0-9,]+");
private static final Pattern MITHRIL_PATTERN = Pattern.compile("Mithril: [0-9,]+");
private static final Pattern GEMSTONE_PATTERN = Pattern.compile("Gemstone: [0-9,]+");
private static final Pattern GLACITE_PATTERN = Pattern.compile("Glacite: [0-9,]+");

public static void init() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("skyblocker")
Expand All @@ -59,8 +63,8 @@ public static void init() {

HudRenderCallback.EVENT.register((context, tickDelta) -> {
if (!SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.enabledCommissions && !SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.enabledPowder
|| client.options.playerListKey.isPressed()
|| client.player == null
|| CLIENT.options.playerListKey.isPressed()
|| CLIENT.player == null
|| (!Utils.isInDwarvenMines() && !Utils.isInCrystalHollows())) {
return;
}
Expand All @@ -74,7 +78,7 @@ public static void init() {
});
}

public static void render(HudCommsWidget hcw, HudPowderWidget hpw, DrawContext context, int comHudX, int comHudY, int powderHudX, int powderHudY, List<Commission> commissions) {
protected static void render(HudCommsWidget hcw, HudPowderWidget hpw, DrawContext context, int comHudX, int comHudY, int powderHudX, int powderHudY, List<Commission> commissions) {
switch (SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.style) {
case SIMPLE -> renderSimple(hcw, hpw, context, comHudX, comHudY, powderHudX, powderHudY, commissions);
case FANCY -> renderFancy(hcw, hpw, context, comHudX, comHudY, powderHudX, powderHudY, commissions);
Expand All @@ -91,7 +95,7 @@ public static void render(HudCommsWidget hcw, HudPowderWidget hpw, DrawContext c
* @param powderHudY Y coordinate of the powder hud
* @param commissions the commissions to render to the commissions hud
*/
public static void renderClassic(DrawContext context, int comHudX, int comHudY, int powderHudX, int powderHudY, List<Commission> commissions) {
private static void renderClassic(DrawContext context, int comHudX, int comHudY, int powderHudX, int powderHudY, List<Commission> commissions) {
if (SkyblockerConfigManager.get().general.tabHud.enableHudBackground) {
context.fill(comHudX, comHudY, comHudX + 200, comHudY + (20 * commissions.size()), 0x64000000);
context.fill(powderHudX, powderHudY, powderHudX + 200, powderHudY + 40, 0x64000000);
Expand All @@ -106,7 +110,7 @@ public static void renderClassic(DrawContext context, int comHudX, int comHudY,
percentage = 100f;
}

context.drawTextWithShadow(client.textRenderer,
context.drawTextWithShadow(CLIENT.textRenderer,
Text.literal(commission.commission + ": ").formatted(Formatting.AQUA)
.append(Text.literal(commission.progression).formatted(Colors.hypixelProgressColor(percentage))),
comHudX + 5, comHudY + y + 5, 0xFFFFFFFF);
Expand All @@ -115,16 +119,16 @@ public static void renderClassic(DrawContext context, int comHudX, int comHudY,
}
if (SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.enabledPowder) {
//render mithril powder then gemstone
context.drawTextWithShadow(client.textRenderer,
context.drawTextWithShadow(CLIENT.textRenderer,
Text.literal("Mithril: " + mithrilPowder).formatted(Formatting.AQUA),
powderHudX + 5, powderHudY + 5, 0xFFFFFFFF);
context.drawTextWithShadow(client.textRenderer,
context.drawTextWithShadow(CLIENT.textRenderer,
Text.literal("Gemstone: " + gemStonePowder).formatted(Formatting.DARK_PURPLE),
powderHudX + 5, powderHudY + 25, 0xFFFFFFFF);
}
}

public static void renderSimple(HudCommsWidget hcw, HudPowderWidget hpw, DrawContext context, int comHudX, int comHudY, int powderHudX, int powderHudY, List<Commission> commissions) {
private static void renderSimple(HudCommsWidget hcw, HudPowderWidget hpw, DrawContext context, int comHudX, int comHudY, int powderHudX, int powderHudY, List<Commission> commissions) {
if (SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.enabledCommissions) {
hcw.updateData(commissions, false);
hcw.update();
Expand All @@ -140,7 +144,7 @@ public static void renderSimple(HudCommsWidget hcw, HudPowderWidget hpw, DrawCon
}
}

public static void renderFancy(HudCommsWidget hcw, HudPowderWidget hpw, DrawContext context, int comHudX, int comHudY, int powderHudX, int powderHudY, List<Commission> commissions) {
private static void renderFancy(HudCommsWidget hcw, HudPowderWidget hpw, DrawContext context, int comHudX, int comHudY, int powderHudX, int powderHudY, List<Commission> commissions) {
if (SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.enabledCommissions) {
hcw.updateData(commissions, true);
hcw.update();
Expand All @@ -157,15 +161,15 @@ public static void renderFancy(HudCommsWidget hcw, HudPowderWidget hpw, DrawCont
}

public static void update() {
if (client.player == null || client.getNetworkHandler() == null
if (CLIENT.player == null || CLIENT.getNetworkHandler() == null
|| !SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.enabledCommissions && !SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.enabledPowder
|| !Utils.isInCrystalHollows() && !Utils.isInDwarvenMines()) {
return;
}

commissionList = new ArrayList<>();

for (PlayerListEntry playerListEntry : client.getNetworkHandler().getPlayerList()) {
for (PlayerListEntry playerListEntry : CLIENT.getNetworkHandler().getPlayerList()) {
if (playerListEntry.getDisplayName() == null) {
continue;
}
Expand All @@ -186,6 +190,10 @@ public static void update() {
if (gemstoneMatcher.matches()) {
gemStonePowder = gemstoneMatcher.group(0).split(": ")[1];
}
Matcher glaciteMatcher = GLACITE_PATTERN.matcher(name);
if (glaciteMatcher.matches()) {
glacitePowder = glaciteMatcher.group(0).split(": ")[1];
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ public class Ico {
public static final ItemStack LIME_DYE = new ItemStack(Items.LIME_DYE);
public static final ItemStack ENCHANTED_BOOK = new ItemStack(Items.ENCHANTED_BOOK);
public static final ItemStack SPIDER_EYE = new ItemStack(Items.SPIDER_EYE);
public static final ItemStack BLUE_ICE = new ItemStack(Items.BLUE_ICE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum Location {
INSTANCED("kuudra"),
THE_RIFT("rift"),
DARK_AUCTION("dark_auction"),
GLACITE_MINESHAFT("mineshaft"),
UNKNOWN("unknown");

public final String internal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public class HudPowderWidget extends Widget {
* current value of Gemstone Powder
*/
private static int gemstonePowder = 0;
/**
* current value of Glacite Powder
*/
private static int glacitePowder = 0;
/**
* the difference between the previous and current value of Mithril Powder
*/
Expand All @@ -37,6 +41,10 @@ public class HudPowderWidget extends Widget {
* the difference between the previous and current value of Gemstone Powder
*/
private static int gemstonePowderDiff = 0;
/**
* the difference between the previous and current value of Glacite Powder
*/
private static int glacitePowderDiff = 0;
/**
* The initial value of the timer for the difference update delay countdown.
*/
Expand Down Expand Up @@ -77,8 +85,8 @@ private static int parsePowder(String str) {
/**
* Converts Powder and difference values to a string and adds commas to the digits of the numbers.
*
* @param powder the value of Mithril or Gemstone Powder
* @param diff the difference between the previous and current value of Mithril or Gemstone Powder
* @param powder the value of Mithril, Gemstone Powder, or Glacite Powder
* @param diff the difference between the previous and current value of Mithril, Gemstone, or Glacite Powder
* @return formatted string
*/
private static String formatPowderString(int powder, int diff) {
Expand All @@ -94,15 +102,18 @@ private static void updatePowders() {

int newMithrilPowder = parsePowder(DwarvenHud.mithrilPowder);
int newGemstonePowder = parsePowder(DwarvenHud.gemStonePowder);
int newGlacitePowder = parsePowder(DwarvenHud.glacitePowder);

if (newMithrilPowder != mithrilPowder || newGemstonePowder != gemstonePowder || elapsedTime > 2000) {
if (newMithrilPowder != mithrilPowder || newGemstonePowder != gemstonePowder || newGlacitePowder != glacitePowder || elapsedTime > 2000) {
startTime = System.currentTimeMillis();

mithrilPowderDiff = newMithrilPowder - mithrilPowder;
gemstonePowderDiff = newGemstonePowder - gemstonePowder;
glacitePowderDiff = newGlacitePowder - glacitePowder;

mithrilPowder = newMithrilPowder;
gemstonePowder = newGemstonePowder;
glacitePowder = newGlacitePowder;
}
}

Expand All @@ -111,9 +122,11 @@ public void updateContent() {
updatePowders();
String mithrilPowderString = formatPowderString(mithrilPowder, mithrilPowderDiff);
String gemstonePowderString = formatPowderString(gemstonePowder, gemstonePowderDiff);
String glacitePowderString = formatPowderString(glacitePowder, glacitePowderDiff);

this.addSimpleIcoText(Ico.MITHRIL, "Mithril: ", Formatting.AQUA, mithrilPowderString);
this.addSimpleIcoText(Ico.MITHRIL, "Mithril: ", Formatting.DARK_GREEN, mithrilPowderString);
this.addSimpleIcoText(Ico.AMETHYST_SHARD, "Gemstone: ", Formatting.DARK_PURPLE, gemstonePowderString);
this.addSimpleIcoText(Ico.BLUE_ICE, "Glacite: ", Formatting.AQUA, glacitePowderString);
}

}
4 changes: 4 additions & 0 deletions src/main/java/de/hysky/skyblocker/utils/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public enum Location {
* mode: kuudra
*/
KUUDRAS_HOLLOW("kuudra"),
/**
* The freezing cold Glacite Mineshafts! *brr... so cold... :(*
*/
GLACITE_MINESHAFT("mineshaft"),
/**
* Unknown Skyblock location
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/hysky/skyblocker/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static boolean isInCrystalHollows() {
}

public static boolean isInDwarvenMines() {
return location == Location.DWARVEN_MINES || FabricLoader.getInstance().isDevelopmentEnvironment();
return location == Location.DWARVEN_MINES || location == Location.GLACITE_MINESHAFT || FabricLoader.getInstance().isDevelopmentEnvironment();
}

public static boolean isInTheRift() {
Expand Down

0 comments on commit 5041bde

Please sign in to comment.