aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java
diff options
context:
space:
mode:
authorolim <bobq4582@gmail.com>2024-02-15 22:06:08 +0000
committerolim <bobq4582@gmail.com>2024-02-15 22:06:08 +0000
commitd27d35e4caa652bd84a2421e2d544920ce9aa5fd (patch)
tree4cf8ff9c74219f44920854e68a5a2ca5e21377f3 /src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java
parent5e325b27590920f1abcb0a6fbe8d037e1131b9df (diff)
downloadSkyblocker-d27d35e4caa652bd84a2421e2d544920ce9aa5fd.tar.gz
Skyblocker-d27d35e4caa652bd84a2421e2d544920ce9aa5fd.tar.bz2
Skyblocker-d27d35e4caa652bd84a2421e2d544920ce9aa5fd.zip
added annoucments
added the announcement output option for the chat rules
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java
new file mode 100644
index 00000000..e6300808
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java
@@ -0,0 +1,53 @@
+package de.hysky.skyblocker.skyblock.chat;
+
+import de.hysky.skyblocker.config.SkyblockerConfigManager;
+import de.hysky.skyblocker.skyblock.dwarven.CrystalsHudConfigScreen;
+import de.hysky.skyblocker.utils.scheduler.Scheduler;
+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.gui.DrawContext;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.text.Text;
+
+public class ChatRuleAnnouncementScreen {
+
+ private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
+ private static float timer;
+
+ private static Text text = null;
+
+ public static void init() {
+ HudRenderCallback.EVENT.register((context, tickDelta) -> {
+ if (timer <= 0 || text == null) {
+ return;
+ }
+ render(context, tickDelta);
+ });
+ }
+
+ /**
+ * renders {@link ChatRuleAnnouncementScreen#text} to the middle of the top of the screen.
+ * @param context render context
+ * @param tickDelta difference from last render to remove from timer
+ */
+ private static void render(DrawContext context, float tickDelta) {
+ int scale = SkyblockerConfigManager.get().messages.chatRuleConfig.announcementScale;
+ //decrement timer
+ timer -= tickDelta;
+ //scale text up and center
+ MatrixStack matrices = context.getMatrices();
+ matrices.push();
+ matrices.translate(context.getScaledWindowWidth() / 2f, context.getScaledWindowHeight() * 0.3, 0f);
+ matrices.scale(scale, scale, 0f);
+ //render text
+ context.drawCenteredTextWithShadow(CLIENT.textRenderer,text,0, 0, 0xFFFFFF);
+
+ matrices.pop();
+ }
+ protected static void setText(Text newText) {
+ text = newText;
+ timer = SkyblockerConfigManager.get().messages.chatRuleConfig.announcementLength;
+ }
+}