From e4fe151991889a53787eccd23d7c12036cd7b3e4 Mon Sep 17 00:00:00 2001 From: Color_yr <402067010@qq.com> Date: Wed, 15 Jul 2026 23:05:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B8=B2=E6=9F=93=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../allmusic/client/CoreRenderTarget.java | 61 +++-------------- .../allmusic/client/CoreRenderTarget.java | 56 ++-------------- .../allmusic/client/CoreRenderTarget.java | 56 ++-------------- .../allmusic/client/CoreRenderTarget.java | 56 ++-------------- .../allmusic/client/CoreRenderTarget.java | 56 ++-------------- .../allmusic/client/CoreRenderTarget.java | 57 +++------------- .../allmusic/client/CoreRenderTarget.java | 56 ++-------------- .../allmusic/client/CoreRenderTarget.java | 56 ++-------------- .../allmusic/client/CoreRenderTarget.java | 61 +++-------------- .../allmusic/client/CoreRenderTarget.java | 56 ++-------------- .../allmusic/client/CoreRenderTarget.java | 62 +++--------------- .../allmusic/client/CoreRenderTarget.java | 61 +++-------------- .../allmusic/client/CoreRenderTarget.java | 59 ++--------------- .../allmusic/client/CoreRenderTarget.java | 62 +++--------------- .../allmusic/client/CoreRenderTarget.java | 59 ++--------------- .../allmusic/client/CoreRenderTarget.java | 59 ++--------------- .../allmusic/client/CoreRenderTarget.java | 59 ++--------------- .../allmusic/client/CoreRenderTarget.java | 60 +++-------------- .../allmusic/client/CoreRenderTarget.java | 59 ++--------------- .../allmusic/client/CoreRenderTarget.java | 61 +++-------------- .../allmusic/client/CoreRenderTarget.java | 59 ++--------------- .../allmusic/client/core/AllMusicHud.java | 26 ++++---- .../client/core/render/TextFrameBuffer.java | 65 ++++++++++++------- settings.gradle.kts | 18 ++--- 24 files changed, 226 insertions(+), 1114 deletions(-) diff --git a/client/fabric_1_16_5/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_1_16_5/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 79e8192a..1329f807 100644 --- a/client/fabric_1_16_5/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_1_16_5/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -11,29 +11,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.network.chat.Component; import org.lwjgl.opengl.GL11; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -41,25 +19,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -72,8 +32,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -86,7 +45,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (matrices == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -116,11 +75,10 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; PoseStack matrices = AllMusicClient.context; if (matrices == null) return; Font font = Minecraft.getInstance().font; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); drawString(font, matrices, entry, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha)); @@ -128,10 +86,10 @@ public class CoreRenderTarget extends TextFrameBuffer { @Override public Point2f getLine(int line) { - if (line >= texts.size() || line >= entries.size()) { + if (line >= texts.size()) { return new Point2f(0, 0); } - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } @@ -144,7 +102,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (matrices == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -157,7 +115,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - enableScissor(drawX, drawY, maxWidth, entry.height); enableScissor(drawX, drawY, revealWidth, entry.height); drawString(font, matrices, entry, drawX - (int) texOffset, drawY, finalColor); disableScissor(); @@ -170,7 +127,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } } - private static void drawString(Font font, PoseStack matrices, TextEntry entry, + private static void drawString(Font font, PoseStack matrices, TextItem entry, int x, int y, int color) { if (entry.shadow) { font.drawShadow(matrices, entry.component, x, y, color); diff --git a/client/fabric_1_20_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_1_20_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..f4cb9c68 100644 --- a/client/fabric_1_20_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_1_20_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +33,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +46,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +76,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +93,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +106,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +123,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/fabric_1_21/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_1_21/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..f4cb9c68 100644 --- a/client/fabric_1_21/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_1_21/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +33,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +46,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +76,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +93,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +106,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +123,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/fabric_1_21_11/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_1_21_11/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..f4cb9c68 100644 --- a/client/fabric_1_21_11/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_1_21_11/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +33,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +46,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +76,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +93,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +106,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +123,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/fabric_1_21_3/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_1_21_3/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..f4cb9c68 100644 --- a/client/fabric_1_21_3/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_1_21_3/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +33,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +46,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +76,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +93,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +106,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +123,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/fabric_1_21_4/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_1_21_4/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..04b8e62a 100644 --- a/client/fabric_1_21_4/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_1_21_4/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +33,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +46,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,15 +76,15 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); } + @Override public void drawWithState(float alpha, int x, int y, int maxWidth, float state, HudPosType dir) { if (texts.isEmpty()) { @@ -133,7 +94,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +107,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +124,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..f4cb9c68 100644 --- a/client/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +33,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +46,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +76,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +93,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +106,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +123,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/fabric_1_21_8/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_1_21_8/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..f4cb9c68 100644 --- a/client/fabric_1_21_8/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_1_21_8/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +33,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +46,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +76,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +93,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +106,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +123,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/fabric_26_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_26_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 5f3122e6..fe90072e 100644 --- a/client/fabric_26_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_26_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -94,7 +52,7 @@ public class CoreRenderTarget extends TextFrameBuffer { int finalColor = applyAlpha(entry.color, alpha); if (maxWidth != -1 && entry.width > maxWidth) { - int scrollOffset = (int) (offsetX % entry.width); + int scrollOffset = (int) getOffset(entry, maxWidth); gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.text(font, entry.component, drawX - scrollOffset, drawY, finalColor, entry.shadow); if (scrollOffset > 0) { @@ -115,10 +73,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphicsExtractor gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.text(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +90,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +103,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.text(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +120,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/fabric_26_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/fabric_26_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 5f3122e6..592ece22 100644 --- a/client/fabric_26_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/fabric_26_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +33,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +46,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +76,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphicsExtractor gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.text(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +93,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +106,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.text(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +123,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/forge_1_12_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/forge_1_12_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 0dd2be81..60202cde 100644 --- a/client/forge_1_12_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/forge_1_12_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -12,27 +12,7 @@ import org.lwjgl.opengl.GL11; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final String text; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(String text, int y, int color, boolean shadow, int width, int height) { - this.text = text; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +20,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; FontRenderer font = Minecraft.getMinecraft().fontRenderer; int width = font.getStringWidth(text); @@ -70,8 +32,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(text, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, text, shadow, color)); } @Override @@ -82,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { FontRenderer font = Minecraft.getMinecraft().fontRenderer; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -117,8 +78,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); FontRenderer font = Minecraft.getMinecraft().fontRenderer; GlStateManager.pushMatrix(); GlStateManager.translate(x, y + entry.y, 0); @@ -133,7 +93,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } FontRenderer font = Minecraft.getMinecraft().fontRenderer; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -149,7 +109,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - enableScissor(drawX, drawY, maxWidth, entry.height); enableScissor(drawX, drawY, revealWidth, entry.height); drawString(font, entry, -(int) texOffset, 0, finalColor); disableScissor(); @@ -169,16 +128,15 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } - private static void drawString(FontRenderer font, TextEntry entry, int x, int y, int color) { + private static void drawString(FontRenderer font, TextItem entry, int x, int y, int color) { if (entry.shadow) { - font.drawStringWithShadow(entry.text, x, y, color); + font.drawStringWithShadow(entry.component, x, y, color); } else { - font.drawString(entry.text, x, y, color); + font.drawString(entry.component, x, y, color); } } diff --git a/client/forge_1_16_5/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/forge_1_16_5/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 79e8192a..1329f807 100644 --- a/client/forge_1_16_5/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/forge_1_16_5/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -11,29 +11,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.network.chat.Component; import org.lwjgl.opengl.GL11; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -41,25 +19,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -72,8 +32,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -86,7 +45,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (matrices == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -116,11 +75,10 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; PoseStack matrices = AllMusicClient.context; if (matrices == null) return; Font font = Minecraft.getInstance().font; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); drawString(font, matrices, entry, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha)); @@ -128,10 +86,10 @@ public class CoreRenderTarget extends TextFrameBuffer { @Override public Point2f getLine(int line) { - if (line >= texts.size() || line >= entries.size()) { + if (line >= texts.size()) { return new Point2f(0, 0); } - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } @@ -144,7 +102,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (matrices == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -157,7 +115,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - enableScissor(drawX, drawY, maxWidth, entry.height); enableScissor(drawX, drawY, revealWidth, entry.height); drawString(font, matrices, entry, drawX - (int) texOffset, drawY, finalColor); disableScissor(); @@ -170,7 +127,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } } - private static void drawString(Font font, PoseStack matrices, TextEntry entry, + private static void drawString(Font font, PoseStack matrices, TextItem entry, int x, int y, int color) { if (entry.shadow) { font.drawShadow(matrices, entry.component, x, y, color); diff --git a/client/forge_1_20_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/forge_1_20_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..95ad14ef 100644 --- a/client/forge_1_20_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/forge_1_20_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +73,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +90,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +103,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +120,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/forge_1_7_10/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/forge_1_7_10/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 86b989cf..b4724b0b 100644 --- a/client/forge_1_7_10/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/forge_1_7_10/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -11,27 +11,7 @@ import org.lwjgl.opengl.GL11; import java.util.ArrayList; import java.util.List; -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final String text; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(String text, int y, int color, boolean shadow, int width, int height) { - this.text = text; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -39,25 +19,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; FontRenderer font = Minecraft.getMinecraft().fontRenderer; int width = font.getStringWidth(text); @@ -69,8 +31,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(text, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, text, shadow, color)); } @Override @@ -81,7 +42,7 @@ public class CoreRenderTarget extends TextFrameBuffer { FontRenderer font = Minecraft.getMinecraft().fontRenderer; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -116,8 +77,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); FontRenderer font = Minecraft.getMinecraft().fontRenderer; GL11.glPushMatrix(); GL11.glTranslatef((float) x, (float) (y + entry.y), 0); @@ -132,7 +92,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } FontRenderer font = Minecraft.getMinecraft().fontRenderer; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -148,7 +108,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - enableScissor(drawX, drawY, maxWidth, entry.height); enableScissor(drawX, drawY, revealWidth, entry.height); drawString(font, entry, -(int) texOffset, 0, finalColor); disableScissor(); @@ -168,16 +127,15 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } - private static void drawString(FontRenderer font, TextEntry entry, int x, int y, int color) { + private static void drawString(FontRenderer font, TextItem entry, int x, int y, int color) { if (entry.shadow) { - font.drawStringWithShadow(entry.text, x, y, color); + font.drawStringWithShadow(entry.component, x, y, color); } else { - font.drawString(entry.text, x, y, color); + font.drawString(entry.component, x, y, color); } } diff --git a/client/neoforge_1_21/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/neoforge_1_21/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..95ad14ef 100644 --- a/client/neoforge_1_21/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/neoforge_1_21/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +73,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +90,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +103,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +120,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/neoforge_1_21_11/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/neoforge_1_21_11/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..95ad14ef 100644 --- a/client/neoforge_1_21_11/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/neoforge_1_21_11/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +73,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +90,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +103,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +120,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/neoforge_1_21_3/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/neoforge_1_21_3/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..95ad14ef 100644 --- a/client/neoforge_1_21_3/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/neoforge_1_21_3/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +73,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +90,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +103,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +120,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/neoforge_1_21_4/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/neoforge_1_21_4/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..82829fcd 100644 --- a/client/neoforge_1_21_4/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/neoforge_1_21_4/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,15 +73,15 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); } + @Override public void drawWithState(float alpha, int x, int y, int maxWidth, float state, HudPosType dir) { if (texts.isEmpty()) { @@ -133,7 +91,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +104,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +121,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/neoforge_1_21_6/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/neoforge_1_21_6/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 450f1f7b..95ad14ef 100644 --- a/client/neoforge_1_21_6/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/neoforge_1_21_6/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +73,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphics gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.drawString(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +90,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +103,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.drawString(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +120,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/neoforge_26_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/neoforge_26_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 5f3122e6..fe90072e 100644 --- a/client/neoforge_26_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/neoforge_26_1/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -94,7 +52,7 @@ public class CoreRenderTarget extends TextFrameBuffer { int finalColor = applyAlpha(entry.color, alpha); if (maxWidth != -1 && entry.width > maxWidth) { - int scrollOffset = (int) (offsetX % entry.width); + int scrollOffset = (int) getOffset(entry, maxWidth); gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.text(font, entry.component, drawX - scrollOffset, drawY, finalColor, entry.shadow); if (scrollOffset > 0) { @@ -115,10 +73,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphicsExtractor gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.text(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +90,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +103,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.text(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +120,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/neoforge_26_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java b/client/neoforge_26_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java index 5f3122e6..72b32986 100644 --- a/client/neoforge_26_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java +++ b/client/neoforge_26_2/src/main/java/com/coloryr/allmusic/client/CoreRenderTarget.java @@ -9,30 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.network.chat.Component; -import java.util.ArrayList; -import java.util.List; - -public class CoreRenderTarget extends TextFrameBuffer { - private static class TextEntry { - final Component component; - final int y; - final int color; - final boolean shadow; - final int width; - final int height; - - TextEntry(Component component, int y, int color, boolean shadow, int width, int height) { - this.component = component; - this.y = y; - this.color = color; - this.shadow = shadow; - this.width = width; - this.height = height; - } - } - - private final List entries = new ArrayList<>(); - +public class CoreRenderTarget extends TextFrameBuffer { private final boolean isState; public CoreRenderTarget(String name) { @@ -40,25 +17,7 @@ public class CoreRenderTarget extends TextFrameBuffer { } @Override - public void resize(int width, int height) { - nowWidth = width; - nowHeight = height; - } - - @Override - public void use() { - isDraw = true; - clear(); - entries.clear(); - } - - @Override - public void unUse() { - isDraw = false; - } - - @Override - public void drawText(String text, int y, int color, boolean shadow) { + public void putText(String text, int y, int color, boolean shadow) { color = (color & 0x00FFFFFF) | 0xFF000000; Component component = MiniMessage.parse(text); Font font = Minecraft.getInstance().font; @@ -71,8 +30,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (isState) { y = 0; } - entries.add(new TextEntry(component, y, color, shadow, width, height)); - texts.add(new TextItem(width, height, y, 1.0f)); + texts.add(new TextItem<>(width, height, y, component, shadow, color)); } @Override @@ -85,7 +43,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -115,10 +73,9 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return; } - if (line >= entries.size()) return; GuiGraphicsExtractor gui = AllMusicClient.context; if (gui == null) return; - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); gui.text(Minecraft.getInstance().font, entry.component, (int) x, (int) (y + entry.y), applyAlpha(entry.color, alpha), entry.shadow); @@ -133,7 +90,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (gui == null) return; Font font = Minecraft.getInstance().font; - for (TextEntry entry : entries) { + for (TextItem entry : texts) { int displayWidth = maxWidth != -1 ? Math.min(entry.width, maxWidth) : entry.width; Point2f point = AllMusicHud.getPos(displayWidth, entry.height, x, y, dir); @@ -146,7 +103,6 @@ public class CoreRenderTarget extends TextFrameBuffer { float texOffset = maxOffset * state; int revealWidth = (int) (maxWidth * state); - gui.enableScissor(drawX, Math.max(0, drawY), drawX + maxWidth, drawY + entry.height); gui.enableScissor(drawX, Math.max(0, drawY), drawX + revealWidth, drawY + entry.height); gui.text(font, entry.component, drawX - (int) texOffset, drawY, finalColor, entry.shadow); gui.disableScissor(); @@ -164,8 +120,7 @@ public class CoreRenderTarget extends TextFrameBuffer { if (line >= texts.size()) { return new Point2f(0, 0); } - if (line >= entries.size()) return new Point2f(0, 0); - TextEntry entry = entries.get(line); + TextItem entry = texts.get(line); return new Point2f(entry.width, entry.height); } diff --git a/client/src/main/java/com/coloryr/allmusic/client/core/AllMusicHud.java b/client/src/main/java/com/coloryr/allmusic/client/core/AllMusicHud.java index 6e8f45b3..56de12ba 100644 --- a/client/src/main/java/com/coloryr/allmusic/client/core/AllMusicHud.java +++ b/client/src/main/java/com/coloryr/allmusic/client/core/AllMusicHud.java @@ -48,11 +48,11 @@ public class AllMusicHud { /** * 文字渲染 */ - private final TextFrameBuffer stateRender; - private final TextFrameBuffer infoRender; - private final TextFrameBuffer lyricRender; - private final TextFrameBuffer lyricTranRender; - private final TextFrameBuffer lyricKtvRender; + private final TextFrameBuffer stateRender; + private final TextFrameBuffer infoRender; + private final TextFrameBuffer lyricRender; + private final TextFrameBuffer lyricTranRender; + private final TextFrameBuffer lyricKtvRender; private final TextureRender progress1; private final TextureRender progress2; private final TextureRender progress3; @@ -250,9 +250,12 @@ public class AllMusicHud { if (ktv == null || save == null || lyricWidth <= 0) { lyricRender.clearKtvOffset(); lyricKtvRender.clearKtvOffset(); + lyricTranRender.setState(0); return; } + lyricTranRender.setState(lyricState); + float offset = 0; int maxWidth = save.lyric.maxWidth; if (maxWidth > 0 && lyricWidth > maxWidth) { @@ -458,7 +461,7 @@ public class AllMusicHud { if (item.isEmpty()) { continue; } - infoRender.drawText(item, offset, save.info.color, save.info.shadow); + infoRender.putText(item, offset, save.info.color, save.info.shadow); offset += save.info.gap; } infoRender.unUse(); @@ -491,7 +494,7 @@ public class AllMusicHud { if (item.isEmpty()) { continue; } - lyricRender.drawText(item, offset, save.lyric.color, save.lyric.shadow); + lyricRender.putText(item, offset, save.lyric.color, save.lyric.shadow); offset += save.lyric.gap; } lyricRender.unUse(); @@ -520,7 +523,7 @@ public class AllMusicHud { if (item.isEmpty()) { continue; } - lyricTranRender.drawText(item, offset, save.lyric.color, save.lyric.shadow); + lyricTranRender.putText(item, offset, save.lyric.color, save.lyric.shadow); offset += save.lyric.gap; } lyricTranRender.unUse(); @@ -551,7 +554,7 @@ public class AllMusicHud { if (item.isEmpty()) { continue; } - lyricKtvRender.drawText(item, offset, save.lyric.color, save.lyric.shadow); + lyricKtvRender.putText(item, offset, save.lyric.color, save.lyric.shadow); offset += save.lyric.gap; } lyricKtvRender.unUse(); @@ -575,8 +578,8 @@ public class AllMusicHud { stateRender.resize(allWidth, allHeight); stateRender.use(); - stateRender.drawText(all, 0, save.state.color, save.state.shadow); - stateRender.drawText(time, 10, save.state.color, save.state.shadow); + stateRender.putText(all, 0, save.state.color, save.state.shadow); + stateRender.putText(time, 10, save.state.color, save.state.shadow); stateRender.unUse(); } stateNeedUpdate = false; @@ -588,6 +591,7 @@ public class AllMusicHud { if (save.lyric.enable) { lyricRender.draw(save.lyric.alpha, save.lyric.x, save.lyric.y, save.lyric.maxWidth, save.lyric.pos); lyricTranRender.draw(save.lyric.alpha, save.lyric.x, save.lyric.y + save.lyric.gap, save.lyric.maxWidth, save.lyric.pos); + if (ktv != null) { lyricKtvRender.drawWithState(save.lyric.alpha, save.lyric.x, save.lyric.y, save.lyric.maxWidth, lyricState, save.lyric.pos); } diff --git a/client/src/main/java/com/coloryr/allmusic/client/core/render/TextFrameBuffer.java b/client/src/main/java/com/coloryr/allmusic/client/core/render/TextFrameBuffer.java index 445b1aff..811f980e 100644 --- a/client/src/main/java/com/coloryr/allmusic/client/core/render/TextFrameBuffer.java +++ b/client/src/main/java/com/coloryr/allmusic/client/core/render/TextFrameBuffer.java @@ -6,11 +6,12 @@ import com.coloryr.allmusic.codec.HudPosType; import java.util.ArrayList; import java.util.List; -public abstract class TextFrameBuffer { - protected final List texts = new ArrayList<>(); +public abstract class TextFrameBuffer { + protected final List> texts = new ArrayList<>(); protected int nowWidth, nowHeight; protected long offsetX; protected boolean isDraw; + protected float state; /** * KTV模式下的强制滚动偏移,>=0 时优先使用 */ @@ -31,17 +32,25 @@ public abstract class TextFrameBuffer { return a / gcd(a, b) * b; // 先除后乘防溢出 } + public void use() { + isDraw = true; + texts.clear(); + } + public void clear() { texts.clear(); } - public abstract void use(); + public void unUse() { + isDraw = false; + } - public abstract void unUse(); + public void resize(int width, int height) { + nowWidth = width; + nowHeight = height; + } - public abstract void resize(int width, int height); - - public abstract void drawText(String text, int y, int color, boolean shadow); + public abstract void putText(String text, int y, int color, boolean shadow); public abstract void drawLine(float x, float y, float alpha, int line); @@ -55,8 +64,8 @@ public abstract class TextFrameBuffer { offsetX++; if (isDraw) return; long temp = 1; - for (TextItem item : texts) { - temp = lcm(temp, item.textWidth); + for (TextItem item : texts) { + temp = lcm(temp, item.width); } if (offsetX > temp) { offsetX = 0; @@ -80,28 +89,36 @@ public abstract class TextFrameBuffer { /** * 获取当前应使用的水平滚动偏移 */ - protected float getOffset(TextItem item) { + protected float getOffset(TextItem item, int maxWidth) { + if (state > 0) { + float maxOffset = item.width - maxWidth; + return maxOffset * state; + } if (ktvOffset >= 0) { return ktvOffset; } - return offsetX % item.textWidth; + return offsetX % item.width; } - public static class TextItem { - public final float renderWidth; - public final float renderHeight; - public final int textWidth; - public final int textHeight; - public final float y; - public final float scale; + public void setState(float state) { + this.state = state; + } - public TextItem(int width, int height, float y, float scale) { - this.textWidth = width; - this.textHeight = height; - this.renderWidth = width * scale; - this.renderHeight = height * scale; + public static class TextItem { + public final T component; + public final int width; + public final int height; + public final boolean shadow; + public final int color; + public final float y; + + public TextItem(int width, int height, float y, T component, boolean shadow, int color) { + this.width = width; + this.height = height; + this.component = component; this.y = y; - this.scale = scale; + this.shadow = shadow; + this.color = color; } } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 787803c2..413b7b9a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -55,15 +55,15 @@ include(":server:folia") include(":server:paper") include(":server:velocity") -include(":onejar") - -include(":onejar:fabric_1_16_5") -include(":onejar:fabric_1_20_1") -include(":onejar:fabric_1_21") -include(":onejar:fabric_1_21_6") -include(":onejar:fabric_1_21_11") -include(":onejar:fabric_26_1") -include(":onejar:fabric_26_2") +//include(":onejar") +// +//include(":onejar:fabric_1_16_5") +//include(":onejar:fabric_1_20_1") +//include(":onejar:fabric_1_21") +//include(":onejar:fabric_1_21_6") +//include(":onejar:fabric_1_21_11") +//include(":onejar:fabric_26_1") +//include(":onejar:fabric_26_2") pluginManagement { repositories {