aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin <92656833+kevinthegreat1@users.noreply.github.com>2023-09-08 23:28:57 -0400
committerGitHub <noreply@github.com>2023-09-08 23:28:57 -0400
commit284442a7ea65a7a6ae15ad394818c7e9187c2aaf (patch)
treefb2b0594a7e0b397b8f5afccdfa8ae7409edb9f8
parent9c7bf54123f366ad90bfafe81e973b731fd6b5b3 (diff)
parent7df2a590d4b0079f65ef639315d04f63c2f754a7 (diff)
downloadSkyblocker-284442a7ea65a7a6ae15ad394818c7e9187c2aaf.tar.gz
Skyblocker-284442a7ea65a7a6ae15ad394818c7e9187c2aaf.tar.bz2
Skyblocker-284442a7ea65a7a6ae15ad394818c7e9187c2aaf.zip
Merge pull request #276 from msg-programs/readme-fixes
Readme fixes
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java6
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/AdvertisementWidget.java8
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/GoodToKnowWidget.java40
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProfileWidget.java4
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProgressWidget.java148
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftServerInfoWidget.java2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftStatsWidget.java10
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/ShenWidget.java2
-rw-r--r--src/main/resources/assets/skyblocker/tabhud/readme.md9
9 files changed, 138 insertions, 91 deletions
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 7b35bcce..446b7d81 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
@@ -43,7 +43,11 @@ public class PlayerListMgr {
}
public static void updateFooter(Text f) {
- footer = f.getString();
+ if (f == null) {
+ footer = null;
+ } else {
+ footer = f.getString();
+ }
}
public static String getFooter() {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/AdvertisementWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/AdvertisementWidget.java
index 88e3a5cd..8d50fc2f 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/AdvertisementWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/AdvertisementWidget.java
@@ -18,12 +18,18 @@ public class AdvertisementWidget extends Widget {
@Override
public void updateContent() {
+ boolean added = false;
for (int i = 73; i < 80; i++) {
Text text = PlayerListMgr.textAt(i);
- if (text != null)
+ if (text != null) {
this.addComponent(new PlainTextComponent(text));
+ added = true;
+ }
}
+ if (!added) {
+ this.addComponent(new PlainTextComponent(Text.literal("No Advertisements").formatted(Formatting.GRAY)));
+ }
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/GoodToKnowWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/GoodToKnowWidget.java
index e3b462a9..d1a3df1f 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/GoodToKnowWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/GoodToKnowWidget.java
@@ -22,26 +22,38 @@ public class GoodToKnowWidget extends Widget {
// that
// In beginning it only shows montezuma, then timecharms and enigma souls are
// added
- Text pos49 = PlayerListMgr.textAt(49); // Can be times visited rift
- Text pos51 = PlayerListMgr.textAt(51); // Can be lifetime motes or visited rift
- Text pos53 = PlayerListMgr.textAt(53); // Can be lifetime motes
+
+ int headerPos = 0;
+ // this seems suboptimal, but I'm not sure if there's a way to do it better.
+ // search for the GTK header and offset the rest accordingly.
+ for (int i = 45; i <= 49; i++) {
+ String str = PlayerListMgr.strAt(i);
+ if (str != null && str.startsWith("Good to")) {
+ headerPos = i;
+ break;
+ }
+ }
+
+ Text posA = PlayerListMgr.textAt(headerPos + 2); // Can be times visited rift
+ Text posB = PlayerListMgr.textAt(headerPos + 4); // Can be lifetime motes or visited rift
+ Text posC = PlayerListMgr.textAt(headerPos + 6); // Can be lifetime motes
int visitedRiftPos = 0;
int lifetimeMotesPos = 0;
// Check each position to see what is or isn't there so we don't try adding
// invalid components
- if (pos49.getString().contains("times"))
- visitedRiftPos = 49;
- if (pos51.getString().contains("Motes"))
- lifetimeMotesPos = 51;
- if (pos51.getString().contains("times"))
- visitedRiftPos = 51;
- if (pos53.getString().contains("Motes"))
- lifetimeMotesPos = 53;
-
- Text timesVisitedRift = (visitedRiftPos == 51) ? pos51 : (visitedRiftPos == 49) ? pos49 : null;
- Text lifetimeMotesEarned = (lifetimeMotesPos == 53) ? pos53 : (lifetimeMotesPos == 51) ? pos51 : null;
+ if (posA != null && posA.getString().contains("times"))
+ visitedRiftPos = headerPos + 2;
+ if (posB != null && posB.getString().contains("Motes"))
+ lifetimeMotesPos = headerPos + 4;
+ if (posB != null && posB.getString().contains("times"))
+ visitedRiftPos = headerPos + 4;
+ if (posC != null && posC.getString().contains("Motes"))
+ lifetimeMotesPos = headerPos + 6;
+
+ Text timesVisitedRift = (visitedRiftPos == headerPos + 4) ? posB : (visitedRiftPos == headerPos + 2) ? posA : Text.literal("No Data").formatted(Formatting.GRAY);
+ Text lifetimeMotesEarned = (lifetimeMotesPos == headerPos + 6) ? posC : (lifetimeMotesPos == headerPos + 4) ? posB : Text.literal("No Data").formatted(Formatting.GRAY);
if (visitedRiftPos != 0) {
this.addComponent(new IcoTextComponent(Ico.EXPERIENCE_BOTTLE,
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProfileWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProfileWidget.java
index 0b6ff5bf..785850d5 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProfileWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProfileWidget.java
@@ -7,9 +7,9 @@ import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class RiftProfileWidget extends Widget {
-
+
private static final MutableText TITLE = Text.literal("Profile").formatted(Formatting.DARK_AQUA, Formatting.BOLD);
-
+
public RiftProfileWidget() {
super(TITLE, Formatting.DARK_AQUA.getColorValue());
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProgressWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProgressWidget.java
index 375a41b9..ad43c9f4 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProgressWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftProgressWidget.java
@@ -6,6 +6,7 @@ import java.util.regex.Pattern;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.PlayerListMgr;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.Widget;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.ProgressComponent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
@@ -14,86 +15,109 @@ import net.minecraft.util.math.MathHelper;
public class RiftProgressWidget extends Widget {
- private static final MutableText TITLE = Text.literal("Rift Progress").formatted(Formatting.BLUE, Formatting.BOLD);
+ private static final MutableText TITLE = Text.literal("Rift Progress").formatted(Formatting.BLUE, Formatting.BOLD);
- private static final Pattern TIMECHARMS_PATTERN = Pattern.compile("Timecharms: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
- private static final Pattern ENIGMA_SOULS_PATTERN = Pattern.compile("Enigma Souls: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
- private static final Pattern MONTEZUMA_PATTERN = Pattern.compile("Montezuma: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
+ private static final Pattern TIMECHARMS_PATTERN = Pattern.compile("Timecharms: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
+ private static final Pattern ENIGMA_SOULS_PATTERN = Pattern.compile("Enigma Souls: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
+ private static final Pattern MONTEZUMA_PATTERN = Pattern.compile("Montezuma: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
- public RiftProgressWidget() {
- super(TITLE, Formatting.BLUE.getColorValue());
+ public RiftProgressWidget() {
+ super(TITLE, Formatting.BLUE.getColorValue());
}
@Override
public void updateContent() {
- // After you progress further the tab adds more info so we need to be careful of
- // that
- // In beginning it only shows montezuma, then timecharms and enigma souls are
- // added
- String pos45 = PlayerListMgr.strAt(45); // Can be Montezuma or Timecharms
- String pos46 = PlayerListMgr.strAt(46); // Can be Enigma Souls or Empty
- String pos47 = PlayerListMgr.strAt(47); // Can be Montezuma or "Good to know" heading
+ // After you progress further, the tab adds more info so we need to be careful
+ // of that.
+ // In beginning it only shows montezuma, then timecharms and enigma souls are
+ // added.
+
+ String pos44 = PlayerListMgr.strAt(44);
+
+ // LHS short-circuits, so the RHS won't be evaluated on pos44 == null
+ if (pos44 == null || !pos44.contains("Rift Progress")) {
+ this.addComponent(new PlainTextComponent(Text.literal("No Progress").formatted(Formatting.GRAY)));
+ return;
+ }
+
+ // let's try to be clever by assuming what progress item may appear where and
+ // when to skip testing every slot for every thing.
+
+ // always non-null, as this holds the topmost item.
+ // if there is none, there shouldn't be a header.
+ String pos45 = PlayerListMgr.strAt(45);
+
+ // Can be Montezuma, Enigma Souls or Timecharms.
+ // assume timecharms can only appear here and that they're the last thing to
+ // appear, so if this exists, we know the rest.
+ if (pos45.contains("Timecharms")) {
+ addTimecharmsComponent(45);
+ addEnigmaSoulsComponent(46);
+ addMontezumaComponent(47);
+ return;
+ }
+
+ // timecharms didn't appear at the top, so there's two or one entries.
+ // assume that if there's two, souls is always top.
+ String pos46 = PlayerListMgr.strAt(46);
+
+ if (pos45.contains("Enigma Souls")) {
+ addEnigmaSoulsComponent(45);
+ if (pos46 != null) {
+ // souls might appear alone.
+ // if there's a second entry, it has to be montezuma
+ addMontezumaComponent(46);
+ }
+ } else {
+ // first entry isn't souls, so it's just montezuma and nothing else.
+ addMontezumaComponent(45);
+ }
- boolean hasTimecharms = false;
- boolean hasEnigmaSouls = false;
- int montezumaPos;
-
- // Check each position to see what is or isn't there so we don't try adding
- // invalid components
- if (pos45.contains("Timecharms"))
- hasTimecharms = true;
- if (pos46.contains("Enigma Souls"))
- hasEnigmaSouls = true;
-
- // Small ternary to account for positions, defaults to -1 if it for some reason
- // does not exist (which shouldn't be the case!)
- montezumaPos = (pos47.contains("Montezuma")) ? 47 : (pos45.contains("Montezuma")) ? 45 : -1;
-
- if (hasTimecharms) {
- Matcher m = PlayerListMgr.regexAt(45, TIMECHARMS_PATTERN);
+ }
- int current = Integer.parseInt(m.group("current"));
- int total = Integer.parseInt(m.group("total"));
- float pcnt = ((float) current / (float) total) * 100f;
- Text progressText = Text.literal(current + "/" + total);
+ private static int pcntToCol(float pcnt) {
+ return MathHelper.hsvToRgb(pcnt / 300f, 0.9f, 0.9f);
+ }
- ProgressComponent pc = new ProgressComponent(Ico.NETHER_STAR, Text.literal("Timecharms"), progressText,
- pcnt, pcntToCol(pcnt));
+ private void addTimecharmsComponent(int pos) {
+ Matcher m = PlayerListMgr.regexAt(pos, TIMECHARMS_PATTERN);
- this.addComponent(pc);
- }
+ int current = Integer.parseInt(m.group("current"));
+ int total = Integer.parseInt(m.group("total"));
+ float pcnt = ((float) current / (float) total) * 100f;
+ Text progressText = Text.literal(current + "/" + total);
- if (hasEnigmaSouls) {
- Matcher m = PlayerListMgr.regexAt(46, ENIGMA_SOULS_PATTERN);
+ ProgressComponent pc = new ProgressComponent(Ico.NETHER_STAR, Text.literal("Timecharms"), progressText,
+ pcnt, pcntToCol(pcnt));
- int current = Integer.parseInt(m.group("current"));
- int total = Integer.parseInt(m.group("total"));
- float pcnt = ((float) current / (float) total) * 100f;
- Text progressText = Text.literal(current + "/" + total);
+ this.addComponent(pc);
+ }
- ProgressComponent pc = new ProgressComponent(Ico.HEART_OF_THE_SEA, Text.literal("Enigma Souls"),
- progressText, pcnt, pcntToCol(pcnt));
+ private void addEnigmaSoulsComponent(int pos) {
+ Matcher m = PlayerListMgr.regexAt(pos, ENIGMA_SOULS_PATTERN);
- this.addComponent(pc);
- }
+ int current = Integer.parseInt(m.group("current"));
+ int total = Integer.parseInt(m.group("total"));
+ float pcnt = ((float) current / (float) total) * 100f;
+ Text progressText = Text.literal(current + "/" + total);
- if (montezumaPos != -1) {
- Matcher m = PlayerListMgr.regexAt(montezumaPos, MONTEZUMA_PATTERN);
+ ProgressComponent pc = new ProgressComponent(Ico.HEART_OF_THE_SEA, Text.literal("Enigma Souls"),
+ progressText, pcnt, pcntToCol(pcnt));
- int current = Integer.parseInt(m.group("current"));
- int total = Integer.parseInt(m.group("total"));
- float pcnt = ((float) current / (float) total) * 100f;
- Text progressText = Text.literal(current + "/" + total);
+ this.addComponent(pc);
+ }
- ProgressComponent pc = new ProgressComponent(Ico.BONE, Text.literal("Montezuma"), progressText, pcnt,
- pcntToCol(pcnt));
+ private void addMontezumaComponent(int pos) {
+ Matcher m = PlayerListMgr.regexAt(pos, MONTEZUMA_PATTERN);
- this.addComponent(pc);
- }
+ int current = Integer.parseInt(m.group("current"));
+ int total = Integer.parseInt(m.group("total"));
+ float pcnt = ((float) current / (float) total) * 100f;
+ Text progressText = Text.literal(current + "/" + total);
- }
+ ProgressComponent pc = new ProgressComponent(Ico.BONE, Text.literal("Montezuma"), progressText, pcnt,
+ pcntToCol(pcnt));
- private static int pcntToCol(float pcnt) {
- return MathHelper.hsvToRgb(pcnt / 300f, 0.9f, 0.9f);
- }
+ this.addComponent(pc);
+ }
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftServerInfoWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftServerInfoWidget.java
index cab38a86..1ec3771e 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftServerInfoWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftServerInfoWidget.java
@@ -11,7 +11,7 @@ import net.minecraft.util.Formatting;
*
*/
public class RiftServerInfoWidget extends Widget {
-
+
private static final MutableText TITLE = Text.literal("Server Info").formatted(Formatting.LIGHT_PURPLE, Formatting.BOLD);
public RiftServerInfoWidget() {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftStatsWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftStatsWidget.java
index 8fab3dd4..95a587a9 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftStatsWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/RiftStatsWidget.java
@@ -21,22 +21,22 @@ public class RiftStatsWidget extends Widget {
public void updateContent() {
Text riftDamage = Widget.simpleEntryText(64, "RDG", Formatting.DARK_PURPLE);
IcoTextComponent rdg = new IcoTextComponent(Ico.DIASWORD, riftDamage);
-
+
Text speed = Widget.simpleEntryText(65, "SPD", Formatting.WHITE);
IcoTextComponent spd = new IcoTextComponent(Ico.SUGAR, speed);
-
+
Text intelligence = Widget.simpleEntryText(66, "INT", Formatting.AQUA);
IcoTextComponent intel = new IcoTextComponent(Ico.ENCHANTED_BOOK, intelligence);
-
+
Text manaRegen = Widget.simpleEntryText(67, "MRG", Formatting.AQUA);
IcoTextComponent mrg = new IcoTextComponent(Ico.DIAMOND, manaRegen);
-
+
TableComponent tc = new TableComponent(2, 2, Formatting.AQUA.getColorValue());
tc.addToCell(0, 0, rdg);
tc.addToCell(0, 1, spd);
tc.addToCell(1, 0, intel);
tc.addToCell(1, 1, mrg);
-
+
this.addComponent(tc);
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/ShenWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/ShenWidget.java
index a1345c49..1f432406 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/ShenWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/rift/ShenWidget.java
@@ -8,7 +8,7 @@ import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class ShenWidget extends Widget {
-
+
private static final MutableText TITLE = Text.literal("Shen's Countdown").formatted(Formatting.DARK_AQUA, Formatting.BOLD);
public ShenWidget() {
diff --git a/src/main/resources/assets/skyblocker/tabhud/readme.md b/src/main/resources/assets/skyblocker/tabhud/readme.md
index 9e637500..7a52ddc0 100644
--- a/src/main/resources/assets/skyblocker/tabhud/readme.md
+++ b/src/main/resources/assets/skyblocker/tabhud/readme.md
@@ -68,6 +68,7 @@ Grouped by themes (roughly)
- SkillsWidget: The player's skill levels and stats
- TrapperWidget: Trapper pelts on the farming island.
- UpgradeWidget: Currently running upgrades
+- CameraPositionWidget: Shows orientation (pitch/yaw) of camera
#### Garden
- ComposterWidget: The composter in the garden.
@@ -96,12 +97,12 @@ Grouped by themes (roughly)
#### Rift
- AdvertisementWidget: Shows rift ads.
-- GoodToKnowWidget:
-- RiftProfileWidget:
-- RiftProgressWidget:
+- GoodToKnowWidget: Lifetime Motes earned and/or times you visited the rift.
+- RiftProfileWidget: Info about your player profile while in the rift.
+- RiftProgressWidget: Info about Montezuma, Timecharms and Enigma Souls.
- RiftServerInfoWidget: Server widget specialized for the rift.
- RiftStatsWidget: Server widget specialized for the rift.
-- ShenWidget:
+- ShenWidget: Shows Shen's countdown
#### Player lists
- PlayerListWidget: Generic list of players in the area.