aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud
diff options
context:
space:
mode:
authorJakub <jakvb.kolodziej@gmail.com>2023-06-25 13:16:59 +0200
committerGitHub <noreply@github.com>2023-06-25 13:16:59 +0200
commit5bd5e7d4881f34c1da9dcbde899f655de3777b96 (patch)
treefcaf7de10025bbf5a33b5798b71d50c4f122a638 /src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud
parentf3f000a7e5a015aa7690502c8c3b74ce558decf6 (diff)
parentdc312c8db05bc9e9cd3f4fd8c039274270a4661b (diff)
downloadSkyblocker-5bd5e7d4881f34c1da9dcbde899f655de3777b96.tar.gz
Skyblocker-5bd5e7d4881f34c1da9dcbde899f655de3777b96.tar.bz2
Skyblocker-5bd5e7d4881f34c1da9dcbde899f655de3777b96.zip
Merge branch 'master' into autorejoin2
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/Screen.java9
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/genericInfo/GenericRiftInfoScreen.java38
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/main/RiftScreen.java28
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java5
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java225
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java3
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java3
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java3
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java37
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java5
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java10
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java8
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java6
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlayerComponent.java11
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java15
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/TableComponent.java9
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/AdvertisementWidget.java27
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/GoodToKnowWidget.java55
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProfileWidget.java19
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProgressWidget.java97
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftServerInfoWidget.java26
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftStatsWidget.java41
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/ShenWidget.java20
23 files changed, 555 insertions, 145 deletions
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
index 43b7f956..6d06c637 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/Screen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/Screen.java
@@ -6,6 +6,7 @@ import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.skyblock.tabhud.TabHud;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.genericInfo.GardenInfoScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.genericInfo.GenericInfoScreen;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.genericInfo.GenericRiftInfoScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.CrimsonIsleScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.DungeonHubScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.DungeonScreen;
@@ -17,12 +18,14 @@ import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.HomeServerScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.HubServerScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.MineServerScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.ParkServerScreen;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main.RiftScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.playerList.DungeonPlayerScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.playerList.GuestPlayerScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.playerList.HomePlayerScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.playerList.PlayerListScreen;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.PlayerLocator;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.Widget;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
@@ -50,6 +53,7 @@ public class Screen {
private static Screen correctGenericScrn(int w, int h, Text footer) {
return switch (PlayerLocator.getPlayerLocation()) {
case GARDEN -> new GardenInfoScreen(w, h, footer); // ok
+ case THE_RIFT -> new GenericRiftInfoScreen(w, h, footer);
case UNKNOWN -> new EmptyScreen(w, h, footer); // ok
default -> new GenericInfoScreen(w, h, footer); // ok
};
@@ -77,6 +81,7 @@ public class Screen {
case DUNGEON -> new DungeonScreen(w, h, footer); // ok
case CRIMSON_ISLE -> new CrimsonIsleScreen(w, h, footer);
case GARDEN -> new GardenScreen(w, h, footer); // ok
+ case THE_RIFT -> new RiftScreen(w, h, footer);
case UNKNOWN -> new EmptyScreen(w, h, footer); // ok
default -> new GenericServerScreen(w, h, footer); // ok
};
@@ -98,9 +103,9 @@ public class Screen {
}
}
- public void render(MatrixStack ms) {
+ public void render(DrawContext context) {
for (Widget w : widgets) {
- w.render(ms);
+ w.render(context);
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/genericInfo/GenericRiftInfoScreen.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/genericInfo/GenericRiftInfoScreen.java
new file mode 100644
index 00000000..9821b5a3
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/genericInfo/GenericRiftInfoScreen.java
@@ -0,0 +1,38 @@
+package me.xmrvizzy.skyblocker.skyblock.tabhud.screens.genericInfo;
+
+import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.Screen;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.rift.RiftProfileWidget;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.rift.RiftStatsWidget;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.rift.ShenWidget;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.CookieWidget;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.rift.AdvertisementWidget;
+import net.minecraft.text.Text;
+
+public class GenericRiftInfoScreen extends Screen {
+
+ public GenericRiftInfoScreen(int w, int h, Text footer) {
+ super(w, h);
+
+ String f = footer.getString();
+
+ RiftProfileWidget profile = new RiftProfileWidget();
+ RiftStatsWidget stats = new RiftStatsWidget();
+ ShenWidget shen = new ShenWidget();
+
+ CookieWidget cookie = new CookieWidget(f);
+ AdvertisementWidget advertisement = new AdvertisementWidget();
+
+ this.stackWidgetsH(stats, advertisement);
+ this.stackWidgetsH(profile, shen, cookie);
+
+ this.offCenterL(stats);
+ this.offCenterL(advertisement);
+
+ this.offCenterR(profile);
+ this.offCenterR(shen);
+ this.offCenterR(cookie);
+
+ this.addWidgets(profile, stats, shen, cookie, advertisement);
+ }
+
+}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/main/RiftScreen.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/main/RiftScreen.java
new file mode 100644
index 00000000..d63bcf62
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screens/main/RiftScreen.java
@@ -0,0 +1,28 @@
+package me.xmrvizzy.skyblocker.skyblock.tabhud.screens.main;
+
+import me.xmrvizzy.skyblocker.skyblock.tabhud.screens.Screen;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.rift.RiftProgressWidget;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.rift.GoodToKnowWidget;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.rift.RiftServerInfoWidget;
+
+
+import net.minecraft.text.Text;
+
+public class RiftScreen extends Screen {
+
+ public RiftScreen(int w, int h, Text footer) {
+ super(w, h);
+
+ RiftProgressWidget rftProg = new RiftProgressWidget();
+ GoodToKnowWidget gtk = new GoodToKnowWidget();
+ RiftServerInfoWidget si = new RiftServerInfoWidget();
+
+ this.stackWidgetsH(si, gtk);
+ this.stackWidgetsH(rftProg);
+ this.offCenterL(si);
+ this.offCenterL(gtk);
+ this.offCenterR(rftProg);
+ this.addWidgets(si, gtk, rftProg);
+ }
+
+}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java
index ca767617..97237769 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java
@@ -52,4 +52,9 @@ public class Ico {
public static final ItemStack SAPLING = new ItemStack(Items.OAK_SAPLING);
public static final ItemStack MILESTONE = new ItemStack(Items.LODESTONE);
public static final ItemStack PICKAXE = new ItemStack(Items.IRON_PICKAXE);
+ public static final ItemStack NETHER_STAR = new ItemStack(Items.NETHER_STAR);
+ public static final ItemStack HEART_OF_THE_SEA = new ItemStack(Items.HEART_OF_THE_SEA);
+ public static final ItemStack EXPERIENCE_BOTTLE = new ItemStack(Items.EXPERIENCE_BOTTLE);
+ public static final ItemStack PINK_DYE = new ItemStack(Items.PINK_DYE);
+ public static final ItemStack ENCHANTED_BOOK = new ItemStack(Items.ENCHANTED_BOOK);
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java
index 60915bc1..ee4319dc 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java
@@ -4,6 +4,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -13,99 +14,147 @@ import me.xmrvizzy.skyblocker.utils.Utils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.PlayerListEntry;
+import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
/**
- * This class may be used to get data from the player list.
- * It doesn't get its data every frame, instead, a scheduler is used to
- * update the data this class is holding periodically.
- * The list is sorted like in the vanilla game.
+ * This class may be used to get data from the player list. It doesn't get its
+ * data every frame, instead, a scheduler is used to update the data this class
+ * is holding periodically. The list is sorted like in the vanilla game.
*/
public class PlayerListMgr {
- public static final Logger LOGGER = LoggerFactory.getLogger("Skyblocker Regex");
-
- private static List<PlayerListEntry> playerList;
-
- public static void updateList() {
-
- if (!Utils.isOnSkyblock()) {
- return;
- }
-
- ClientPlayNetworkHandler cpnwh = MinecraftClient.getInstance().getNetworkHandler();
-
- // check is needed, else game crash on server leave
- if (cpnwh != null) {
- playerList = cpnwh.getPlayerList()
- .stream()
- .sorted(PlayerListHudAccessor.getOrdering())
- .toList();
- }
- }
-
- /**
- * Get the display name at some index of the player list and apply a pattern to
- * it
- *
- * @return the matcher if p fully matches, else null
- */
- public static Matcher regexAt(int idx, Pattern p) {
-
- String str = PlayerListMgr.strAt(idx);
-
- if (str == null) {
- return null;
- }
-
- Matcher m = p.matcher(str);
- if (!m.matches()) {
- LOGGER.error("no match: \"{}\" against \"{}\"", str, p);
- return null;
- } else {
- return m;
- }
- }
-
- /**
- * Get the display name at some index of the player list as string
- *
- * @return the string or null, if the display name is null, empty or whitespace
- * only
- */
- public static String strAt(int idx) {
-
- if (playerList == null) {
- return null;
- }
-
- if (playerList.size() <= idx) {
- return null;
- }
-
- Text txt = playerList.get(idx).getDisplayName();
- if (txt == null) {
- return null;
- }
- String str = txt.getString().trim();
- if (str.length() == 0) {
- return null;
- }
- return str;
- }
-
- /**
- * Get the display name at some index of the player list as Text as seen in the
- * game
- *
- * @return the PlayerListEntry at that index
- */
- public static PlayerListEntry getRaw(int idx) {
- return playerList.get(idx);
- }
-
- public static int getSize() {
- return playerList.size();
- }
+ public static final Logger LOGGER = LoggerFactory.getLogger("Skyblocker Regex");
+
+ private static List<PlayerListEntry> playerList;
+
+ public static void updateList() {
+
+ if (!Utils.isOnSkyblock()) {
+ return;
+ }
+
+ ClientPlayNetworkHandler cpnwh = MinecraftClient.getInstance().getNetworkHandler();
+
+ // check is needed, else game crash on server leave
+ if (cpnwh != null) {
+ playerList = cpnwh.getPlayerList().stream().sorted(PlayerListHudAccessor.getOrdering()).toList();
+ }
+ }
+
+ /**
+ * Get the display name at some index of the player list and apply a pattern to
+ * it
+ *
+ * @return the matcher if p fully matches, else null
+ */
+ public static Matcher regexAt(int idx, Pattern p) {
+
+ String str = PlayerListMgr.strAt(idx);
+
+ if (str == null) {
+ return null;
+ }
+
+ Matcher m = p.matcher(str);
+ if (!m.matches()) {
+ LOGGER.error("no match: \"{}\" against \"{}\"", str, p);
+ return null;
+ } else {
+ return m;
+ }
+ }
+
+ /**
+ * Get the display name at some index of the player list as string
+ *
+ * @return the string or null, if the display name is null, empty or whitespace
+ * only
+ */
+ public static String strAt(int idx) {
+
+ if (playerList == null) {
+ return null;
+ }
+
+ if (playerList.size() <= idx) {
+ return null;
+ }
+
+ Text txt = playerList.get(idx).getDisplayName();
+ if (txt == null) {
+ return null;
+ }
+ String str = txt.getString().trim();
+ if (str.length() == 0) {
+ return null;
+ }
+ return str;
+ }
+
+ /**
+ * Gets the display name at some index of the player list
+ *
+ * @return the text or null, if the display name is null
+ *
+ * @implNote currently designed specifically for crimson isles faction quests
+ * widget and the rift widgets, might not work correctly without
+ * modification for other stuff. you've been warned!
+ */
+ public static Text textAt(int idx) {
+
+ if (playerList == null) {
+ return null;
+ }
+
+ if (playerList.size() <= idx) {
+ return null;
+ }
+
+ Text txt = playerList.get(idx).getDisplayName();
+ if (txt == null) {
+ return null;
+ }
+
+ // Rebuild the text object to remove leading space thats in all faction quest
+ // stuff (also removes trailing space just in case)
+ MutableText newText = Text.empty();
+ int size = txt.getSiblings().size();
+
+ for (int i = 0; i < size; i++) {
+ Text current = txt.getSiblings().get(i);
+ String textToAppend = current.getString();
+
+ // Trim leading & trailing space - this can only be done at the start and end
+ // otherwise it'll produce malformed results
+ if (i == 0)
+ textToAppend = textToAppend.stripLeading();
+ if (i == size - 1)
+ textToAppend = textToAppend.stripTrailing();
+
+ newText.append(Text.literal(textToAppend).setStyle(current.getStyle()));
+ }
+
+ // Avoid returning an empty component - Rift advertisements needed this
+ if (newText.getString().length() == 0) {
+ return null;
+ }
+
+ return newText;
+ }
+
+ /**
+ * Get the display name at some index of the player list as Text as seen in the
+ * game
+ *
+ * @return the PlayerListEntry at that index
+ */
+ public static PlayerListEntry getRaw(int idx) {
+ return playerList.get(idx);
+ }
+
+ public static int getSize() {
+ return playerList.size();
+ }
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java
index d7abdfc2..c2f14d3c 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java
@@ -25,6 +25,7 @@ public class PlayerLocator {
JERRY,
GARDEN,
INSTANCED,
+ THE_RIFT,
UNKNOWN
}
@@ -82,6 +83,8 @@ public class PlayerLocator {
return Location.GARDEN;
case "Instanced":
return Location.INSTANCED;
+ case "The Rift":
+ return Location.THE_RIFT;
default:
return Location.UNKNOWN;
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java
index 5c89964e..43b741ba 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java
@@ -1,6 +1,7 @@
package me.xmrvizzy.skyblocker.skyblock.tabhud.widget;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.util.PlayerListMgr;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent;
import net.minecraft.text.MutableText;
@@ -18,7 +19,7 @@ public class QuestWidget extends Widget {
super(TITLE, Formatting.AQUA.getColorValue());
for (int i = 51; i < 56; i++) {
- Text q = Widget.plainEntryText(i);
+ Text q = PlayerListMgr.textAt(i);
IcoTextComponent itc = new IcoTextComponent(Ico.BOOK, q);
this.addComponent(itc);
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java
index c0379623..3685e0ca 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java
@@ -54,8 +54,9 @@ public class ReputationWidget extends Widget {
this.addComponent(new ProgressComponent());
} else {
float pcnt = Float.parseFloat(prog.group("prog"));
+ Text reputationText = state.group("from").equals("Max") ? Text.literal("Max Reputation") : Text.literal(state.group("from") + " -> " + state.group("to"));
ProgressComponent pc = new ProgressComponent(Ico.LANTERN,
- Text.of(state.group("from") + " -> " + state.group("to")), rep, pcnt,
+ reputationText, rep, pcnt,
Formatting.AQUA.getColorValue());
this.addComponent(pc);
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java
index 6b96c151..33f77933 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/Widget.java
@@ -10,7 +10,7 @@ import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.Component;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
-import net.minecraft.client.gui.DrawableHelper;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.text.MutableText;
@@ -103,14 +103,15 @@ public abstract class Widget {
/**
* Draw this widget with a background
*/
- public final void render(MatrixStack ms) {
- this.render(ms, true);
+ public final void render(DrawContext context) {
+ this.render(context, true);
}
/**
* Draw this widget, possibly with a background
*/
- public final void render(MatrixStack ms, boolean hasBG) {
+ public final void render(DrawContext context, boolean hasBG) {
+ MatrixStack ms = context.getMatrices();
// not sure if this is the way to go, but it fixes Z-layer issues
// like blocks being rendered behind the BG and the hotbar clipping into things
@@ -123,9 +124,9 @@ public abstract class Widget {
// move above other UI elements
ms.translate(0, 0, 200);
if (hasBG) {
- DrawableHelper.fill(ms, x + 1, y, x + w - 1, y + h, COL_BG_BOX);
- DrawableHelper.fill(ms, x, y + 1, x + 1, y + h - 1, COL_BG_BOX);
- DrawableHelper.fill(ms, x + w - 1, y + 1, x + w, y + h - 1, COL_BG_BOX);
+ context.fill(x + 1, y, x + w - 1, y + h, COL_BG_BOX);
+ context.fill(x, y + 1, x + 1, y + h - 1, COL_BG_BOX);
+ context.fill(x + w - 1, y + 1, x + w, y + h - 1, COL_BG_BOX);
}
// move above background (if exists)
ms.translate(0, 0, 100);
@@ -133,19 +134,19 @@ public abstract class Widget {
int strHeightHalf = Widget.txtRend.fontHeight / 2;
int strAreaWidth = Widget.txtRend.getWidth(title) + 4;
- txtRend.draw(ms, title, x + 8, y + 2, this.color);
+ context.drawText(txtRend, title, x + 8, y + 2, this.color, false);
- this.drawHLine(ms, x + 2, y + 1 + strHeightHalf, 4);
- this.drawHLine(ms, x + 2 + strAreaWidth + 4, y + 1 + strHeightHalf, w - 4 - 4 - strAreaWidth);
- this.drawHLine(ms, x + 2, y + h - 2, w - 4);
+ this.drawHLine(context, x + 2, y + 1 + strHeightHalf, 4);
+ this.drawHLine(context, x + 2 + strAreaWidth + 4, y + 1 + strHeightHalf, w - 4 - 4 - strAreaWidth);
+ this.drawHLine(context, x + 2, y + h - 2, w - 4);
- this.drawVLine(ms, x + 1, y + 2 + strHeightHalf, h - 4 - strHeightHalf);
- this.drawVLine(ms, x + w - 2, y + 2 + strHeightHalf, h - 4 - strHeightHalf);
+ this.drawVLine(context, x + 1, y + 2 + strHeightHalf, h - 4 - strHeightHalf);
+ this.drawVLine(context, x + w - 2, y + 2 + strHeightHalf, h - 4 - strHeightHalf);
int yOffs = y + BORDER_SZE_N;
for (Component c : components) {
- c.render(ms, x + BORDER_SZE_W, yOffs);
+ c.render(context, x + BORDER_SZE_W, yOffs);
yOffs += c.getHeight() + Component.PAD_L;
}
// pop manipulations above
@@ -153,12 +154,12 @@ public abstract class Widget {
RenderSystem.disableDepthTest();
}
- private void drawHLine(MatrixStack ms, int xpos, int ypos, int width) {
- DrawableHelper.fill(ms, xpos, ypos, xpos + width, ypos + 1, this.color);
+ private void drawHLine(DrawContext context, int xpos, int ypos, int width) {
+ context.fill(xpos, ypos, xpos + width, ypos + 1, this.color);
}
- private void drawVLine(MatrixStack ms, int xpos, int ypos, int height) {
- DrawableHelper.fill(ms, xpos, ypos, xpos + 1, ypos + height, this.color);
+ private void drawVLine(DrawContext context, int xpos, int ypos, int height) {
+ context.fill(xpos, ypos, xpos + 1, ypos + height, this.color);
}
/**
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java
index 671b1f41..850cb3d2 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/Component.java
@@ -2,8 +2,8 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.item.ItemRenderer;
-import net.minecraft.client.util.math.MatrixStack;
/**
* Abstract base class for a component that may be added to a Widget.
@@ -15,12 +15,11 @@ public abstract class Component {
public static final int PAD_L = 4;
static TextRenderer txtRend = MinecraftClient.getInstance().textRenderer;
- static ItemRenderer itmRend = MinecraftClient.getInstance().getItemRenderer();
// these should always be the content dimensions without any padding.
int width, height;
- public abstract void render(MatrixStack ms, int x, int y);
+ public abstract void render(DrawContext context, int x, int y);
public int getWidth() {
return this.width;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java
index f845eba5..afd05c26 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoFatTextComponent.java
@@ -1,7 +1,7 @@
package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -36,10 +36,10 @@ public class IcoFatTextComponent extends Component {
}
@Override
- public void render(MatrixStack ms, int x, int y) {
- itmRend.renderGuiItemIcon(ms, ico, x, y + ICO_OFFS);
- txtRend.draw(ms, line1, x + ICO_DIM + PAD_L, y, 0xffffffff);
- txtRend.draw(ms, line2, x + ICO_DIM + PAD_L, y + txtRend.fontHeight + PAD_S, 0xffffffff);
+ public void render(DrawContext context, int x, int y) {
+ context.drawItem(ico, x, y + ICO_OFFS);
+ context.drawText(txtRend, line1, x + ICO_DIM + PAD_L, y, 0xffffffff, false);
+ context.drawText(txtRend, line2, x + ICO_DIM + PAD_L, y + txtRend.fontHeight + PAD_S, 0xffffffff, false);
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java
index 7a495a13..7ab92dd5 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/IcoTextComponent.java
@@ -1,7 +1,7 @@
package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -32,9 +32,9 @@ public class IcoTextComponent extends Component {
}
@Override
- public void render(MatrixStack ms, int x, int y) {
- itmRend.renderGuiItemIcon(ms, ico, x, y);
- txtRend.draw(ms, text, x + ICO_DIM + PAD_L, y + 5, 0xffffffff);
+ public void render(DrawContext context, int x, int y) {
+ context.drawItem(ico, x, y);
+ context.drawText(txtRend, text, x + ICO_DIM + PAD_L, y + 5, 0xffffffff, false);
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java
index 265d11f1..34e0268b 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlainTextComponent.java
@@ -1,6 +1,6 @@
package me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component;
-import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -23,8 +23,8 @@ public class PlainTextComponent extends Component {
}
@Override
- public void render(MatrixStack ms, int x, int y) {
- txtRend.draw(ms, text, x + PAD_S, y, 0xffffffff);
+ public void render(DrawContext context, int x, int y) {
+ context.drawText(txtRend, text, x + PAD_S, y, 0xffffffff, false);
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlayerComponent.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/component/PlayerComponent.java
index 18859080..fd66ec73 100644
--- a/src/main/java/me/xmrvizzy/skybloc