aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-08-31 20:21:30 -0400
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-08-31 20:40:44 -0400
commitaa2abcf644bf58adb3330e87d870ce56a09ce3f5 (patch)
treef9e9114f9b0031ce61dcfba05a030453f540d6b1 /src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven
parentfea919794608128b6c436f1a64d1be38e935241d (diff)
parent1370097922f19815e14bdfd8c9e606cde2bc8f39 (diff)
downloadSkyblocker-aa2abcf644bf58adb3330e87d870ce56a09ce3f5.tar.gz
Skyblocker-aa2abcf644bf58adb3330e87d870ce56a09ce3f5.tar.bz2
Skyblocker-aa2abcf644bf58adb3330e87d870ce56a09ce3f5.zip
Merge branch 'master' into utils-cleanup
# Conflicts: # src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java # src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java # src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java # src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java # src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java64
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java17
2 files changed, 55 insertions, 26 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java
index 5d6df319..3563741c 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java
@@ -1,7 +1,8 @@
package me.xmrvizzy.skyblocker.skyblock.dwarven;
+import it.unimi.dsi.fastutil.ints.IntIntPair;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
-import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.CommsWidget;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.hud.HudCommsWidget;
import me.xmrvizzy.skyblocker.utils.scheduler.Scheduler;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
@@ -20,11 +21,9 @@ import java.util.stream.Stream;
public class DwarvenHud {
-
public static final MinecraftClient client = MinecraftClient.getInstance();
public static List<Commission> commissionList = new ArrayList<>();
-
public static final List<Pattern> COMMISSIONS = Stream.of(
"(?:Titanium|Mithril|Hard Stone) Miner",
"(?:Ice Walker|Goblin|Goblin Raid|Automaton|Sludge|Team Treasurite Member|Yog|Boss Corleone|Thyst) Slayer",
@@ -37,8 +36,7 @@ public class DwarvenHud {
"2x Mithril Powder Collector",
"(?:Ruby|Amber|Sapphire|Jade|Amethyst|Topaz) Gemstone Collector",
"(?:Amber|Sapphire|Jade|Amethyst|Topaz) Crystal Hunter",
- "Chest Looter"
- ).map(s -> Pattern.compile("^.*(" + s + "): (\\d+\\.?\\d*%|DONE)"))
+ "Chest Looter").map(s -> Pattern.compile("^.*(" + s + "): (\\d+\\.?\\d*%|DONE)"))
.collect(Collectors.toList());
public static void init() {
@@ -54,15 +52,34 @@ public class DwarvenHud {
|| commissionList.isEmpty()) {
return;
}
- render(context, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.x, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.y, commissionList);
+ render(HudCommsWidget.INSTANCE, context, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.x,
+ SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.y, commissionList);
});
}
- public static void render(DrawContext context, int hudX, int hudY, List<Commission> commissions) {
+ public static IntIntPair getDimForConfig(List<Commission> commissions) {
+ return switch (SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.style) {
+ case SIMPLE -> {
+ HudCommsWidget.INSTANCE_CFG.updateData(commissions, false);
+ yield IntIntPair.of(
+ HudCommsWidget.INSTANCE_CFG.getWidth(),
+ HudCommsWidget.INSTANCE_CFG.getHeight());
+ }
+ case FANCY -> {
+ HudCommsWidget.INSTANCE_CFG.updateData(commissions, true);
+ yield IntIntPair.of(
+ HudCommsWidget.INSTANCE_CFG.getWidth(),
+ HudCommsWidget.INSTANCE_CFG.getHeight());
+ }
+ default -> IntIntPair.of(200, 20 * commissions.size());
+ };
+ }
+
+ public static void render(HudCommsWidget hcw, DrawContext context, int hudX, int hudY, List<Commission> commissions) {
switch (SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.style) {
- case SIMPLE -> renderSimple(context, hudX, hudY, commissions);
- case FANCY -> renderFancy(context, hudX, hudY, commissions);
+ case SIMPLE -> renderSimple(hcw, context, hudX, hudY, commissions);
+ case FANCY -> renderFancy(hcw, context, hudX, hudY, commissions);
case CLASSIC -> renderClassic(context, hudX, hudY, commissions);
}
}
@@ -85,23 +102,28 @@ public class DwarvenHud {
}
}
- public static void renderSimple(DrawContext context, int hudX, int hudY, List<Commission> commissions) {
- CommsWidget cw = new CommsWidget(commissions, false);
- cw.setX(hudX);
- cw.setY(hudY);
- cw.render(context, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground);
+ public static void renderSimple(HudCommsWidget hcw, DrawContext context, int hudX, int hudY, List<Commission> commissions) {
+ hcw.updateData(commissions, false);
+ hcw.update();
+ hcw.setX(hudX);
+ hcw.setY(hudY);
+ hcw.render(context,
+ SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground);
}
- public static void renderFancy(DrawContext context, int hudX, int hudY, List<Commission> commissions) {
- CommsWidget cw = new CommsWidget(commissions, true);
- cw.setX(hudX);
- cw.setY(hudY);
- cw.render(context, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground);
+ public static void renderFancy(HudCommsWidget hcw, DrawContext context, int hudX, int hudY, List<Commission> commissions) {
+ hcw.updateData(commissions, true);
+ hcw.update();
+ hcw.setX(hudX);
+ hcw.setY(hudY);
+ hcw.render(context,
+ SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground);
}
public static void update() {
commissionList = new ArrayList<>();
- if (client.player == null || client.getNetworkHandler() == null || !SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enabled) return;
+ if (client.player == null || client.getNetworkHandler() == null || !SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enabled)
+ return;
client.getNetworkHandler().getPlayerList().forEach(playerListEntry -> {
if (playerListEntry.getDisplayName() != null) {
@@ -116,7 +138,7 @@ public class DwarvenHud {
});
}
- // steamroller tactics to get visibility from outside classes (CommsWidget)
+ // steamroller tactics to get visibility from outside classes (HudCommsWidget)
public record Commission(String commission, String progression) {
}
} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java
index 3ab08bfb..35a296fb 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java
@@ -1,7 +1,10 @@
package me.xmrvizzy.skyblocker.skyblock.dwarven;
+import it.unimi.dsi.fastutil.ints.IntIntPair;
import me.shedaniel.autoconfig.AutoConfig;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import me.xmrvizzy.skyblocker.skyblock.dwarven.DwarvenHud.Commission;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.hud.HudCommsWidget;
import me.xmrvizzy.skyblocker.utils.render.RenderHelper;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
@@ -12,6 +15,8 @@ import java.util.List;
public class DwarvenHudConfigScreen extends Screen {
+ private static final List<Commission> CFG_COMMS = List.of(new DwarvenHud.Commission("Test Commission 1", "1%"), new DwarvenHud.Commission("Test Commission 2", "2%"));
+
private int hudX = SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.x;
private int hudY = SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.y;
@@ -23,15 +28,16 @@ public class DwarvenHudConfigScreen extends Screen {
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
renderBackground(context);
- DwarvenHud.render(context, hudX, hudY, List.of(new DwarvenHud.Commission("Test Commission 1", "1%"), new DwarvenHud.Commission("Test Commission 2", "2%")));
+ DwarvenHud.render(HudCommsWidget.INSTANCE_CFG, context, hudX, hudY, List.of(new DwarvenHud.Commission("Test Commission 1", "1%"), new DwarvenHud.Commission("Test Commission 2", "2%")));
context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB());
}
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
+ IntIntPair dims = DwarvenHud.getDimForConfig(CFG_COMMS);
if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + 200, hudY + 40) && button == 0) {
- hudX = (int) Math.max(Math.min(mouseX - 100, this.width - 200), 0);
- hudY = (int) Math.max(Math.min(mouseY - 20, this.height - 40), 0);
+ hudX = (int) Math.max(Math.min(mouseX - (double) dims.leftInt() / 2, this.width - dims.leftInt()), 0);
+ hudY = (int) Math.max(Math.min(mouseY - (double) dims.rightInt() / 2, this.height - dims.rightInt()), 0);
}
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}
@@ -39,8 +45,9 @@ public class DwarvenHudConfigScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 1) {
- hudX = this.width / 2 - 100;
- hudY = this.height / 2 - 20;
+ IntIntPair dims = DwarvenHud.getDimForConfig(CFG_COMMS);
+ hudX = this.width / 2 - dims.leftInt();
+ hudY = this.height / 2 - dims.rightInt();
}
return super.mouseClicked(mouseX, mouseY, button);
}