diff options
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock')
63 files changed, 3091 insertions, 16 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 86fe58fe..9f1e783c 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -1,6 +1,7 @@ package me.xmrvizzy.skyblocker.skyblock.dwarven; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.CommsWidget; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; @@ -55,17 +56,49 @@ public class DwarvenHud { } public static void render(MatrixStack matrixStack, int hudX, int hudY, List<Commission> commissions) { - if (commissions.size() > 0){ - if (SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground) - DrawableHelper.fill(matrixStack, hudX, hudY, hudX + 200, hudY + (20 * commissions.size()), 0x64000000); - int y = 0; - for (Commission commission : commissions) { - client.textRenderer.drawWithShadow(matrixStack, Text.literal(commission.commission).styled(style -> style.withColor(Formatting.AQUA)).append(Text.literal(": " + commission.progression).styled(style -> style.withColor(Formatting.GREEN))), hudX + 5, hudY + y + 5, 0xFFFFFFFF); - y += 20; - } + if (commissions.size() <= 0) { + return; + } + + switch(SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.style) { + case SIMPLE -> renderSimple(matrixStack, hudX, hudY, commissions); + case FANCY -> renderFancy(matrixStack, hudX, hudY, commissions); + case CLASSIC -> renderClassic(matrixStack, hudX, hudY, commissions); + } + } + + public static void renderClassic(MatrixStack matrixStack, int hudX, int hudY, List<Commission> commissions) { + if (SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground) { + DrawableHelper.fill(matrixStack, hudX, hudY, hudX + 200, hudY + (20 * commissions.size()), 0x64000000); + } + + int y = 0; + for (Commission commission : commissions) { + client.textRenderer + .drawWithShadow(matrixStack, + Text.literal(commission.commission + ": ") + .styled(style -> style.withColor(Formatting.AQUA)) + .append(Text.literal(commission.progression) + .styled(style -> style.withColor(Formatting.GREEN))), + hudX + 5, hudY + y + 5, 0xFFFFFFFF); + y += 20; } } + public static void renderSimple(MatrixStack matrixStack, int hudX, int hudY, List<Commission> commissions) { + CommsWidget cw = new CommsWidget(commissions, false); + cw.setX(hudX); + cw.setY(hudY); + cw.render(matrixStack, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground); + } + + public static void renderFancy(MatrixStack matrixStack, int hudX, int hudY, List<Commission> commissions) { + CommsWidget cw = new CommsWidget(commissions, true); + cw.setX(hudX); + cw.setY(hudY); + cw.render(matrixStack, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground); + } + public static void update() { commissionList = new ArrayList<>(); if (client.player == null || !SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enabled) return; @@ -83,13 +116,7 @@ public class DwarvenHud { }); } - public static class Commission{ - final String commission; - final String progression; + // steamroller tactics to get visibility from outside classes + public static record Commission(String commission, String progression){} - public Commission(String commission, String progression){ - this.commission = commission; - this.progression = progression; - } - } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/TabHud.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/TabHud.java new file mode 100644 index 00000000..01c196f7 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/TabHud.java @@ -0,0 +1,40 @@ +package me.xmrvizzy.skyblocker.skyblock.tabhud; + +import org.lwjgl.glfw.GLFW; + +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; +import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.util.InputUtil; + +public class TabHud { + + public static KeyBinding playerTgl; + public static KeyBinding genericTgl; + // public static KeyBinding mapTgl; + public static KeyBinding defaultTgl; + + public static void init() { + + playerTgl = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.skyblocker.playerTgl", + InputUtil.Type.KEYSYM, + GLFW.GLFW_KEY_LEFT_SHIFT, + "key.categories.skyblocker")); + genericTgl = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.skyblocker.genericTgl", + InputUtil.Type.KEYSYM, + GLFW.GLFW_KEY_LEFT_ALT, + "key.categories.skyblocker")); + // mapTgl = KeyBindingHelper.registerKeyBinding( + // new KeyBinding("key.tabhud.mapTgl", + // InputUtil.Type.KEYSYM, + // GLFW.GLFW_KEY_LEFT_ALT, + // "key.categories.skyblocker")); + defaultTgl = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.skyblocker.defaultTgl", + InputUtil.Type.KEYSYM, + GLFW.GLFW_KEY_B, + "key.categories.skyblocker")); + + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/EmptyScreen.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/EmptyScreen.java new file mode 100644 index 00000000..07162834 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/EmptyScreen.java @@ -0,0 +1,19 @@ +package me.xmrvizzy.skyblocker.skyblock.tabhud.screens; + +import java.util.List; + +import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.EmptyWidget; + +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.text.Text; + +public class EmptyScreen extends Screen { + + public EmptyScreen(int w, int h, List<PlayerListEntry> ple, Text footer) { + super(w, h); + EmptyWidget ew = new EmptyWidget(ple); + this.center(ew); + this.addWidget(ew); + } + +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/Screen.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/Screen.java new file mode 100644 index 00000000..0274f839 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/Screen.java @@ -0,0 +1,262 @@ +package me.xmrvizzy.skyblocker.skyblock.tabhud.screens; + +import java.util.ArrayList; +import java.util.List; + +import me.xmrvizzy.skyblocker.skyblock.tabhud.TabHud; +import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.genericInfo.*; +import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.*; +import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.playerList.*; +import me.xmrvizzy.skyblocker.skyblock.tabhud.util.StrMan; +import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.Widget; + +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; + +public class Screen { + + private enum ScreenType { + DUNGEON, + GUEST_ISLAND, + HOME_ISLAND, + CRIMSON_ISLE, + DUNGEON_HUB, + FARMING_ISLAND, + PARK, + DWARVEN_MINES, + CRYSTAL_HOLLOWS, + END, + GOLD_MINE, + DEEP_CAVERNS, + HUB, + SPIDER_DEN, + JERRY, + GARDEN, + NONE + } + + private ArrayList<Widget> widgets = new ArrayList<>(); + private int w, h; + + public Screen(int w, int h) { + this.w = w; + this.h = h; + } + + public void addWidget(Widget w) { + widgets.add(w); + } + + public void addWidgets(Widget... ws) { + for (Widget w : ws) { + widgets.add(w); + } + } + + public void render(MatrixStack ms) { + for (Widget w : widgets) { + w.render(ms); + } + } + + public void stackWidgetsH(Widget... list) { + int compHeight = -5; + for (Widget wid : list) { + compHeight += wid.getHeight() + 5; + } + + int y = (h - compHeight) / 2; + for (Widget wid : list) { + wid.setY(y); + y += wid.getHeight() + 5; + } + } + + public void stackWidgetsW(Widget... list) { + // TODO not centered + int compWidth = -5; + for (Widget wid : list) { + compWidth += wid.getWidth() + 5; + } + + int x = (w - compWidth) / 2; + for (Widget wid : list) { + wid.setX(x); + x += wid.getWidth() + 5; + } + } + + public void centerH(Widget wid) { + wid.setY((h - wid.getHeight()) / 2); + } + + public void centerW(Widget wid) { + wid.setX((w - wid.getWidth()) / 2); + } + + public void center(Widget wid) { + this.centerH(wid); + this.centerW(wid); + } + + public void offCenterL(Widget wid) { + int wHalf = this.w / 2; + wid.setX(wHalf - 3 - wid.getWidth()); + } + + public void offCenterR(Widget wid) { + int wHalf = this.w / 2; + wid.setX(wHalf + 3); + } + + public void collideAgainstL(Widget w, Widget... others) { + int yMin = w.getY(); + int yMax = w.getY() + w.getHeight(); + + int xCor = this.w / 2; + + // assume others to be sorted top-bottom. + for (Widget other : others) { + if (other.getY() + other.getHeight() + 5 < yMin) { + // too high, next one + continue; + } + + if (other.getY() - 5 > yMax) { + // too low, no more collisions possible + break; + } + + int xPos = other.getX() - 5 - w.getWidth(); + xCor = Math.min(xCor, xPos); + } + w.setX(xCor); + } + + public void collideAgainstR(Widget w, Widget... others) { + int yMin = w.getY(); + int yMax = w.getY() + w.getHeight(); + + int xCor = this.w / 2; + + // assume others to be sorted top-bottom. + for (Widget other : others) { + if (other.getY() + other.getHeight() + 5 < yMin) { + // too high, next one + continue; + } + + if (other.getY() - 5 > yMax) { + // too low, no more collisions possible + break; + } + + int xPos = other.getX() + other.getWidth() + 5; + xCor = Math.max(xCor, xPos); + } + w.setX(xCor); + } + + public static Screen getCorrect(int w, int h, List<PlayerListEntry> ple, Text footer) { + if (TabHud.genericTgl.isPressed()) { + return Screen.correctGenericScrn(w, h, ple, footer); + // } else if (TabHud.mapTgl.isPressed()) { + // return Screen.correctMapScrn(w, h, ple, footer); + } else if (TabHud.playerTgl.isPressed()) { + return Screen.correctPlayerScrn(w, h, ple, footer); + } else { + return Screen.correctMainScrn(w, h, ple, footer); + } + } + + + private static ScreenType getScreenType(List<PlayerListEntry> ple) { + String cat2Name = StrMan.strAt(ple, 40); + + if (cat2Name.contains("Dungeon Stats")) { + return ScreenType.DUNGEON; + } + + String areaDesciptor = StrMan.strAt(ple, 41).substring(6); + switch (areaDesciptor) { + case "Private Island": + if (ple.get(44).getDisplayName().getString().endsWith("Guest")) { + return ScreenType.GUEST_ISLAND; + } else { + return ScreenType.HOME_ISLAND; + } + case "Crimson Isle": + return ScreenType.CRIMSON_ISLE; + case "Dungeon Hub": + return ScreenType.DUNGEON_HUB; + case "The Farming Islands": + return ScreenType.FARMING_ISLAND; + case "The Park": + return ScreenType.PARK; + case "Dwarven Mines": + return ScreenType.DWARVEN_MINES; + case "Crystal Hollows": + return ScreenType.CRYSTAL_HOLLOWS; + case "The End": + return ScreenType.END; + case "Gold Mine": + return ScreenType.GOLD_MINE; + case "Deep Caverns": + return ScreenType.D |
