From 64e1de1f4f857d4c126b7610b008120a61f118d2 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Tue, 4 Jul 2023 20:19:40 -0400
Subject: [PATCH 01/17] New Slayer Stuff
Implement TitleContainer for stacking titles.
Implement Mania Indicator to show the player when they are standing on green terracotta during mania.
---
.../me/xmrvizzy/skyblocker/SkyblockerMod.java | 2 +
.../skyblocker/config/SkyblockerConfig.java | 4 +
.../skyblock/rift/HealingMelonIndicator.java | 26 ++++--
.../skyblock/rift/ManiaIndicator.java | 46 +++++++++++
.../skyblock/rift/StakeIndicator.java | 25 ++++--
.../skyblocker/skyblock/rift/TheRift.java | 1 +
.../skyblock/rift/TwinClawsIndicator.java | 36 +++++---
.../skyblocker/utils/RenderHelper.java | 7 ++
.../skyblocker/utils/title/Title.java | 13 +++
.../utils/title/TitleContainer.java | 82 +++++++++++++++++++
.../assets/skyblocker/lang/en_us.json | 4 +
11 files changed, 224 insertions(+), 22 deletions(-)
create mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
create mode 100644 src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
create mode 100644 src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
diff --git a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
index a629f8519f..4688d90ff6 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
@@ -20,6 +20,7 @@
import me.xmrvizzy.skyblocker.skyblock.tabhud.TabHud;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.PlayerListMgr;
import me.xmrvizzy.skyblocker.utils.*;
+import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.loader.api.FabricLoader;
@@ -84,6 +85,7 @@ public void onInitializeClient() {
TabHud.init();
DungeonMap.init();
TheRift.init();
+ TitleContainer.init();
containerSolverManager.init();
scheduler.scheduleCyclic(Utils::update, 20);
scheduler.scheduleCyclic(DiscordRPCManager::updateDataAndPresence, 100);
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
index 26e59b40b0..ab4149fcf7 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
@@ -399,6 +399,10 @@ public static class VampireSlayer {
@ConfigEntry.BoundedDiscrete(min = 1, max = 10)
@ConfigEntry.Gui.Tooltip()
public int steakStakeUpdateFrequency = 5;
+ public boolean enableManiaIndicator = true;
+ @ConfigEntry.BoundedDiscrete(min = 1, max = 10)
+ @ConfigEntry.Gui.Tooltip()
+ public int maniaUpdateFrequency = 5;
}
public static class Messages {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
index f98c17e723..050c300f32 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
@@ -3,19 +3,33 @@
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.utils.RenderHelper;
import me.xmrvizzy.skyblocker.utils.Utils;
+import me.xmrvizzy.skyblocker.utils.title.Title;
+import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class HealingMelonIndicator {
- private static long lastDisplayTime = 0;
-
+ private static Title title = null;
public static void updateHealth(MinecraftClient client) {
- if (!SkyblockerConfig.get().slayer.vampireSlayer.enableHealingMelonIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château")) return;
+ if(title == null)
+ new Title(I18n.translate("skyblocker.rift.healNow"), Formatting.DARK_RED.getColorValue());
+
+ if (!SkyblockerConfig.get().slayer.vampireSlayer.enableHealingMelonIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château")) {
+ title.active = false;
+ return;
+ }
+ title.active = true;
ClientPlayerEntity player = client.player;
- if (player != null && player.getHealth() <= SkyblockerConfig.get().slayer.vampireSlayer.healingMelonHealthThreshold * 2F && System.currentTimeMillis() - lastDisplayTime > 2500) {
- lastDisplayTime = System.currentTimeMillis();
- RenderHelper.displayTitleAndPlaySound(15, 5, "skyblocker.rift.healNow", Formatting.DARK_RED);
+ if (player != null && player.getHealth() <= SkyblockerConfig.get().slayer.vampireSlayer.healingMelonHealthThreshold * 2F) {
+ title.active = true;
+ if(!TitleContainer.titles.contains(title))
+ RenderHelper.displayInTitleContainerAndPlaySound(title);
+ }
+ else {
+ title.active = false;
}
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
new file mode 100644
index 0000000000..7d5a1cb417
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
@@ -0,0 +1,46 @@
+package me.xmrvizzy.skyblocker.skyblock.rift;
+
+import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import me.xmrvizzy.skyblocker.utils.RenderHelper;
+import me.xmrvizzy.skyblocker.utils.SlayerUtils;
+import me.xmrvizzy.skyblocker.utils.Utils;
+import me.xmrvizzy.skyblocker.utils.title.Title;
+import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
+import net.minecraft.block.Blocks;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.entity.Entity;
+import net.minecraft.util.Formatting;
+
+public class ManiaIndicator {
+ private static Title title = null;
+ public static void updateMania() {
+ if(title == null)
+ title = new Title("b", Formatting.RED.getColorValue());
+
+ if (!SkyblockerConfig.get().slayer.vampireSlayer.enableManiaIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !(Utils.getLocation().contains("Stillgore Château")) || !SlayerUtils.isInSlayer()) {
+ title.active = false;
+ return;
+ }
+
+ Entity slayerEntity = SlayerUtils.getSlayerEntity();
+ if (slayerEntity == null) return;
+
+ boolean anyMania = false;
+ for (Entity entity : SlayerUtils.getEntityArmorStands(slayerEntity)) {
+ if (entity.getDisplayName().toString().contains("MANIA")) {
+ anyMania = true;
+ title.active = true;
+ var pos = MinecraftClient.getInstance().player.getBlockPos().down();
+ var isGreen = MinecraftClient.getInstance().world.getBlockState(pos).getBlock() == Blocks.GREEN_TERRACOTTA;
+ title.color = isGreen ? Formatting.GREEN.getColorValue() : Formatting.RED.getColorValue();
+ if(!TitleContainer.titles.contains(title)) {
+ title.text = I18n.translate("skyblocker.rift.mania");
+ RenderHelper.displayInTitleContainerAndPlaySound(title);
+ }
+ }
+ }
+ if(!anyMania)
+ title.active = false;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
index d1132be8f7..01b6b73852 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
@@ -4,18 +4,31 @@
import me.xmrvizzy.skyblocker.utils.RenderHelper;
import me.xmrvizzy.skyblocker.utils.SlayerUtils;
import me.xmrvizzy.skyblocker.utils.Utils;
+import me.xmrvizzy.skyblocker.utils.title.Title;
+import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
+import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.Entity;
+import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class StakeIndicator {
- private static long lastDisplayTime = 0;
-
+ private static Title title = null;
public static void updateStake() {
- if (!SkyblockerConfig.get().slayer.vampireSlayer.enableSteakStakeIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château") || !SlayerUtils.isInSlayer()) return;
+ if (title == null)
+ title = new Title("b", Formatting.RED.getColorValue());
+
+ if (!SkyblockerConfig.get().slayer.vampireSlayer.enableSteakStakeIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château") || !SlayerUtils.isInSlayer()) {
+ title.active = false;
+ return;
+ }
Entity slayerEntity = SlayerUtils.getSlayerEntity();
- if (slayerEntity != null && slayerEntity.getDisplayName().toString().contains("҉") && System.currentTimeMillis() - lastDisplayTime > 2500) {
- lastDisplayTime = System.currentTimeMillis();
- RenderHelper.displayTitleAndPlaySound(25, 5, "skyblocker.rift.stakeNow", Formatting.RED);
+ if (slayerEntity != null && slayerEntity.getDisplayName().toString().contains("҉")) {
+ title.active = true;
+ title.text = I18n.translate("skyblocker.rift.stakeNow");
+ if(!TitleContainer.titles.contains(title))
+ RenderHelper.displayInTitleContainerAndPlaySound(title);
}
+ else
+ title.active = false;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TheRift.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TheRift.java
index 91b727e24e..5ca89dcf77 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TheRift.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TheRift.java
@@ -15,6 +15,7 @@ public static void init() {
WorldRenderEvents.AFTER_TRANSLUCENT.register(EffigyWaypoints::render);
SkyblockerMod.getInstance().scheduler.scheduleCyclic(EffigyWaypoints::updateEffigies, SkyblockerConfig.get().slayer.vampireSlayer.effigyUpdateFrequency);
SkyblockerMod.getInstance().scheduler.scheduleCyclic(TwinClawsIndicator::updateIce, SkyblockerConfig.get().slayer.vampireSlayer.holyIceUpdateFrequency);
+ SkyblockerMod.getInstance().scheduler.scheduleCyclic(ManiaIndicator::updateMania, SkyblockerConfig.get().slayer.vampireSlayer.maniaUpdateFrequency);
SkyblockerMod.getInstance().scheduler.scheduleCyclic(StakeIndicator::updateStake, SkyblockerConfig.get().slayer.vampireSlayer.steakStakeUpdateFrequency);
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
index 7e1d6605d3..a062f7b7e4 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
@@ -5,28 +5,44 @@
import me.xmrvizzy.skyblocker.utils.RenderHelper;
import me.xmrvizzy.skyblocker.utils.SlayerUtils;
import me.xmrvizzy.skyblocker.utils.Utils;
+import me.xmrvizzy.skyblocker.utils.title.Title;
+import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
+import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.Entity;
+import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class TwinClawsIndicator {
- private static long lastDisplayTime = 0;
-
+ private static Title title = null;
+ public static boolean scheduling = false;
public static void updateIce() {
- if (!SkyblockerConfig.get().slayer.vampireSlayer.enableHolyIceIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !(Utils.getLocation().contains("Stillgore Château")) || !SlayerUtils.isInSlayer()) return;
+ if(title == null)
+ title = new Title("b", Formatting.AQUA.getColorValue());
+
+ if (!SkyblockerConfig.get().slayer.vampireSlayer.enableHolyIceIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !(Utils.getLocation().contains("Stillgore Château")) || !SlayerUtils.isInSlayer()) {
+ title.active = false;
+ return;
+ }
Entity slayerEntity = SlayerUtils.getSlayerEntity();
if (slayerEntity == null) return;
+ boolean anyClaws = false;
for (Entity entity : SlayerUtils.getEntityArmorStands(slayerEntity)) {
if (entity.getDisplayName().toString().contains("TWINCLAWS")) {
- SkyblockerMod.getInstance().scheduler.schedule(() -> {
- if (System.currentTimeMillis() - lastDisplayTime > 2500) {
- lastDisplayTime = System.currentTimeMillis();
- RenderHelper.displayTitleAndPlaySound(40, 5, "skyblocker.rift.iceNow", Formatting.AQUA);
- }
- }, SkyblockerConfig.get().slayer.vampireSlayer.holyIceIndicatorTickDelay);
+ anyClaws = true;
+ title.active = true;
+ if(!TitleContainer.titles.contains(title) && !scheduling) {
+ scheduling = true;
+ SkyblockerMod.getInstance().scheduler.schedule(() -> {
+ title.text = I18n.translate("skyblocker.rift.iceNow");
+ RenderHelper.displayInTitleContainerAndPlaySound(title);
+ scheduling = false;
+ }, SkyblockerConfig.get().slayer.vampireSlayer.holyIceIndicatorTickDelay);
+ }
}
}
-
+ if(!anyClaws)
+ title.active = false;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
index a7e1fc995b..e75538f6b4 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
@@ -2,6 +2,8 @@
import me.x150.renderer.render.Renderer3d;
import me.xmrvizzy.skyblocker.mixin.accessor.BeaconBlockEntityRendererInvoker;
+import me.xmrvizzy.skyblocker.utils.title.Title;
+import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer;
@@ -51,6 +53,11 @@ public static void displayTitleAndPlaySound(int stayTicks, int fadeOutTicks, Str
playNotificationSound();
}
+ public static void displayInTitleContainerAndPlaySound(Title title) {
+ TitleContainer.addTitle(title);
+ playNotificationSound();
+ }
+
private static void playNotificationSound() {
if (MinecraftClient.getInstance().player != null) {
MinecraftClient.getInstance().player.playSound(SoundEvent.of(new Identifier("entity.experience_orb.pickup")), 100f, 0.1f);
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
new file mode 100644
index 0000000000..44a636d781
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
@@ -0,0 +1,13 @@
+package me.xmrvizzy.skyblocker.utils.title;
+
+public class Title {
+ public String text = "";
+ public boolean active = true;
+ public int color;
+ public float lastX = 0;
+
+ public Title(String text, int color) {
+ this.text = text;
+ this.color = color;
+ }
+}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
new file mode 100644
index 0000000000..c8747596f1
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -0,0 +1,82 @@
+package me.xmrvizzy.skyblocker.utils.title;
+
+import me.xmrvizzy.skyblocker.SkyblockerMod;
+import me.xmrvizzy.skyblocker.skyblock.FairySouls;
+import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
+import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.gui.DrawContext;
+import net.minecraft.entity.decoration.DisplayEntity;
+import net.minecraft.text.Text;
+import net.minecraft.util.Formatting;
+import net.minecraft.util.math.MathHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
+
+public class TitleContainer {
+ public static List
titles = new ArrayList<>();
+ private static final Logger LOGGER = LoggerFactory.getLogger("skyblocker");
+ public static void init() {
+ HudRenderCallback.EVENT.register(TitleContainer::draw);
+ ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE)
+ .then(literal("title")
+ .then(literal("ice").executes(context -> {
+ titles.add(new Title(Text.translatable("skyblocker.rift.iceNow").getString(), Formatting.AQUA.getColorValue()));
+ return 1;
+ }))
+ .then(literal("stake").executes(context -> {
+ titles.add(new Title("Stake", Formatting.RED.getColorValue()));
+ return 1;
+ }))
+ .then(literal("heal").executes(context -> {
+ titles.add(new Title("Heal", Formatting.DARK_RED.getColorValue()));
+ return 1;
+ }))
+ )));
+ }
+ public static void addTitle(Title title)
+ {
+ title.active = true;
+ title.lastX = 0;
+ titles.add(title);
+ }
+ public static void draw(DrawContext context, float tickDelta) {
+ var client = MinecraftClient.getInstance();
+ TextRenderer textRenderer = client.textRenderer;
+
+ List toRemove = new ArrayList<>();
+
+ float x;
+ float width = 0;
+ context.getMatrices().push();
+ context.getMatrices().scale(3.0F, 3.0F, 3.0F);
+ for (Title title : titles) {
+ width += textRenderer.getWidth(title.text) * 3F + 10;
+ }
+ context.getMatrices().pop();
+
+ x = (client.getWindow().getScaledWidth() / 2) - width / 2;
+
+ for (Title title : titles) {
+ context.getMatrices().push();
+ context.getMatrices().translate(title.lastX, client.getWindow().getScaledHeight() * 0.6F, 0);
+ context.getMatrices().scale(3.0F, 3.0F, 3.0F);
+
+ title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, x);
+ x += textRenderer.getWidth(title.text) * 3F + 10;
+ context.drawText(textRenderer, title.text, 0, 0, title.color, true
+ );
+ context.getMatrices().pop();
+ if (!title.active) {
+ toRemove.add(title);
+ }
+ }
+ titles.removeAll(toRemove);
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index 20c2c27fa1..4686c31abd 100644
--- a/src/main/resources/assets/skyblocker/lang/en_us.json
+++ b/src/main/resources/assets/skyblocker/lang/en_us.json
@@ -240,6 +240,9 @@
"text.autoconfig.skyblocker.option.slayer.vampireSlayer.enableSteakStakeIndicator": "Enable Steak Stake Indicator",
"text.autoconfig.skyblocker.option.slayer.vampireSlayer.steakStakeUpdateFrequency": "Steak Stake Indicator Update Frequency (Ticks)",
"text.autoconfig.skyblocker.option.slayer.vampireSlayer.steakStakeUpdateFrequency.@Tooltip": "The lower the value, the more frequent the updates, which may cause lag.",
+ "text.autoconfig.skyblocker.option.slayer.vampireSlayer.enableManiaIndicator": "Enable Mania Block Indicator",
+ "text.autoconfig.skyblocker.option.slayer.vampireSlayer.maniaUpdateFrequency": "Mania Indicator Update Frequency (Ticks)",
+ "text.autoconfig.skyblocker.option.slayer.vampireSlayer.maniaUpdateFrequency.@Tooltip": "The lower the value, the more frequent the updates, which may cause lag.",
"skyblocker.update.update_message": "§b[§6Skyblocker§b] §2There is a new version available!",
"skyblocker.update.update_link": " §2§nClick here§r",
@@ -255,6 +258,7 @@
"skyblocker.fishing.reelNow": "Reel in now!",
"skyblocker.rift.healNow": "Heal now!",
"skyblocker.rift.iceNow": "Ice now!",
+ "skyblocker.rift.mania": "Mania!",
"skyblocker.rift.stakeNow": "Stake now!",
"skyblocker.fairySouls.markAllFound": "Marked all fairy souls in the current island as found",
"skyblocker.fairySouls.markAllMissing": "Marked all fairy souls in the current island as missing"
From 77fe811d2347b7fb21da028ffe32205459804e3d Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Tue, 4 Jul 2023 20:21:03 -0400
Subject: [PATCH 02/17] Change Position
---
.gitignore | 1 +
.../java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 896dca7fad..b95c73fbb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,4 @@ bin/
# fabric
run/
+libs/
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
index c8747596f1..472c39fd69 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -65,7 +65,7 @@ public static void draw(DrawContext context, float tickDelta) {
for (Title title : titles) {
context.getMatrices().push();
- context.getMatrices().translate(title.lastX, client.getWindow().getScaledHeight() * 0.6F, 0);
+ context.getMatrices().translate(title.lastX, client.getWindow().getScaledHeight() * 0.7F, 0);
context.getMatrices().scale(3.0F, 3.0F, 3.0F);
title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, x);
From 83b5d6152bc73b8d550a45a46792c2ee2523d4fa Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Tue, 4 Jul 2023 20:31:44 -0400
Subject: [PATCH 03/17] oopsie daisy
---
.../skyblocker/skyblock/rift/HealingMelonIndicator.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
index 050c300f32..63cd2b7e5e 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
@@ -15,7 +15,7 @@ public class HealingMelonIndicator {
private static Title title = null;
public static void updateHealth(MinecraftClient client) {
if(title == null)
- new Title(I18n.translate("skyblocker.rift.healNow"), Formatting.DARK_RED.getColorValue());
+ title = new Title(I18n.translate("skyblocker.rift.healNow"), Formatting.DARK_RED.getColorValue());
if (!SkyblockerConfig.get().slayer.vampireSlayer.enableHealingMelonIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château")) {
title.active = false;
From f5eca35862beee810c4761a51f274bb89e726e55 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Tue, 4 Jul 2023 20:37:27 -0400
Subject: [PATCH 04/17] remove debug stuff
---
.../skyblock/rift/HealingMelonIndicator.java | 1 -
.../skyblock/rift/StakeIndicator.java | 1 -
.../skyblock/rift/TwinClawsIndicator.java | 1 -
.../skyblocker/utils/title/TitleContainer.java | 17 -----------------
4 files changed, 20 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
index 63cd2b7e5e..d1657d6747 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
@@ -8,7 +8,6 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.resource.language.I18n;
-import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class HealingMelonIndicator {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
index 01b6b73852..d946df6d4b 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
@@ -8,7 +8,6 @@
import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.Entity;
-import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class StakeIndicator {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
index a062f7b7e4..706aa95e0e 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
@@ -9,7 +9,6 @@
import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.Entity;
-import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class TwinClawsIndicator {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
index 472c39fd69..8eaf45a324 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -1,13 +1,11 @@
package me.xmrvizzy.skyblocker.utils.title;
import me.xmrvizzy.skyblocker.SkyblockerMod;
-import me.xmrvizzy.skyblocker.skyblock.FairySouls;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
-import net.minecraft.entity.decoration.DisplayEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.MathHelper;
@@ -24,21 +22,6 @@ public class TitleContainer {
private static final Logger LOGGER = LoggerFactory.getLogger("skyblocker");
public static void init() {
HudRenderCallback.EVENT.register(TitleContainer::draw);
- ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE)
- .then(literal("title")
- .then(literal("ice").executes(context -> {
- titles.add(new Title(Text.translatable("skyblocker.rift.iceNow").getString(), Formatting.AQUA.getColorValue()));
- return 1;
- }))
- .then(literal("stake").executes(context -> {
- titles.add(new Title("Stake", Formatting.RED.getColorValue()));
- return 1;
- }))
- .then(literal("heal").executes(context -> {
- titles.add(new Title("Heal", Formatting.DARK_RED.getColorValue()));
- return 1;
- }))
- )));
}
public static void addTitle(Title title)
{
From 7c5916b985edbee5a428ff0af80e7104b8d3b3e4 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Tue, 4 Jul 2023 21:16:36 -0400
Subject: [PATCH 05/17] Fix Renderer
---
gradle.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle.properties b/gradle.properties
index d90dc6f2bc..cbb51b5214 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -18,7 +18,7 @@ mod_menu_version=7.0.1
## REI (https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items/files)
rei_version=12.0.625
## Renderer (https://github.com/0x3C50/Renderer)
-renderer_version = master-SNAPSHOT
+renderer_version = d687aced4c
# Mod Properties
mod_version = 1.10.0
From e393d6f9fa44b0314734ce54927ebf3bf0551d47 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Wed, 5 Jul 2023 17:07:44 -0400
Subject: [PATCH 06/17] Make Changes + Add scaling
---
.../skyblocker/config/SkyblockerConfig.java | 10 +++++++
.../utils/title/TitleContainer.java | 28 ++++++-------------
.../assets/skyblocker/lang/en_us.json | 3 ++
3 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
index ab4149fcf7..d461dbfec1 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
@@ -175,6 +175,11 @@ public static class General {
@ConfigEntry.Gui.CollapsibleObject()
public Hitbox hitbox = new Hitbox();
+ @ConfigEntry.Gui.Tooltip()
+ @ConfigEntry.Category("titleContainer")
+ @ConfigEntry.Gui.CollapsibleObject()
+ public TitleContainer titleContainer = new TitleContainer();
+
@ConfigEntry.Gui.Excluded
public List lockedSlots = new ArrayList<>();
}
@@ -247,6 +252,11 @@ public static class Hitbox {
public boolean oldLeverHitbox = false;
}
+ public static class TitleContainer {
+ @ConfigEntry.BoundedDiscrete(min = 30, max = 140)
+ public float titleContainerScale = 100;
+ }
+
public static class RichPresence {
public boolean enableRichPresence = false;
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
index 8eaf45a324..9728e1eb75 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -1,30 +1,22 @@
package me.xmrvizzy.skyblocker.utils.title;
-import me.xmrvizzy.skyblocker.SkyblockerMod;
-import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
+import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
import net.minecraft.util.math.MathHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
-import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
-
public class TitleContainer {
public static List titles = new ArrayList<>();
- private static final Logger LOGGER = LoggerFactory.getLogger("skyblocker");
+
public static void init() {
HudRenderCallback.EVENT.register(TitleContainer::draw);
}
- public static void addTitle(Title title)
- {
+ public static void addTitle(Title title) {
title.active = true;
title.lastX = 0;
titles.add(title);
@@ -35,26 +27,24 @@ public static void draw(DrawContext context, float tickDelta) {
List toRemove = new ArrayList<>();
+ float scale = 3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F);
+
float x;
float width = 0;
- context.getMatrices().push();
- context.getMatrices().scale(3.0F, 3.0F, 3.0F);
for (Title title : titles) {
- width += textRenderer.getWidth(title.text) * 3F + 10;
+ width += textRenderer.getWidth(title.text) * scale + 10;
}
- context.getMatrices().pop();
x = (client.getWindow().getScaledWidth() / 2) - width / 2;
for (Title title : titles) {
context.getMatrices().push();
context.getMatrices().translate(title.lastX, client.getWindow().getScaledHeight() * 0.7F, 0);
- context.getMatrices().scale(3.0F, 3.0F, 3.0F);
+ context.getMatrices().scale(scale, scale, scale);
title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, x);
- x += textRenderer.getWidth(title.text) * 3F + 10;
- context.drawText(textRenderer, title.text, 0, 0, title.color, true
- );
+ x += textRenderer.getWidth(title.text) * scale + 10;
+ context.drawText(textRenderer, title.text, 0, 0, title.color, true);
context.getMatrices().pop();
if (!title.active) {
toRemove.add(title);
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index 4686c31abd..641fd202ee 100644
--- a/src/main/resources/assets/skyblocker/lang/en_us.json
+++ b/src/main/resources/assets/skyblocker/lang/en_us.json
@@ -52,6 +52,9 @@
"text.autoconfig.skyblocker.option.general.hitbox": "Hitboxes",
"text.autoconfig.skyblocker.option.general.hitbox.oldFarmlandHitbox": "Enable 1.8 farmland hitbox",
"text.autoconfig.skyblocker.option.general.hitbox.oldLeverHitbox": "Enable 1.8 lever hitbox",
+ "text.autoconfig.skyblocker.option.general.titleContainer": "Title Container",
+ "text.autoconfig.skyblocker.option.general.titleContainer.@Tooltip": "Used to display multiple titles at once, Example use: Vampire Slayer",
+ "text.autoconfig.skyblocker.option.general.titleContainer.titleContainerScale": "Title Container Scale",
"skyblocker.itemTooltip.nullMessage": "§b[§6Skyblocker§b] §cItem price information on tooltip will renew in max 60 seconds. If not, check latest.log",
"skyblocker.itemTooltip.noData": "§cNo Data",
From a4917d92ab77bc980b68017721adac2091a51f3e Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Fri, 7 Jul 2023 18:00:58 -0400
Subject: [PATCH 07/17] WIP Title Container movement + Duration methods
Added a WIP configuration screen under /Skyblocker hud titleContainer that allows you to move, change alignment, and reorient the titles inside.
Added methods(TitleContainer.addTitleWithDismiss, and RenderHelper.displayInTitleContainerWDismissAndPlaySound) that will display the given title and after a set amount of ticks will disable that title.
---
.gitignore | 1 -
.../skyblocker/config/SkyblockerConfig.java | 34 +++++++
.../skyblocker/utils/RenderHelper.java | 5 +
.../skyblocker/utils/title/Title.java | 1 +
.../utils/title/TitleContainer.java | 81 ++++++++++++++--
.../title/TitleContainerConfigScreen.java | 95 +++++++++++++++++++
6 files changed, 207 insertions(+), 10 deletions(-)
create mode 100644 src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
diff --git a/.gitignore b/.gitignore
index b95c73fbb2..896dca7fad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,4 +32,3 @@ bin/
# fabric
run/
-libs/
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
index d461dbfec1..1aeee35e05 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
@@ -255,6 +255,40 @@ public static class Hitbox {
public static class TitleContainer {
@ConfigEntry.BoundedDiscrete(min = 30, max = 140)
public float titleContainerScale = 100;
+ public int x = 540;
+ public int y = 10;
+ @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
+ public Direction direction = Direction.HORIZONTAL;
+ @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.DROPDOWN)
+ public Alignment alignment = Alignment.MIDDLE;
+ }
+
+ public enum Direction {
+ HORIZONTAL,
+ VERTICAL;
+
+ @Override
+ public String toString() {
+ return switch (this) {
+ case HORIZONTAL -> "Horizontal";
+ case VERTICAL -> "Vertical";
+ };
+ }
+ }
+
+ public enum Alignment {
+ LEFT,
+ RIGHT,
+ MIDDLE;
+
+ @Override
+ public String toString() {
+ return switch (this) {
+ case LEFT -> "Left";
+ case RIGHT -> "Right";
+ case MIDDLE -> "Middle";
+ };
+ }
}
public static class RichPresence {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
index e75538f6b4..4a15112961 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
@@ -58,6 +58,11 @@ public static void displayInTitleContainerAndPlaySound(Title title) {
playNotificationSound();
}
+ public static void displayInTitleContainerWDismissAndPlaySound(Title title, int ticks) {
+ TitleContainer.addTitleWithDismiss(title, ticks);
+ playNotificationSound();
+ }
+
private static void playNotificationSound() {
if (MinecraftClient.getInstance().player != null) {
MinecraftClient.getInstance().player.playSound(SoundEvent.of(new Identifier("entity.experience_orb.pickup")), 100f, 0.1f);
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
index 44a636d781..d1977470ab 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
@@ -5,6 +5,7 @@ public class Title {
public boolean active = true;
public int color;
public float lastX = 0;
+ public float lastY = 0;
public Title(String text, int color) {
this.text = text;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
index 9728e1eb75..e888fbda6d 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -1,27 +1,50 @@
package me.xmrvizzy.skyblocker.utils.title;
+import me.xmrvizzy.skyblocker.SkyblockerMod;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import me.xmrvizzy.skyblocker.skyblock.dwarven.DwarvenHudConfigScreen;
+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;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
+import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import java.util.ArrayList;
import java.util.List;
public class TitleContainer {
+ public static final MinecraftClient client = MinecraftClient.getInstance();
public static List titles = new ArrayList<>();
public static void init() {
HudRenderCallback.EVENT.register(TitleContainer::draw);
+ ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("skyblocker")
+ .then(ClientCommandManager.literal("hud")
+ .then(ClientCommandManager.literal("titleContainer")
+ .executes(context -> {
+ client.send(() -> client.setScreen(new TitleContainerConfigScreen(Text.of("Title Container HUD Config"))));
+ return 1;
+ })))));
}
public static void addTitle(Title title) {
title.active = true;
title.lastX = 0;
+ title.lastY = SkyblockerConfig.get().general.titleContainer.y;
titles.add(title);
}
+ public static void addTitleWithDismiss(Title title, int ticks) {
+ addTitle(title);
+ SkyblockerMod.getInstance().scheduler.schedule(() -> {
+ title.active = false;
+ }, ticks);
+ }
public static void draw(DrawContext context, float tickDelta) {
+ draw(titles, SkyblockerConfig.get().general.titleContainer.x, SkyblockerConfig.get().general.titleContainer.y, context, tickDelta, false);
+ }
+ public static void draw(List titlesToDraw, int xPos, int yPos, DrawContext context, float tickDelta, boolean example) {
var client = MinecraftClient.getInstance();
TextRenderer textRenderer = client.textRenderer;
@@ -29,27 +52,67 @@ public static void draw(DrawContext context, float tickDelta) {
float scale = 3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F);
- float x;
+ var direction = SkyblockerConfig.get().general.titleContainer.direction;
+ var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
+ float x = 0;
+ float y;
float width = 0;
- for (Title title : titles) {
+ for (Title title : titlesToDraw) {
width += textRenderer.getWidth(title.text) * scale + 10;
}
+ if (alignment == SkyblockerConfig.Alignment.MIDDLE) {
+ if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ x = xPos - width / 2;
+ } else {
+ if (titlesToDraw.size() > 0) {
+ if (titlesToDraw.size() > 0) {
+ x = xPos - (textRenderer.getWidth(titlesToDraw.get(0).text) / 2 * scale);
+ }
+ }
+ }
+ } else {
+ if (alignment == SkyblockerConfig.Alignment.LEFT) {
+ x = xPos;
+ } else {
+ if (titlesToDraw.size() > 0) {
+ x = xPos - (textRenderer.getWidth(titlesToDraw.get(0).text) * scale);
+ }
+ }
+ }
+ y = yPos;
- x = (client.getWindow().getScaledWidth() / 2) - width / 2;
-
- for (Title title : titles) {
+ for (Title title : titlesToDraw) {
context.getMatrices().push();
- context.getMatrices().translate(title.lastX, client.getWindow().getScaledHeight() * 0.7F, 0);
+ context.getMatrices().translate(title.lastX, title.lastY, 200);
context.getMatrices().scale(scale, scale, scale);
title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, x);
- x += textRenderer.getWidth(title.text) * scale + 10;
+ title.lastY = MathHelper.lerp(tickDelta * 0.5F, title.lastY, y);
+
+ if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ switch (alignment) {
+ case LEFT -> x += textRenderer.getWidth(title.text) * scale + 10;
+ case RIGHT -> x -= (textRenderer.getWidth(title.text) * scale + 10);
+ case MIDDLE -> x += textRenderer.getWidth(title.text) * scale + 10;
+ }
+ y = yPos;
+ } else {
+ switch (alignment) {
+ case LEFT -> x = xPos;
+ case RIGHT -> x = xPos - (textRenderer.getWidth(title.text) * scale);
+ case MIDDLE -> x = xPos - ((textRenderer.getWidth(title.text) * scale));
+ }
+ y += textRenderer.fontHeight * scale + 10;
+ }
+
context.drawText(textRenderer, title.text, 0, 0, title.color, true);
context.getMatrices().pop();
- if (!title.active) {
+ if (!title.active && !example) {
toRemove.add(title);
}
}
- titles.removeAll(toRemove);
+ if (!example) {
+ titlesToDraw.removeAll(toRemove);
+ }
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
new file mode 100644
index 0000000000..5a693ddbf6
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -0,0 +1,95 @@
+package me.xmrvizzy.skyblocker.utils.title;
+
+import me.shedaniel.autoconfig.AutoConfig;
+import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import me.xmrvizzy.skyblocker.skyblock.dwarven.DwarvenHud;
+import me.xmrvizzy.skyblocker.utils.RenderUtils;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.DrawContext;
+import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.input.KeyCodes;
+import net.minecraft.text.Text;
+import net.minecraft.util.Formatting;
+import org.lwjgl.glfw.GLFW;
+
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.util.List;
+
+public class TitleContainerConfigScreen extends Screen {
+
+ private final Title example1 = new Title("Test1", Formatting.RED.getColorValue());
+ private final Title example2 = new Title("Test23", Formatting.AQUA.getColorValue());
+ private final Title example3 = new Title("Testing123456", Formatting.DARK_GREEN.getColorValue());
+ private int hudX = SkyblockerConfig.get().general.titleContainer.x;
+ private int hudY = SkyblockerConfig.get().general.titleContainer.y;
+ protected TitleContainerConfigScreen(Text title) {
+ super(title);
+ }
+
+ @Override
+ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
+ super.render(context, mouseX, mouseY, delta);
+ renderBackground(context);
+ TitleContainer.draw(List.of(example1, example2, example3), hudX, hudY, context, delta, true);
+ context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB());
+ int width1 = client.textRenderer.getWidth("Press Q/E to change Alignment");
+ int width2 = client.textRenderer.getWidth("Press R to change Direction");
+ context.drawText(client.textRenderer, "Press Q/E to change Alignment", (width / 2) - width1 / 2, client.textRenderer.fontHeight * 2, Color.GRAY.getRGB(), true);
+ context.drawText(client.textRenderer, "Press R to change Direction", (width / 2) - width2 / 2, client.textRenderer.fontHeight * 3 + 5, Color.GRAY.getRGB(), true);
+ }
+
+ @Override
+ public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
+ if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, hudX - 100, hudY - 20, hudX + 110, hudY + 30) && button == 0) {
+ hudX = (int) Math.max(Math.min(mouseX, this.width - 100), 110);
+ hudY = (int) Math.max(Math.min(mouseY, this.height - 30), 0);
+ }
+ return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
+ }
+
+ @Override
+ public boolean mouseClicked(double mouseX, double mouseY, int button) {
+ if (button == 1) {
+ hudX = this.width / 2;
+ hudY = (int) (this.height * 0.6F);
+ }
+ return super.mouseClicked(mouseX, mouseY, button);
+ }
+
+ @Override
+ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
+ if(keyCode == GLFW.GLFW_KEY_Q) {
+ var current = SkyblockerConfig.get().general.titleContainer.alignment;
+ SkyblockerConfig.get().general.titleContainer.alignment = switch (current) {
+ case LEFT -> SkyblockerConfig.Alignment.MIDDLE;
+ case MIDDLE -> SkyblockerConfig.Alignment.RIGHT;
+ case RIGHT -> SkyblockerConfig.Alignment.LEFT;
+ };
+ }
+ if(keyCode == GLFW.GLFW_KEY_E) {
+ var current = SkyblockerConfig.get().general.titleContainer.alignment;
+ SkyblockerConfig.get().general.titleContainer.alignment = switch (current) {
+ case LEFT -> SkyblockerConfig.Alignment.RIGHT;
+ case MIDDLE -> SkyblockerConfig.Alignment.LEFT;
+ case RIGHT -> SkyblockerConfig.Alignment.MIDDLE;
+ };
+ }
+ if(keyCode == GLFW.GLFW_KEY_R) {
+ var current = SkyblockerConfig.get().general.titleContainer.direction;
+ SkyblockerConfig.get().general.titleContainer.direction = switch (current) {
+ case HORIZONTAL -> SkyblockerConfig.Direction.VERTICAL;
+ case VERTICAL -> SkyblockerConfig.Direction.HORIZONTAL;
+ };
+ }
+ return super.keyPressed(keyCode, scanCode, modifiers);
+ }
+
+ @Override
+ public void close() {
+ SkyblockerConfig.get().general.titleContainer.x = hudX;
+ SkyblockerConfig.get().general.titleContainer.y = hudY;
+ AutoConfig.getConfigHolder(SkyblockerConfig.class).save();
+ super.close();
+ }
+}
From 558bb3c1b3a52cc4a8ec3610fa88b9552a063433 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Fri, 7 Jul 2023 21:31:19 -0400
Subject: [PATCH 08/17] Proper Movement Menu
---
.../utils/title/TitleContainer.java | 51 +++----
.../title/TitleContainerConfigScreen.java | 141 +++++++++++++++++-
2 files changed, 159 insertions(+), 33 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
index e888fbda6d..14db8d6e6b 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -60,25 +60,18 @@ public static void draw(List titlesToDraw, int xPos, int yPos, DrawContex
for (Title title : titlesToDraw) {
width += textRenderer.getWidth(title.text) * scale + 10;
}
- if (alignment == SkyblockerConfig.Alignment.MIDDLE) {
- if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
- x = xPos - width / 2;
- } else {
- if (titlesToDraw.size() > 0) {
- if (titlesToDraw.size() > 0) {
- x = xPos - (textRenderer.getWidth(titlesToDraw.get(0).text) / 2 * scale);
- }
- }
+ if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ if (alignment == SkyblockerConfig.Alignment.MIDDLE) {
+ x = xPos - (width / 2);
}
} else {
- if (alignment == SkyblockerConfig.Alignment.LEFT) {
+ if (alignment == SkyblockerConfig.Alignment.MIDDLE) {
x = xPos;
- } else {
- if (titlesToDraw.size() > 0) {
- x = xPos - (textRenderer.getWidth(titlesToDraw.get(0).text) * scale);
- }
}
}
+ if(alignment == SkyblockerConfig.Alignment.LEFT || alignment == SkyblockerConfig.Alignment.RIGHT) {
+ x = xPos;
+ }
y = yPos;
for (Title title : titlesToDraw) {
@@ -86,22 +79,30 @@ public static void draw(List titlesToDraw, int xPos, int yPos, DrawContex
context.getMatrices().translate(title.lastX, title.lastY, 200);
context.getMatrices().scale(scale, scale, scale);
- title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, x);
+ float xToUse = 0;
+ if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ xToUse = alignment == SkyblockerConfig.Alignment.RIGHT ?
+ x - (textRenderer.getWidth(title.text) * scale) :
+ x;
+ } else {
+ xToUse = alignment == SkyblockerConfig.Alignment.MIDDLE ?
+ x - (textRenderer.getWidth(title.text) * scale) / 2 :
+ alignment == SkyblockerConfig.Alignment.RIGHT ?
+ x - (textRenderer.getWidth(title.text) * scale) :
+ x;
+ }
+ title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, xToUse);
title.lastY = MathHelper.lerp(tickDelta * 0.5F, title.lastY, y);
if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
- switch (alignment) {
- case LEFT -> x += textRenderer.getWidth(title.text) * scale + 10;
- case RIGHT -> x -= (textRenderer.getWidth(title.text) * scale + 10);
- case MIDDLE -> x += textRenderer.getWidth(title.text) * scale + 10;
+ if (alignment == SkyblockerConfig.Alignment.MIDDLE || alignment == SkyblockerConfig.Alignment.LEFT) {
+ x += textRenderer.getWidth(title.text) * scale + 10;
}
- y = yPos;
- } else {
- switch (alignment) {
- case LEFT -> x = xPos;
- case RIGHT -> x = xPos - (textRenderer.getWidth(title.text) * scale);
- case MIDDLE -> x = xPos - ((textRenderer.getWidth(title.text) * scale));
+
+ if (alignment == SkyblockerConfig.Alignment.RIGHT) {
+ x -= textRenderer.getWidth(title.text) * scale + 10;
}
+ } else {
y += textRenderer.fontHeight * scale + 10;
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
index 5a693ddbf6..41734dcba1 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -20,7 +20,7 @@ public class TitleContainerConfigScreen extends Screen {
private final Title example1 = new Title("Test1", Formatting.RED.getColorValue());
private final Title example2 = new Title("Test23", Formatting.AQUA.getColorValue());
- private final Title example3 = new Title("Testing123456", Formatting.DARK_GREEN.getColorValue());
+ private final Title example3 = new Title("Testing1234", Formatting.DARK_GREEN.getColorValue());
private int hudX = SkyblockerConfig.get().general.titleContainer.x;
private int hudY = SkyblockerConfig.get().general.titleContainer.y;
protected TitleContainerConfigScreen(Text title) {
@@ -33,17 +33,142 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context);
TitleContainer.draw(List.of(example1, example2, example3), hudX, hudY, context, delta, true);
context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB());
- int width1 = client.textRenderer.getWidth("Press Q/E to change Alignment");
- int width2 = client.textRenderer.getWidth("Press R to change Direction");
- context.drawText(client.textRenderer, "Press Q/E to change Alignment", (width / 2) - width1 / 2, client.textRenderer.fontHeight * 2, Color.GRAY.getRGB(), true);
- context.drawText(client.textRenderer, "Press R to change Direction", (width / 2) - width2 / 2, client.textRenderer.fontHeight * 3 + 5, Color.GRAY.getRGB(), true);
+ var direction = SkyblockerConfig.get().general.titleContainer.direction;
+ var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
+ int width1 = client.textRenderer.getWidth("Press Q/E to change Alignment: " + alignment.toString());
+ int width2 = client.textRenderer.getWidth("Press R to change Direction: " + direction.toString());
+ context.drawText(client.textRenderer, "Press Q/E to change Alignment: " + alignment.toString(), (width / 2) - width1 / 2, client.textRenderer.fontHeight * 2, Color.GRAY.getRGB(), true);
+ context.drawText(client.textRenderer, "Press R to change Direction: " + direction.toString(), (width / 2) - width2 / 2, client.textRenderer.fontHeight * 3 + 5, Color.GRAY.getRGB(), true);
+
+ int midWidth = getSelectionWidth() / 2;
+ int midHeight = getSelectionHeight() / 2;
+ int x1 = 0;
+ int x2 = 0;
+ int y1 = 0;
+ int y2 = 0;
+ if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ switch (alignment) {
+ case RIGHT:
+ x1 = hudX - midWidth * 2;
+ x2 = hudX;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ case MIDDLE:
+ x1 = hudX - midWidth;
+ x2 = hudX + midWidth;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ case LEFT:
+ x1 = hudX;
+ x2 = hudX + midWidth * 2;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ }
+ } else {
+ switch (alignment) {
+ case RIGHT:
+ x1 = hudX - midWidth * 2;
+ x2 = hudX;
+ y1 = hudY;
+ y2 = hudY + midHeight;
+ break;
+ case MIDDLE:
+ x1 = hudX - midWidth;
+ x2 = hudX + midWidth;
+ y1 = hudY;
+ y2 = hudY + midHeight;
+ break;
+ case LEFT:
+ x1 = hudX;
+ x2 = hudX + midWidth * 2;
+ y1 = hudY;
+ y2 = hudY + midHeight;
+ break;
+ }
+ }
+ context.drawHorizontalLine(x1, x2, y1, Color.RED.getRGB());
+ context.drawHorizontalLine(x1, x2, y2, Color.RED.getRGB());
+ context.drawVerticalLine(x1, y1, y2, Color.RED.getRGB());
+ context.drawVerticalLine(x2, y1, y2, Color.RED.getRGB());
+ }
+
+ public int getSelectionHeight()
+ {
+ int scale = (int) (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
+ return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ?
+ textRenderer.fontHeight * scale :
+ (textRenderer.fontHeight + 10) * 3 * scale;
+ }
+
+ public int getSelectionWidth()
+ {
+ int scale = (int) (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
+ return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ?
+ (textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale :
+ textRenderer.getWidth("Testing1234") * scale;
}
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
- if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, hudX - 100, hudY - 20, hudX + 110, hudY + 30) && button == 0) {
- hudX = (int) Math.max(Math.min(mouseX, this.width - 100), 110);
- hudY = (int) Math.max(Math.min(mouseY, this.height - 30), 0);
+ int midWidth = getSelectionWidth() / 2;
+ int midHeight = getSelectionHeight() / 2;
+ var direction = SkyblockerConfig.get().general.titleContainer.direction;
+ var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
+ int x1 = 0;
+ int x2 = 0;
+ int y1 = 0;
+ int y2 = 0;
+ if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ switch (alignment) {
+ case RIGHT:
+ x1 = hudX - midWidth * 2;
+ x2 = hudX;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ case MIDDLE:
+ x1 = hudX - midWidth;
+ x2 = hudX + midWidth;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ case LEFT:
+ x1 = hudX;
+ x2 = hudX + midWidth * 2;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ }
+ } else {
+ switch (alignment) {
+ case RIGHT:
+ x1 = hudX - midWidth * 2;
+ x2 = hudX;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ case MIDDLE:
+ x1 = hudX - midWidth;
+ x2 = hudX + midWidth;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ case LEFT:
+ x1 = hudX;
+ x2 = hudX + midWidth * 2;
+ y1 = hudY + 0;
+ y2 = hudY + midHeight * 2;
+ break;
+ }
+ }
+ if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, x1, y1, x2, y2) && button == 0) {
+ hudX = alignment == SkyblockerConfig.Alignment.RIGHT ?
+ (int) mouseX + midWidth :
+ (int) mouseX - (midWidth / 2);
+ hudY = (int) mouseY - (midHeight);
}
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}
From b6cc175f8782ee94f5aeaef877466f9c81564cf6 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Fri, 7 Jul 2023 21:48:32 -0400
Subject: [PATCH 09/17] Remove Duplicate Code
---
.../title/TitleContainerConfigScreen.java | 89 ++++++++-----------
1 file changed, 37 insertions(+), 52 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
index 41734dcba1..cf59ff6656 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -10,6 +10,8 @@
import net.minecraft.client.input.KeyCodes;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
+import net.minecraft.util.math.Box;
+import org.joml.Vector4i;
import org.lwjgl.glfw.GLFW;
import java.awt.*;
@@ -40,6 +42,28 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
context.drawText(client.textRenderer, "Press Q/E to change Alignment: " + alignment.toString(), (width / 2) - width1 / 2, client.textRenderer.fontHeight * 2, Color.GRAY.getRGB(), true);
context.drawText(client.textRenderer, "Press R to change Direction: " + direction.toString(), (width / 2) - width2 / 2, client.textRenderer.fontHeight * 3 + 5, Color.GRAY.getRGB(), true);
+ int x1;
+ int x2;
+ int y1;
+ int y2;
+
+ var vec = getSelectionBounding();
+ x1 = vec.x;
+ x2 = vec.y;
+ y1 = vec.z;
+ y2 = vec.w;
+
+ context.drawHorizontalLine(x1, x2, y1, Color.RED.getRGB());
+ context.drawHorizontalLine(x1, x2, y2, Color.RED.getRGB());
+ context.drawVerticalLine(x1, y1, y2, Color.RED.getRGB());
+ context.drawVerticalLine(x2, y1, y2, Color.RED.getRGB());
+ }
+
+ public Vector4i getSelectionBounding()
+ {
+ var direction = SkyblockerConfig.get().general.titleContainer.direction;
+ var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
+
int midWidth = getSelectionWidth() / 2;
int midHeight = getSelectionHeight() / 2;
int x1 = 0;
@@ -89,10 +113,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
break;
}
}
- context.drawHorizontalLine(x1, x2, y1, Color.RED.getRGB());
- context.drawHorizontalLine(x1, x2, y2, Color.RED.getRGB());
- context.drawVerticalLine(x1, y1, y2, Color.RED.getRGB());
- context.drawVerticalLine(x2, y1, y2, Color.RED.getRGB());
+ return new Vector4i(x1, x2, y1, y2);
}
public int getSelectionHeight()
@@ -115,55 +136,19 @@ public int getSelectionWidth()
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
int midWidth = getSelectionWidth() / 2;
int midHeight = getSelectionHeight() / 2;
- var direction = SkyblockerConfig.get().general.titleContainer.direction;
var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
- int x1 = 0;
- int x2 = 0;
- int y1 = 0;
- int y2 = 0;
- if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
- switch (alignment) {
- case RIGHT:
- x1 = hudX - midWidth * 2;
- x2 = hudX;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- case MIDDLE:
- x1 = hudX - midWidth;
- x2 = hudX + midWidth;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- case LEFT:
- x1 = hudX;
- x2 = hudX + midWidth * 2;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- }
- } else {
- switch (alignment) {
- case RIGHT:
- x1 = hudX - midWidth * 2;
- x2 = hudX;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- case MIDDLE:
- x1 = hudX - midWidth;
- x2 = hudX + midWidth;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- case LEFT:
- x1 = hudX;
- x2 = hudX + midWidth * 2;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- }
- }
+
+ int x1;
+ int x2;
+ int y1;
+ int y2;
+
+ var vec = getSelectionBounding();
+ x1 = vec.x;
+ x2 = vec.y;
+ y1 = vec.z;
+ y2 = vec.w;
+
if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, x1, y1, x2, y2) && button == 0) {
hudX = alignment == SkyblockerConfig.Alignment.RIGHT ?
(int) mouseX + midWidth :
From aed3973ad0cc33b3d3128695e6f660dc304bc9d6 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Fri, 7 Jul 2023 23:02:07 -0400
Subject: [PATCH 10/17] Simplify Code + Fix Vertical BB
---
.../title/TitleContainerConfigScreen.java | 61 ++++++-------------
.../assets/skyblocker/lang/en_us.json | 4 ++
2 files changed, 21 insertions(+), 44 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
index cf59ff6656..a035f86258 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -39,8 +39,8 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
int width1 = client.textRenderer.getWidth("Press Q/E to change Alignment: " + alignment.toString());
int width2 = client.textRenderer.getWidth("Press R to change Direction: " + direction.toString());
- context.drawText(client.textRenderer, "Press Q/E to change Alignment: " + alignment.toString(), (width / 2) - width1 / 2, client.textRenderer.fontHeight * 2, Color.GRAY.getRGB(), true);
- context.drawText(client.textRenderer, "Press R to change Direction: " + direction.toString(), (width / 2) - width2 / 2, client.textRenderer.fontHeight * 3 + 5, Color.GRAY.getRGB(), true);
+ context.drawText(client.textRenderer, "Press Q/E to change Alignment: " + alignment.toString(), (width / 2) - width1 / 2, client.textRenderer.fontHeight * 2, Color.WHITE.getRGB(), true);
+ context.drawText(client.textRenderer, "Press R to change Direction: " + direction.toString(), (width / 2) - width2 / 2, client.textRenderer.fontHeight * 3 + 5, Color.WHITE.getRGB(), true);
int x1;
int x2;
@@ -70,48 +70,21 @@ public Vector4i getSelectionBounding()
int x2 = 0;
int y1 = 0;
int y2 = 0;
- if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
- switch (alignment) {
- case RIGHT:
- x1 = hudX - midWidth * 2;
- x2 = hudX;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- case MIDDLE:
- x1 = hudX - midWidth;
- x2 = hudX + midWidth;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- case LEFT:
- x1 = hudX;
- x2 = hudX + midWidth * 2;
- y1 = hudY + 0;
- y2 = hudY + midHeight * 2;
- break;
- }
- } else {
- switch (alignment) {
- case RIGHT:
- x1 = hudX - midWidth * 2;
- x2 = hudX;
- y1 = hudY;
- y2 = hudY + midHeight;
- break;
- case MIDDLE:
- x1 = hudX - midWidth;
- x2 = hudX + midWidth;
- y1 = hudY;
- y2 = hudY + midHeight;
- break;
- case LEFT:
- x1 = hudX;
- x2 = hudX + midWidth * 2;
- y1 = hudY;
- y2 = hudY + midHeight;
- break;
- }
+ y1 = hudY;
+ y2 = hudY + midHeight * 2;
+ switch (alignment) {
+ case RIGHT:
+ x1 = hudX - midWidth * 2;
+ x2 = hudX;
+ break;
+ case MIDDLE:
+ x1 = hudX - midWidth;
+ x2 = hudX + midWidth;
+ break;
+ case LEFT:
+ x1 = hudX;
+ x2 = hudX + midWidth * 2;
+ break;
}
return new Vector4i(x1, x2, y1, y2);
}
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index 641fd202ee..dc3a6cf82d 100644
--- a/src/main/resources/assets/skyblocker/lang/en_us.json
+++ b/src/main/resources/assets/skyblocker/lang/en_us.json
@@ -55,6 +55,10 @@
"text.autoconfig.skyblocker.option.general.titleContainer": "Title Container",
"text.autoconfig.skyblocker.option.general.titleContainer.@Tooltip": "Used to display multiple titles at once, Example use: Vampire Slayer",
"text.autoconfig.skyblocker.option.general.titleContainer.titleContainerScale": "Title Container Scale",
+ "text.autoconfig.skyblocker.option.general.titleContainer.x": "Title Container X Position",
+ "text.autoconfig.skyblocker.option.general.titleContainer.y": "Title Container Y Position",
+ "text.autoconfig.skyblocker.option.general.titleContainer.direction": "Title Container Orientation",
+ "text.autoconfig.skyblocker.option.general.titleContainer.alignment": "Title Container Horizontal Alignment",
"skyblocker.itemTooltip.nullMessage": "§b[§6Skyblocker§b] §cItem price information on tooltip will renew in max 60 seconds. If not, check latest.log",
"skyblocker.itemTooltip.noData": "§cNo Data",
From 796177d64aac6c64949973a5604aedc0d1f2651f Mon Sep 17 00:00:00 2001
From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Date: Sat, 8 Jul 2023 17:20:55 +0800
Subject: [PATCH 11/17] Refactor Title Container
---
.../skyblocker/config/SkyblockerConfig.java | 10 +-
.../skyblocker/skyblock/FishingHelper.java | 4 +-
.../skyblock/rift/EffigyWaypoints.java | 4 +-
.../skyblock/rift/HealingMelonIndicator.java | 19 +--
.../skyblock/rift/ManiaIndicator.java | 27 ++--
.../skyblock/rift/MirrorverseWaypoints.java | 4 +-
.../skyblock/rift/StakeIndicator.java | 19 +--
.../skyblock/rift/TwinClawsIndicator.java | 25 ++--
.../skyblocker/utils/RenderHelper.java | 25 +++-
.../xmrvizzy/skyblocker/utils/Scheduler.java | 21 +++
.../skyblocker/utils/title/Title.java | 31 ++++-
.../utils/title/TitleContainer.java | 128 ++++++++++++------
.../title/TitleContainerConfigScreen.java | 110 ++++++---------
13 files changed, 237 insertions(+), 190 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
index 1aeee35e05..7da9979aa6 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
@@ -1,5 +1,6 @@
package me.xmrvizzy.skyblocker.config;
+import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.ConfigData;
@@ -10,8 +11,6 @@
import me.xmrvizzy.skyblocker.chat.ChatFilterResult;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resource.language.I18n;
import java.util.ArrayList;
@@ -500,11 +499,8 @@ public static void init() {
private static LiteralArgumentBuilder optionsLiteral(String name) {
return literal(name).executes(context -> {
// Don't immediately open the next screen as it will be closed by ChatScreen right after this command is executed
- SkyblockerMod.getInstance().scheduler.schedule(() -> {
- Screen a = AutoConfig.getConfigScreen(SkyblockerConfig.class, null).get();
- MinecraftClient.getInstance().setScreen(a);
- }, 0);
- return 1;
+ SkyblockerMod.getInstance().scheduler.queueOpenScreen(AutoConfig.getConfigScreen(SkyblockerConfig.class, null));
+ return Command.SINGLE_SUCCESS;
});
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FishingHelper.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FishingHelper.java
index 822b89d932..8dee3fcb92 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FishingHelper.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FishingHelper.java
@@ -2,6 +2,7 @@
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.utils.RenderHelper;
+import me.xmrvizzy.skyblocker.utils.title.Title;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
@@ -15,6 +16,7 @@
import net.minecraft.util.math.Vec3d;
public class FishingHelper {
+ private static final Title title = new Title("skyblocker.fishing.reelNow", Formatting.GREEN);
private static long startTime;
private static Vec3d normalYawVector;
@@ -49,7 +51,7 @@ public static void onSound(MinecraftClient client, PlaySoundS2CPacket packet) {
if (player != null && player.fishHook != null) {
Vec3d soundToFishHook = player.fishHook.getPos().subtract(packet.getX(), 0, packet.getZ());
if (Math.abs(normalYawVector.x * soundToFishHook.z - normalYawVector.z * soundToFishHook.x) < 0.2D && Math.abs(normalYawVector.dotProduct(soundToFishHook)) < 4D && player.getPos().squaredDistanceTo(packet.getX(), packet.getY(), packet.getZ()) > 1D) {
- RenderHelper.displayTitleAndPlaySound(10, 5, "skyblocker.fishing.reelNow", Formatting.GREEN);
+ RenderHelper.displayInTitleContainerAndPlaySound(title, 10);
reset();
}
} else {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/EffigyWaypoints.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/EffigyWaypoints.java
index 0d44900ad1..7376c89675 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/EffigyWaypoints.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/EffigyWaypoints.java
@@ -32,7 +32,7 @@ public class EffigyWaypoints {
);
private static final List unBrokenEffigies = new ArrayList<>();
- public static void updateEffigies() {
+ protected static void updateEffigies() {
if (!SkyblockerConfig.get().slayer.vampireSlayer.enableEffigyWaypoints || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château")) return;
unBrokenEffigies.clear();
@@ -61,7 +61,7 @@ public static void updateEffigies() {
}
}
- public static void render(WorldRenderContext context) {
+ protected static void render(WorldRenderContext context) {
if (SkyblockerConfig.get().slayer.vampireSlayer.enableEffigyWaypoints && Utils.getLocation().contains("Stillgore Château")) {
for (BlockPos effigy : unBrokenEffigies) {
float[] colorComponents = DyeColor.RED.getColorComponents();
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
index d1657d6747..fed34796d5 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java
@@ -7,28 +7,21 @@
import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
-import net.minecraft.client.resource.language.I18n;
import net.minecraft.util.Formatting;
public class HealingMelonIndicator {
- private static Title title = null;
- public static void updateHealth(MinecraftClient client) {
- if(title == null)
- title = new Title(I18n.translate("skyblocker.rift.healNow"), Formatting.DARK_RED.getColorValue());
+ private static final Title title = new Title("skyblocker.rift.healNow", Formatting.DARK_RED);
+ public static void updateHealth(MinecraftClient client) {
if (!SkyblockerConfig.get().slayer.vampireSlayer.enableHealingMelonIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château")) {
- title.active = false;
+ TitleContainer.removeTitle(title);
return;
}
- title.active = true;
ClientPlayerEntity player = client.player;
if (player != null && player.getHealth() <= SkyblockerConfig.get().slayer.vampireSlayer.healingMelonHealthThreshold * 2F) {
- title.active = true;
- if(!TitleContainer.titles.contains(title))
- RenderHelper.displayInTitleContainerAndPlaySound(title);
- }
- else {
- title.active = false;
+ RenderHelper.displayInTitleContainerAndPlaySound(title);
+ } else {
+ TitleContainer.removeTitle(title);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
index 7d5a1cb417..4e873eedf8 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
@@ -8,18 +8,16 @@
import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.util.Formatting;
+import net.minecraft.util.math.BlockPos;
public class ManiaIndicator {
- private static Title title = null;
- public static void updateMania() {
- if(title == null)
- title = new Title("b", Formatting.RED.getColorValue());
+ private static final Title title = new Title("skyblocker.rift.mania", Formatting.RED);
+ protected static void updateMania() {
if (!SkyblockerConfig.get().slayer.vampireSlayer.enableManiaIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !(Utils.getLocation().contains("Stillgore Château")) || !SlayerUtils.isInSlayer()) {
- title.active = false;
+ TitleContainer.removeTitle(title);
return;
}
@@ -30,17 +28,14 @@ public static void updateMania() {
for (Entity entity : SlayerUtils.getEntityArmorStands(slayerEntity)) {
if (entity.getDisplayName().toString().contains("MANIA")) {
anyMania = true;
- title.active = true;
- var pos = MinecraftClient.getInstance().player.getBlockPos().down();
- var isGreen = MinecraftClient.getInstance().world.getBlockState(pos).getBlock() == Blocks.GREEN_TERRACOTTA;
- title.color = isGreen ? Formatting.GREEN.getColorValue() : Formatting.RED.getColorValue();
- if(!TitleContainer.titles.contains(title)) {
- title.text = I18n.translate("skyblocker.rift.mania");
- RenderHelper.displayInTitleContainerAndPlaySound(title);
- }
+ BlockPos pos = MinecraftClient.getInstance().player.getBlockPos().down();
+ boolean isGreen = MinecraftClient.getInstance().world.getBlockState(pos).getBlock() == Blocks.GREEN_TERRACOTTA;
+ title.setFormatting(isGreen ? Formatting.GREEN : Formatting.RED);
+ RenderHelper.displayInTitleContainerAndPlaySound(title);
}
}
- if(!anyMania)
- title.active = false;
+ if (!anyMania) {
+ TitleContainer.removeTitle(title);
+ }
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java
index 276ec55198..32551179ce 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java
@@ -34,7 +34,7 @@ public class MirrorverseWaypoints {
/**
* Loads the waypoint locations into memory
*/
- public static void loadWaypoints() {
+ private static void loadWaypoints() {
try (BufferedReader reader = CLIENT.getResourceManager().openAsReader(WAYPOINTS_JSON)) {
JsonObject file = JsonParser.parseReader(reader).getAsJsonObject();
JsonArray sections = file.get("sections").getAsJsonArray();
@@ -69,7 +69,7 @@ public static void loadWaypoints() {
}
}
- public static void render(WorldRenderContext wrc) {
+ protected static void render(WorldRenderContext wrc) {
//I would also check for the mirrorverse location but the scoreboard stuff is not performant at all...
if (Utils.isInTheRift() && SkyblockerConfig.get().locations.rift.mirrorverseWaypoints) {
for (BlockPos pos : LAVA_PATH_WAYPOINTS) {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
index d946df6d4b..90fc436dc9 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/StakeIndicator.java
@@ -6,28 +6,23 @@
import me.xmrvizzy.skyblocker.utils.Utils;
import me.xmrvizzy.skyblocker.utils.title.Title;
import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
-import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.Entity;
+import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class StakeIndicator {
- private static Title title = null;
- public static void updateStake() {
- if (title == null)
- title = new Title("b", Formatting.RED.getColorValue());
+ private static final Title title = new Title("skyblocker.rift.stakeNow",Formatting.RED);
+ protected static void updateStake() {
if (!SkyblockerConfig.get().slayer.vampireSlayer.enableSteakStakeIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château") || !SlayerUtils.isInSlayer()) {
- title.active = false;
+ TitleContainer.removeTitle(title);
return;
}
Entity slayerEntity = SlayerUtils.getSlayerEntity();
if (slayerEntity != null && slayerEntity.getDisplayName().toString().contains("҉")) {
- title.active = true;
- title.text = I18n.translate("skyblocker.rift.stakeNow");
- if(!TitleContainer.titles.contains(title))
- RenderHelper.displayInTitleContainerAndPlaySound(title);
+ RenderHelper.displayInTitleContainerAndPlaySound(title);
+ } else {
+ TitleContainer.removeTitle(title);
}
- else
- title.active = false;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
index 706aa95e0e..f36b97df20 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TwinClawsIndicator.java
@@ -7,19 +7,17 @@
import me.xmrvizzy.skyblocker.utils.Utils;
import me.xmrvizzy.skyblocker.utils.title.Title;
import me.xmrvizzy.skyblocker.utils.title.TitleContainer;
-import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.Entity;
+import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
public class TwinClawsIndicator {
- private static Title title = null;
- public static boolean scheduling = false;
- public static void updateIce() {
- if(title == null)
- title = new Title("b", Formatting.AQUA.getColorValue());
+ private static final Title title = new Title("skyblocker.rift.iceNow",Formatting.AQUA);
+ private static boolean scheduled = false;
+ protected static void updateIce() {
if (!SkyblockerConfig.get().slayer.vampireSlayer.enableHolyIceIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !(Utils.getLocation().contains("Stillgore Château")) || !SlayerUtils.isInSlayer()) {
- title.active = false;
+ TitleContainer.removeTitle(title);
return;
}
@@ -30,18 +28,17 @@ public static void updateIce() {
for (Entity entity : SlayerUtils.getEntityArmorStands(slayerEntity)) {
if (entity.getDisplayName().toString().contains("TWINCLAWS")) {
anyClaws = true;
- title.active = true;
- if(!TitleContainer.titles.contains(title) && !scheduling) {
- scheduling = true;
+ if (!TitleContainer.containsTitle(title) && !scheduled) {
+ scheduled = true;
SkyblockerMod.getInstance().scheduler.schedule(() -> {
- title.text = I18n.translate("skyblocker.rift.iceNow");
RenderHelper.displayInTitleContainerAndPlaySound(title);
- scheduling = false;
+ scheduled = false;
}, SkyblockerConfig.get().slayer.vampireSlayer.holyIceIndicatorTickDelay);
}
}
}
- if(!anyClaws)
- title.active = false;
+ if (!anyClaws) {
+ TitleContainer.removeTitle(title);
+ }
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
index 4a15112961..6fa9373541 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
@@ -53,14 +53,29 @@ public static void displayTitleAndPlaySound(int stayTicks, int fadeOutTicks, Str
playNotificationSound();
}
+ /**
+ * Adds the title to {@link TitleContainer} and {@link #playNotificationSound() plays the notification sound} if the title is not in the {@link TitleContainer} already.
+ * No checking needs to be done on whether the title is in the {@link TitleContainer} already by the caller.
+ *
+ * @param title the title
+ */
public static void displayInTitleContainerAndPlaySound(Title title) {
- TitleContainer.addTitle(title);
- playNotificationSound();
+ if (TitleContainer.addTitle(title)) {
+ playNotificationSound();
+ }
}
- public static void displayInTitleContainerWDismissAndPlaySound(Title title, int ticks) {
- TitleContainer.addTitleWithDismiss(title, ticks);
- playNotificationSound();
+ /**
+ * Adds the title to {@link TitleContainer} for a set number of ticks and {@link #playNotificationSound() plays the notification sound} if the title is not in the {@link TitleContainer} already.
+ * No checking needs to be done on whether the title is in the {@link TitleContainer} already by the caller.
+ *
+ * @param title the title
+ * @param ticks the number of ticks the title will remain
+ */
+ public static void displayInTitleContainerAndPlaySound(Title title, int ticks) {
+ if (TitleContainer.addTitle(title, ticks)) {
+ playNotificationSound();
+ }
}
private static void playNotificationSound() {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java
index 021621408a..7b19e2843e 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java
@@ -1,10 +1,13 @@
package me.xmrvizzy.skyblocker.utils;
import me.xmrvizzy.skyblocker.SkyblockerMod;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.screen.Screen;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.PriorityQueue;
+import java.util.function.Supplier;
/**
* A scheduler for running tasks at a later time. Tasks will be run synchronously on the main client thread. Use the instance stored in {@link SkyblockerMod#scheduler}. Do not instantiate this class.
@@ -50,6 +53,24 @@ public void scheduleCyclic(Runnable task, int period) {
}
}
+ /**
+ * Schedules a screen to open in the next tick. Used in commands to avoid screen immediately closing after the command is executed.
+ *
+ * @param screenSupplier the supplier of the screen to open
+ */
+ public void queueOpenScreen(Supplier screenSupplier) {
+ queueOpenScreen(screenSupplier.get());
+ }
+
+ /**
+ * Schedules a screen to open in the next tick. Used in commands to avoid screen immediately closing after the command is executed.
+ *
+ * @param screen the supplier of the screen to open
+ */
+ public void queueOpenScreen(Screen screen) {
+ MinecraftClient.getInstance().send(() -> MinecraftClient.getInstance().setScreen(screen));
+ }
+
public void tick() {
currentTick += 1;
ScheduledTask task;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
index d1977470ab..ac06eb3674 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
@@ -1,14 +1,31 @@
package me.xmrvizzy.skyblocker.utils.title;
+import net.minecraft.text.MutableText;
+import net.minecraft.text.Text;
+import net.minecraft.util.Formatting;
+
public class Title {
- public String text = "";
- public boolean active = true;
- public int color;
- public float lastX = 0;
- public float lastY = 0;
+ private MutableText text;
+ protected float lastX = 0;
+ protected float lastY = 0;
+
+ public MutableText getText() {
+ return text;
+ }
+
+ public void setText(MutableText text) {
+ this.text = text;
+ }
+
+ public void setFormatting(Formatting formatting) {
+ this.text.formatted(formatting);
+ }
+
+ public Title(String textKey, Formatting formatting) {
+ this(Text.translatable(textKey).formatted(formatting));
+ }
- public Title(String text, int color) {
+ public Title(MutableText text) {
this.text = text;
- this.color = color;
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
index 14db8d6e6b..c4908a7397 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -1,8 +1,8 @@
package me.xmrvizzy.skyblocker.utils.title;
+import com.mojang.brigadier.Command;
import me.xmrvizzy.skyblocker.SkyblockerMod;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
-import me.xmrvizzy.skyblocker.skyblock.dwarven.DwarvenHudConfigScreen;
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;
@@ -12,55 +12,99 @@
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashSet;
+import java.util.Set;
public class TitleContainer {
- public static final MinecraftClient client = MinecraftClient.getInstance();
- public static List titles = new ArrayList<>();
+ /**
+ * The set of titles which will be rendered.
+ *
+ * @see #containsTitle(Title)
+ * @see #addTitle(Title)
+ * @see #addTitle(Title, int)
+ * @see #removeTitle(Title)
+ */
+ private static final Set titles = new LinkedHashSet<>();
public static void init() {
- HudRenderCallback.EVENT.register(TitleContainer::draw);
+ HudRenderCallback.EVENT.register(TitleContainer::render);
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("skyblocker")
.then(ClientCommandManager.literal("hud")
.then(ClientCommandManager.literal("titleContainer")
.executes(context -> {
- client.send(() -> client.setScreen(new TitleContainerConfigScreen(Text.of("Title Container HUD Config"))));
- return 1;
+ SkyblockerMod.getInstance().scheduler.queueOpenScreen(new TitleContainerConfigScreen(Text.of("Title Container HUD Config")));
+ return Command.SINGLE_SUCCESS;
})))));
}
- public static void addTitle(Title title) {
- title.active = true;
- title.lastX = 0;
- title.lastY = SkyblockerConfig.get().general.titleContainer.y;
- titles.add(title);
+
+ /**
+ * Returns {@code true} if the title is currently shown.
+ *
+ * @param title the title to check
+ * @return whether the title in currently shown
+ */
+ public static boolean containsTitle(Title title) {
+ return titles.contains(title);
}
- public static void addTitleWithDismiss(Title title, int ticks) {
- addTitle(title);
- SkyblockerMod.getInstance().scheduler.schedule(() -> {
- title.active = false;
- }, ticks);
+
+ /**
+ * Adds a title to be shown
+ *
+ * @param title the title to be shown
+ * @return whether the title is already currently being shown
+ */
+ public static boolean addTitle(Title title) {
+ if (titles.add(title)) {
+ title.lastX = 0;
+ title.lastY = SkyblockerConfig.get().general.titleContainer.y;
+ return true;
+ }
+ return false;
}
- public static void draw(DrawContext context, float tickDelta) {
- draw(titles, SkyblockerConfig.get().general.titleContainer.x, SkyblockerConfig.get().general.titleContainer.y, context, tickDelta, false);
+
+ /**
+ * Adds a title to be shown for a set number of ticks
+ *
+ * @param title the title to be shown
+ * @param ticks the number of ticks to show the title
+ * @return whether the title is already currently being shown
+ */
+ public static boolean addTitle(Title title, int ticks) {
+ if (addTitle(title)) {
+ SkyblockerMod.getInstance().scheduler.schedule(() -> TitleContainer.removeTitle(title), ticks);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Stops showing a title
+ *
+ * @param title the title to stop showing
+ */
+ public static void removeTitle(Title title) {
+ titles.remove(title);
}
- public static void draw(List titlesToDraw, int xPos, int yPos, DrawContext context, float tickDelta, boolean example) {
+
+ private static void render(DrawContext context, float tickDelta) {
+ render(context, titles, SkyblockerConfig.get().general.titleContainer.x, SkyblockerConfig.get().general.titleContainer.y, tickDelta);
+ }
+
+ protected static void render(DrawContext context, Set titles, int xPos, int yPos, float tickDelta) {
var client = MinecraftClient.getInstance();
TextRenderer textRenderer = client.textRenderer;
- List toRemove = new ArrayList<>();
-
float scale = 3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F);
- var direction = SkyblockerConfig.get().general.titleContainer.direction;
- var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
+ SkyblockerConfig.Direction direction = SkyblockerConfig.get().general.titleContainer.direction;
+ SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment;
float x = 0;
float y;
float width = 0;
- for (Title title : titlesToDraw) {
- width += textRenderer.getWidth(title.text) * scale + 10;
+ for (Title title : titles) {
+ width += textRenderer.getWidth(title.getText()) * scale + 10;
}
- if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ if (direction == SkyblockerConfig.Direction.HORIZONTAL) {
if (alignment == SkyblockerConfig.Alignment.MIDDLE) {
x = xPos - (width / 2);
}
@@ -69,51 +113,45 @@ public static void draw(List titlesToDraw, int xPos, int yPos, DrawContex
x = xPos;
}
}
- if(alignment == SkyblockerConfig.Alignment.LEFT || alignment == SkyblockerConfig.Alignment.RIGHT) {
+ if (alignment == SkyblockerConfig.Alignment.LEFT || alignment == SkyblockerConfig.Alignment.RIGHT) {
x = xPos;
}
y = yPos;
- for (Title title : titlesToDraw) {
+ for (Title title : titles) {
context.getMatrices().push();
context.getMatrices().translate(title.lastX, title.lastY, 200);
context.getMatrices().scale(scale, scale, scale);
- float xToUse = 0;
- if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ float xToUse;
+ if (direction == SkyblockerConfig.Direction.HORIZONTAL) {
xToUse = alignment == SkyblockerConfig.Alignment.RIGHT ?
- x - (textRenderer.getWidth(title.text) * scale) :
+ x - (textRenderer.getWidth(title.getText()) * scale) :
x;
} else {
xToUse = alignment == SkyblockerConfig.Alignment.MIDDLE ?
- x - (textRenderer.getWidth(title.text) * scale) / 2 :
+ x - (textRenderer.getWidth(title.getText()) * scale) / 2 :
alignment == SkyblockerConfig.Alignment.RIGHT ?
- x - (textRenderer.getWidth(title.text) * scale) :
+ x - (textRenderer.getWidth(title.getText()) * scale) :
x;
}
title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, xToUse);
title.lastY = MathHelper.lerp(tickDelta * 0.5F, title.lastY, y);
- if(direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ if (direction == SkyblockerConfig.Direction.HORIZONTAL) {
if (alignment == SkyblockerConfig.Alignment.MIDDLE || alignment == SkyblockerConfig.Alignment.LEFT) {
- x += textRenderer.getWidth(title.text) * scale + 10;
+ x += textRenderer.getWidth(title.getText()) * scale + 10;
}
if (alignment == SkyblockerConfig.Alignment.RIGHT) {
- x -= textRenderer.getWidth(title.text) * scale + 10;
+ x -= textRenderer.getWidth(title.getText()) * scale + 10;
}
} else {
y += textRenderer.fontHeight * scale + 10;
}
- context.drawText(textRenderer, title.text, 0, 0, title.color, true);
+ context.drawTextWithShadow(textRenderer, title.getText(), 0, 0, 0xFFFFFF);
context.getMatrices().pop();
- if (!title.active && !example) {
- toRemove.add(title);
- }
- }
- if (!example) {
- titlesToDraw.removeAll(toRemove);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
index a035f86258..b4f3093f70 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -2,29 +2,26 @@
import me.shedaniel.autoconfig.AutoConfig;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
-import me.xmrvizzy.skyblocker.skyblock.dwarven.DwarvenHud;
import me.xmrvizzy.skyblocker.utils.RenderUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.input.KeyCodes;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
-import net.minecraft.util.math.Box;
-import org.joml.Vector4i;
+import net.minecraft.util.Pair;
+import org.joml.Vector2i;
import org.lwjgl.glfw.GLFW;
import java.awt.*;
-import java.awt.event.KeyEvent;
-import java.util.List;
+import java.util.Set;
public class TitleContainerConfigScreen extends Screen {
-
- private final Title example1 = new Title("Test1", Formatting.RED.getColorValue());
- private final Title example2 = new Title("Test23", Formatting.AQUA.getColorValue());
- private final Title example3 = new Title("Testing1234", Formatting.DARK_GREEN.getColorValue());
+ private final Title example1 = new Title(Text.literal("Test1").formatted(Formatting.RED));
+ private final Title example2 = new Title(Text.literal("Test23").formatted(Formatting.AQUA));
+ private final Title example3 = new Title(Text.literal("Testing1234").formatted(Formatting.DARK_GREEN));
private int hudX = SkyblockerConfig.get().general.titleContainer.x;
private int hudY = SkyblockerConfig.get().general.titleContainer.y;
+
protected TitleContainerConfigScreen(Text title) {
super(title);
}
@@ -33,25 +30,18 @@ protected TitleContainerConfigScreen(Text title) {
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
renderBackground(context);
- TitleContainer.draw(List.of(example1, example2, example3), hudX, hudY, context, delta, true);
- context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB());
- var direction = SkyblockerConfig.get().general.titleContainer.direction;
- var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
- int width1 = client.textRenderer.getWidth("Press Q/E to change Alignment: " + alignment.toString());
- int width2 = client.textRenderer.getWidth("Press R to change Direction: " + direction.toString());
- context.drawText(client.textRenderer, "Press Q/E to change Alignment: " + alignment.toString(), (width / 2) - width1 / 2, client.textRenderer.fontHeight * 2, Color.WHITE.getRGB(), true);
- context.drawText(client.textRenderer, "Press R to change Direction: " + direction.toString(), (width / 2) - width2 / 2, client.textRenderer.fontHeight * 3 + 5, Color.WHITE.getRGB(), true);
-
- int x1;
- int x2;
- int y1;
- int y2;
-
- var vec = getSelectionBounding();
- x1 = vec.x;
- x2 = vec.y;
- y1 = vec.z;
- y2 = vec.w;
+ TitleContainer.render(context, Set.of(example1, example2, example3), hudX, hudY, delta);
+ SkyblockerConfig.Direction direction = SkyblockerConfig.get().general.titleContainer.direction;
+ SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment;
+ context.drawCenteredTextWithShadow(client.textRenderer, "Press Q/E to change Alignment: " + alignment, width / 2, client.textRenderer.fontHeight * 2, Color.WHITE.getRGB());
+ context.drawCenteredTextWithShadow(client.textRenderer, "Press R to change Direction: " + direction, width / 2, client.textRenderer.fontHeight * 3 + 5, Color.WHITE.getRGB());
+ context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, client.textRenderer.fontHeight * 4 + 10, Color.GRAY.getRGB());
+
+ Pair boundingBox = getSelectionBoundingBox();
+ int x1 = boundingBox.getLeft().x;
+ int y1 = boundingBox.getLeft().y;
+ int x2 = boundingBox.getRight().x;
+ int y2 = boundingBox.getRight().y;
context.drawHorizontalLine(x1, x2, y1, Color.RED.getRGB());
context.drawHorizontalLine(x1, x2, y2, Color.RED.getRGB());
@@ -59,46 +49,39 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
context.drawVerticalLine(x2, y1, y2, Color.RED.getRGB());
}
- public Vector4i getSelectionBounding()
- {
- var direction = SkyblockerConfig.get().general.titleContainer.direction;
- var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
+ public Pair getSelectionBoundingBox() {
+ SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment;
int midWidth = getSelectionWidth() / 2;
- int midHeight = getSelectionHeight() / 2;
int x1 = 0;
int x2 = 0;
- int y1 = 0;
- int y2 = 0;
- y1 = hudY;
- y2 = hudY + midHeight * 2;
+ int y1 = hudY;
+ int y2 = hudY + getSelectionHeight();
switch (alignment) {
- case RIGHT:
+ case RIGHT -> {
x1 = hudX - midWidth * 2;
x2 = hudX;
- break;
- case MIDDLE:
+ }
+ case MIDDLE -> {
x1 = hudX - midWidth;
x2 = hudX + midWidth;
- break;
- case LEFT:
+ }
+ case LEFT -> {
x1 = hudX;
x2 = hudX + midWidth * 2;
- break;
+ }
}
- return new Vector4i(x1, x2, y1, y2);
+ return new Pair<>(new Vector2i(x1, y1), new Vector2i(x2, y2));
}
- public int getSelectionHeight()
- {
+ public int getSelectionHeight() {
int scale = (int) (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ?
textRenderer.fontHeight * scale :
(textRenderer.fontHeight + 10) * 3 * scale;
}
- public int getSelectionWidth()
- {
+ public int getSelectionWidth() {
int scale = (int) (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ?
(textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale :
@@ -111,16 +94,11 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
int midHeight = getSelectionHeight() / 2;
var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
- int x1;
- int x2;
- int y1;
- int y2;
-
- var vec = getSelectionBounding();
- x1 = vec.x;
- x2 = vec.y;
- y1 = vec.z;
- y2 = vec.w;
+ Pair boundingBox = getSelectionBoundingBox();
+ int x1 = boundingBox.getLeft().x;
+ int y1 = boundingBox.getLeft().y;
+ int x2 = boundingBox.getRight().x;
+ int y2 = boundingBox.getRight().y;
if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, x1, y1, x2, y2) && button == 0) {
hudX = alignment == SkyblockerConfig.Alignment.RIGHT ?
@@ -135,31 +113,31 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 1) {
hudX = this.width / 2;
- hudY = (int) (this.height * 0.6F);
+ hudY = this.height / 2;
}
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
- if(keyCode == GLFW.GLFW_KEY_Q) {
- var current = SkyblockerConfig.get().general.titleContainer.alignment;
+ if (keyCode == GLFW.GLFW_KEY_Q) {
+ SkyblockerConfig.Alignment current = SkyblockerConfig.get().general.titleContainer.alignment;
SkyblockerConfig.get().general.titleContainer.alignment = switch (current) {
case LEFT -> SkyblockerConfig.Alignment.MIDDLE;
case MIDDLE -> SkyblockerConfig.Alignment.RIGHT;
case RIGHT -> SkyblockerConfig.Alignment.LEFT;
};
}
- if(keyCode == GLFW.GLFW_KEY_E) {
- var current = SkyblockerConfig.get().general.titleContainer.alignment;
+ if (keyCode == GLFW.GLFW_KEY_E) {
+ SkyblockerConfig.Alignment current = SkyblockerConfig.get().general.titleContainer.alignment;
SkyblockerConfig.get().general.titleContainer.alignment = switch (current) {
case LEFT -> SkyblockerConfig.Alignment.RIGHT;
case MIDDLE -> SkyblockerConfig.Alignment.LEFT;
case RIGHT -> SkyblockerConfig.Alignment.MIDDLE;
};
}
- if(keyCode == GLFW.GLFW_KEY_R) {
- var current = SkyblockerConfig.get().general.titleContainer.direction;
+ if (keyCode == GLFW.GLFW_KEY_R) {
+ SkyblockerConfig.Direction current = SkyblockerConfig.get().general.titleContainer.direction;
SkyblockerConfig.get().general.titleContainer.direction = switch (current) {
case HORIZONTAL -> SkyblockerConfig.Direction.VERTICAL;
case VERTICAL -> SkyblockerConfig.Direction.HORIZONTAL;
From 28dde248aae76db0f82df54e7757292ecb5693ea Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Sat, 8 Jul 2023 09:33:18 -0400
Subject: [PATCH 12/17] Make Some more changes
Add +/- to change scale
Mouse now properly goes to center for text box
Added comments to rendering code
---
.../utils/title/TitleContainer.java | 34 +++++++++++++------
.../title/TitleContainerConfigScreen.java | 22 ++++++++----
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
index c4908a7397..10b2553a42 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -94,62 +94,76 @@ protected static void render(DrawContext context, Set titles, int xPos, i
var client = MinecraftClient.getInstance();
TextRenderer textRenderer = client.textRenderer;
+ // Calculate Scale to use
float scale = 3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F);
+ // Grab direction and alignment values
SkyblockerConfig.Direction direction = SkyblockerConfig.get().general.titleContainer.direction;
SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment;
+ // x/y refer to the starting position for the text
+ // y always starts at yPos
float x = 0;
- float y;
+ float y = yPos;
+
+ //Calculate the width of combined text
float width = 0;
for (Title title : titles) {
width += textRenderer.getWidth(title.getText()) * scale + 10;
}
- if (direction == SkyblockerConfig.Direction.HORIZONTAL) {
- if (alignment == SkyblockerConfig.Alignment.MIDDLE) {
+
+ if (alignment == SkyblockerConfig.Alignment.MIDDLE) {
+ if (direction == SkyblockerConfig.Direction.HORIZONTAL) {
+ //If middle aligned horizontally, start the xPosition at half of the width to the left.
x = xPos - (width / 2);
- }
- } else {
- if (alignment == SkyblockerConfig.Alignment.MIDDLE) {
+ } else {
+ //If middle aligned vertically, start at xPos, we will shift each text to the left later
x = xPos;
}
}
if (alignment == SkyblockerConfig.Alignment.LEFT || alignment == SkyblockerConfig.Alignment.RIGHT) {
+ //If left or right aligned, start at xPos, we will shift each text later
x = xPos;
}
- y = yPos;
for (Title title : titles) {
+ //Translate the matrix to the texts position and scale
context.getMatrices().push();
context.getMatrices().translate(title.lastX, title.lastY, 200);
context.getMatrices().scale(scale, scale, scale);
+ //Calculate which x the text should use
float xToUse;
if (direction == SkyblockerConfig.Direction.HORIZONTAL) {
xToUse = alignment == SkyblockerConfig.Alignment.RIGHT ?
- x - (textRenderer.getWidth(title.getText()) * scale) :
+ x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side.
x;
} else {
xToUse = alignment == SkyblockerConfig.Alignment.MIDDLE ?
- x - (textRenderer.getWidth(title.getText()) * scale) / 2 :
+ x - (textRenderer.getWidth(title.getText()) * scale) / 2 : //if middle aligned we need the text position to be aligned in the middle.
alignment == SkyblockerConfig.Alignment.RIGHT ?
- x - (textRenderer.getWidth(title.getText()) * scale) :
+ x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side.
x;
}
+ //Lerp the texts x and y variables
title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, xToUse);
title.lastY = MathHelper.lerp(tickDelta * 0.5F, title.lastY, y);
if (direction == SkyblockerConfig.Direction.HORIZONTAL) {
if (alignment == SkyblockerConfig.Alignment.MIDDLE || alignment == SkyblockerConfig.Alignment.LEFT) {
+ //Move to the right if middle or left aligned
x += textRenderer.getWidth(title.getText()) * scale + 10;
}
if (alignment == SkyblockerConfig.Alignment.RIGHT) {
+ //Move to the left if right aligned
x -= textRenderer.getWidth(title.getText()) * scale + 10;
}
} else {
+ //Y always moves by the same amount if vertical
y += textRenderer.fontHeight * scale + 10;
}
+ //Draw text
context.drawTextWithShadow(textRenderer, title.getText(), 0, 0, 0xFFFFFF);
context.getMatrices().pop();
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
index b4f3093f70..be5cc58d19 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -14,6 +14,7 @@
import java.awt.*;
import java.util.Set;
+import java.util.stream.Collectors;
public class TitleContainerConfigScreen extends Screen {
private final Title example1 = new Title(Text.literal("Test1").formatted(Formatting.RED));
@@ -33,9 +34,10 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
TitleContainer.render(context, Set.of(example1, example2, example3), hudX, hudY, delta);
SkyblockerConfig.Direction direction = SkyblockerConfig.get().general.titleContainer.direction;
SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment;
- context.drawCenteredTextWithShadow(client.textRenderer, "Press Q/E to change Alignment: " + alignment, width / 2, client.textRenderer.fontHeight * 2, Color.WHITE.getRGB());
- context.drawCenteredTextWithShadow(client.textRenderer, "Press R to change Direction: " + direction, width / 2, client.textRenderer.fontHeight * 3 + 5, Color.WHITE.getRGB());
- context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, client.textRenderer.fontHeight * 4 + 10, Color.GRAY.getRGB());
+ context.drawCenteredTextWithShadow(textRenderer, "Press Q/E to change Alignment: " + alignment, width / 2, textRenderer.fontHeight * 2, Color.WHITE.getRGB());
+ context.drawCenteredTextWithShadow(textRenderer, "Press R to change Direction: " + direction, width / 2, textRenderer.fontHeight * 3 + 5, Color.WHITE.getRGB());
+ context.drawCenteredTextWithShadow(textRenderer, "Press +/- to change Scale", width / 2, textRenderer.fontHeight * 4 + 10, Color.WHITE.getRGB());
+ context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, textRenderer.fontHeight * 5 + 15, Color.GRAY.getRGB());
Pair boundingBox = getSelectionBoundingBox();
int x1 = boundingBox.getLeft().x;
@@ -101,9 +103,11 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
int y2 = boundingBox.getRight().y;
if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, x1, y1, x2, y2) && button == 0) {
- hudX = alignment == SkyblockerConfig.Alignment.RIGHT ?
- (int) mouseX + midWidth :
- (int) mouseX - (midWidth / 2);
+ hudX = switch (alignment) {
+ case LEFT ->(int) mouseX - midWidth;
+ case MIDDLE -> (int) mouseX;
+ case RIGHT -> (int) mouseX + midWidth;
+ };
hudY = (int) mouseY - (midHeight);
}
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
@@ -143,6 +147,12 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
case VERTICAL -> SkyblockerConfig.Direction.HORIZONTAL;
};
}
+ if (keyCode == GLFW.GLFW_KEY_EQUAL) {
+ SkyblockerConfig.get().general.titleContainer.titleContainerScale += 10;
+ }
+ if (keyCode == GLFW.GLFW_KEY_MINUS) {
+ SkyblockerConfig.get().general.titleContainer.titleContainerScale -= 10;
+ }
return super.keyPressed(keyCode, scanCode, modifiers);
}
From c2d1d4d98bad10860629b00de89134a7cf590e06 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Sat, 8 Jul 2023 09:45:20 -0400
Subject: [PATCH 13/17] Fix scaling issues
---
.../title/TitleContainerConfigScreen.java | 65 ++++++++++---------
1 file changed, 33 insertions(+), 32 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
index be5cc58d19..08a902ab96 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -6,6 +6,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.util.math.Vector2f;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Pair;
@@ -20,8 +21,8 @@ public class TitleContainerConfigScreen extends Screen {
private final Title example1 = new Title(Text.literal("Test1").formatted(Formatting.RED));
private final Title example2 = new Title(Text.literal("Test23").formatted(Formatting.AQUA));
private final Title example3 = new Title(Text.literal("Testing1234").formatted(Formatting.DARK_GREEN));
- private int hudX = SkyblockerConfig.get().general.titleContainer.x;
- private int hudY = SkyblockerConfig.get().general.titleContainer.y;
+ private float hudX = SkyblockerConfig.get().general.titleContainer.x;
+ private float hudY = SkyblockerConfig.get().general.titleContainer.y;
protected TitleContainerConfigScreen(Text title) {
super(title);
@@ -31,7 +32,7 @@ protected TitleContainerConfigScreen(Text title) {
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
renderBackground(context);
- TitleContainer.render(context, Set.of(example1, example2, example3), hudX, hudY, delta);
+ TitleContainer.render(context, Set.of(example1, example2, example3), (int) hudX, (int) hudY, delta);
SkyblockerConfig.Direction direction = SkyblockerConfig.get().general.titleContainer.direction;
SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment;
context.drawCenteredTextWithShadow(textRenderer, "Press Q/E to change Alignment: " + alignment, width / 2, textRenderer.fontHeight * 2, Color.WHITE.getRGB());
@@ -39,11 +40,11 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
context.drawCenteredTextWithShadow(textRenderer, "Press +/- to change Scale", width / 2, textRenderer.fontHeight * 4 + 10, Color.WHITE.getRGB());
context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, textRenderer.fontHeight * 5 + 15, Color.GRAY.getRGB());
- Pair boundingBox = getSelectionBoundingBox();
- int x1 = boundingBox.getLeft().x;
- int y1 = boundingBox.getLeft().y;
- int x2 = boundingBox.getRight().x;
- int y2 = boundingBox.getRight().y;
+ Pair boundingBox = getSelectionBoundingBox();
+ int x1 = (int) boundingBox.getLeft().getX();
+ int y1 = (int) boundingBox.getLeft().getY();
+ int x2 = (int) boundingBox.getRight().getX();
+ int y2 = (int) boundingBox.getRight().getY();
context.drawHorizontalLine(x1, x2, y1, Color.RED.getRGB());
context.drawHorizontalLine(x1, x2, y2, Color.RED.getRGB());
@@ -51,14 +52,14 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
context.drawVerticalLine(x2, y1, y2, Color.RED.getRGB());
}
- public Pair getSelectionBoundingBox() {
+ public Pair getSelectionBoundingBox() {
SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment;
- int midWidth = getSelectionWidth() / 2;
- int x1 = 0;
- int x2 = 0;
- int y1 = hudY;
- int y2 = hudY + getSelectionHeight();
+ float midWidth = getSelectionWidth() / 2F;
+ float x1 = 0;
+ float x2 = 0;
+ float y1 = hudY;
+ float y2 = hudY + getSelectionHeight();
switch (alignment) {
case RIGHT -> {
x1 = hudX - midWidth * 2;
@@ -73,18 +74,18 @@ public Pair getSelectionBoundingBox() {
x2 = hudX + midWidth * 2;
}
}
- return new Pair<>(new Vector2i(x1, y1), new Vector2i(x2, y2));
+ return new Pair<>(new Vector2f(x1, y1), new Vector2f(x2, y2));
}
- public int getSelectionHeight() {
- int scale = (int) (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
+ public float getSelectionHeight() {
+ float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ?
- textRenderer.fontHeight * scale :
- (textRenderer.fontHeight + 10) * 3 * scale;
+ (textRenderer.fontHeight * scale) :
+ (textRenderer.fontHeight + 10F) * 3F * scale;
}
- public int getSelectionWidth() {
- int scale = (int) (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
+ public float getSelectionWidth() {
+ float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ?
(textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale :
textRenderer.getWidth("Testing1234") * scale;
@@ -92,23 +93,23 @@ public int getSelectionWidth() {
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
- int midWidth = getSelectionWidth() / 2;
- int midHeight = getSelectionHeight() / 2;
+ float midWidth = getSelectionWidth() / 2;
+ float midHeight = getSelectionHeight() / 2;
var alignment = SkyblockerConfig.get().general.titleContainer.alignment;
- Pair boundingBox = getSelectionBoundingBox();
- int x1 = boundingBox.getLeft().x;
- int y1 = boundingBox.getLeft().y;
- int x2 = boundingBox.getRight().x;
- int y2 = boundingBox.getRight().y;
+ Pair boundingBox = getSelectionBoundingBox();
+ float x1 = boundingBox.getLeft().getX();
+ float y1 = boundingBox.getLeft().getY();
+ float x2 = boundingBox.getRight().getX();
+ float y2 = boundingBox.getRight().getY();
- if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, x1, y1, x2, y2) && button == 0) {
+ if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, (int) x1, (int) y1, (int) x2, (int) y2) && button == 0) {
hudX = switch (alignment) {
case LEFT ->(int) mouseX - midWidth;
case MIDDLE -> (int) mouseX;
case RIGHT -> (int) mouseX + midWidth;
};
- hudY = (int) mouseY - (midHeight);
+ hudY = (int) (mouseY - midHeight);
}
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}
@@ -158,8 +159,8 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
@Override
public void close() {
- SkyblockerConfig.get().general.titleContainer.x = hudX;
- SkyblockerConfig.get().general.titleContainer.y = hudY;
+ SkyblockerConfig.get().general.titleContainer.x = (int) hudX;
+ SkyblockerConfig.get().general.titleContainer.y = (int) hudY;
AutoConfig.getConfigHolder(SkyblockerConfig.class).save();
super.close();
}
From f2fb1c3d1152efc3cc4741f02fd42dce836bcbb1 Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Sat, 8 Jul 2023 13:53:26 -0400
Subject: [PATCH 14/17] Move to default y position back to 60%
---
.../skyblocker/utils/title/TitleContainerConfigScreen.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
index 08a902ab96..23df1f6c47 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -118,7 +118,7 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 1) {
hudX = this.width / 2;
- hudY = this.height / 2;
+ hudY = this.height * 0.6F;
}
return super.mouseClicked(mouseX, mouseY, button);
}
From 85e5615bac19cf70d00653355f1e01e7d1849f37 Mon Sep 17 00:00:00 2001
From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Date: Sun, 9 Jul 2023 10:01:51 +0800
Subject: [PATCH 15/17] Refactor Title
---
.../skyblocker/utils/title/Title.java | 33 ++++++++++++++-----
.../title/TitleContainerConfigScreen.java | 13 +++-----
2 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
index ac06eb3674..7dfef3d952 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
@@ -4,11 +4,36 @@
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
+/**
+ * Represents a title used for {@link TitleContainer}.
+ *
+ * @see TitleContainer
+ */
public class Title {
private MutableText text;
protected float lastX = 0;
protected float lastY = 0;
+ /**
+ * Constructs a new title with the given translation key and formatting to be applied.
+ *
+ * @param textKey the translation key
+ * @param formatting the formatting to be applied to the text
+ */
+ public Title(String textKey, Formatting formatting) {
+ this(Text.translatable(textKey).formatted(formatting));
+ }
+
+ /**
+ * Constructs a new title with the given {@link MutableText}.
+ * Use {@link Text#literal(String)} or {@link Text#translatable(String)} to create a {@link MutableText}
+ *
+ * @param text the mutable text
+ */
+ public Title(MutableText text) {
+ this.text = text;
+ }
+
public MutableText getText() {
return text;
}
@@ -20,12 +45,4 @@ public void setText(MutableText text) {
public void setFormatting(Formatting formatting) {
this.text.formatted(formatting);
}
-
- public Title(String textKey, Formatting formatting) {
- this(Text.translatable(textKey).formatted(formatting));
- }
-
- public Title(MutableText text) {
- this.text = text;
- }
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
index 23df1f6c47..e729ea15c1 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java
@@ -3,19 +3,16 @@
import me.shedaniel.autoconfig.AutoConfig;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.utils.RenderUtils;
-import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.Vector2f;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Pair;
-import org.joml.Vector2i;
import org.lwjgl.glfw.GLFW;
import java.awt.*;
import java.util.Set;
-import java.util.stream.Collectors;
public class TitleContainerConfigScreen extends Screen {
private final Title example1 = new Title(Text.literal("Test1").formatted(Formatting.RED));
@@ -52,7 +49,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
context.drawVerticalLine(x2, y1, y2, Color.RED.getRGB());
}
- public Pair getSelectionBoundingBox() {
+ private Pair getSelectionBoundingBox() {
SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment;
float midWidth = getSelectionWidth() / 2F;
@@ -77,14 +74,14 @@ public Pair getSelectionBoundingBox() {
return new Pair<>(new Vector2f(x1, y1), new Vector2f(x2, y2));
}
- public float getSelectionHeight() {
+ private float getSelectionHeight() {
float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ?
(textRenderer.fontHeight * scale) :
(textRenderer.fontHeight + 10F) * 3F * scale;
}
- public float getSelectionWidth() {
+ private float getSelectionWidth() {
float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F));
return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ?
(textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale :
@@ -105,7 +102,7 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, (int) x1, (int) y1, (int) x2, (int) y2) && button == 0) {
hudX = switch (alignment) {
- case LEFT ->(int) mouseX - midWidth;
+ case LEFT -> (int) mouseX - midWidth;
case MIDDLE -> (int) mouseX;
case RIGHT -> (int) mouseX + midWidth;
};
@@ -117,7 +114,7 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 1) {
- hudX = this.width / 2;
+ hudX = (float) this.width / 2;
hudY = this.height * 0.6F;
}
return super.mouseClicked(mouseX, mouseY, button);
From 675913a65470a228eead892a2b1d58a4e2f253f5 Mon Sep 17 00:00:00 2001
From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Date: Sun, 9 Jul 2023 10:49:52 +0800
Subject: [PATCH 16/17] Update Title Container rendering
---
.../skyblocker/utils/title/Title.java | 13 ++++++--
.../utils/title/TitleContainer.java | 32 ++++++++++++-------
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
index 7dfef3d952..4f6b2fb41f 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
@@ -11,8 +11,8 @@
*/
public class Title {
private MutableText text;
- protected float lastX = 0;
- protected float lastY = 0;
+ protected float x = -1;
+ protected float y = -1;
/**
* Constructs a new title with the given translation key and formatting to be applied.
@@ -45,4 +45,13 @@ public void setText(MutableText text) {
public void setFormatting(Formatting formatting) {
this.text.formatted(formatting);
}
+
+ protected boolean isDefaultPos() {
+ return x == -1 && y == -1;
+ }
+
+ protected void resetPos() {
+ this.x = -1;
+ this.y = -1;
+ }
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
index 10b2553a42..a4e445ee1b 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainer.java
@@ -55,8 +55,7 @@ public static boolean containsTitle(Title title) {
*/
public static boolean addTitle(Title title) {
if (titles.add(title)) {
- title.lastX = 0;
- title.lastY = SkyblockerConfig.get().general.titleContainer.y;
+ title.resetPos();
return true;
}
return false;
@@ -126,10 +125,6 @@ protected static void render(DrawContext context, Set titles, int xPos, i
}
for (Title title : titles) {
- //Translate the matrix to the texts position and scale
- context.getMatrices().push();
- context.getMatrices().translate(title.lastX, title.lastY, 200);
- context.getMatrices().scale(scale, scale, scale);
//Calculate which x the text should use
float xToUse;
@@ -144,10 +139,27 @@ protected static void render(DrawContext context, Set titles, int xPos, i
x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side.
x;
}
+
+ //Start displaying the title at the correct position, not at the default position
+ if (title.isDefaultPos()) {
+ title.x = xToUse;
+ title.y = y;
+ }
+
//Lerp the texts x and y variables
- title.lastX = MathHelper.lerp(tickDelta * 0.5F, title.lastX, xToUse);
- title.lastY = MathHelper.lerp(tickDelta * 0.5F, title.lastY, y);
+ title.x = MathHelper.lerp(tickDelta * 0.5F, title.x, xToUse);
+ title.y = MathHelper.lerp(tickDelta * 0.5F, title.y, y);
+
+ //Translate the matrix to the texts position and scale
+ context.getMatrices().push();
+ context.getMatrices().translate(title.x, title.y, 200);
+ context.getMatrices().scale(scale, scale, scale);
+
+ //Draw text
+ context.drawTextWithShadow(textRenderer, title.getText(), 0, 0, 0xFFFFFF);
+ context.getMatrices().pop();
+ //Calculate the x and y positions for the next title
if (direction == SkyblockerConfig.Direction.HORIZONTAL) {
if (alignment == SkyblockerConfig.Alignment.MIDDLE || alignment == SkyblockerConfig.Alignment.LEFT) {
//Move to the right if middle or left aligned
@@ -162,10 +174,6 @@ protected static void render(DrawContext context, Set titles, int xPos, i
//Y always moves by the same amount if vertical
y += textRenderer.fontHeight * scale + 10;
}
-
- //Draw text
- context.drawTextWithShadow(textRenderer, title.getText(), 0, 0, 0xFFFFFF);
- context.getMatrices().pop();
}
}
}
\ No newline at end of file
From 324248b4c44d10d3a2cf5412b4ff4beeaa5f681c Mon Sep 17 00:00:00 2001
From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
Date: Sun, 9 Jul 2023 13:38:46 -0400
Subject: [PATCH 17/17] Fix mania indicator
---
.../me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java | 3 ++-
src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java | 4 ----
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
index 4e873eedf8..38f6b01841 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/ManiaIndicator.java
@@ -9,6 +9,7 @@
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Entity;
+import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
@@ -30,7 +31,7 @@ protected static void updateMania() {
anyMania = true;
BlockPos pos = MinecraftClient.getInstance().player.getBlockPos().down();
boolean isGreen = MinecraftClient.getInstance().world.getBlockState(pos).getBlock() == Blocks.GREEN_TERRACOTTA;
- title.setFormatting(isGreen ? Formatting.GREEN : Formatting.RED);
+ title.setText(Text.translatable("skyblocker.rift.mania").formatted(isGreen ? Formatting.GREEN : Formatting.RED));
RenderHelper.displayInTitleContainerAndPlaySound(title);
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
index 4f6b2fb41f..0a3bc84558 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/Title.java
@@ -42,10 +42,6 @@ public void setText(MutableText text) {
this.text = text;
}
- public void setFormatting(Formatting formatting) {
- this.text.formatted(formatting);
- }
-
protected boolean isDefaultPos() {
return x == -1 && y == -1;
}