修复渲染问题

This commit is contained in:
Color_yr committed 2026-07-15 23:05:31 +08:00
1 parent 5d9b83ecc1
commit e4fe151991
24 files changed
+226 -1114

No files matched your search

@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> 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<Component> entry,
int x, int y, int color) {
if (entry.shadow) {
font.drawShadow(matrices, entry.component, x, y, color);
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<String> {
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<String> 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<String> 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<String> 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<String> 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<String> 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);
}
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> 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<Component> entry,
int x, int y, int color) {
if (entry.shadow) {
font.drawShadow(matrices, entry.component, x, y, color);
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<String> {
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<String> 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<String> 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<String> 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<String> 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<String> 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);
}
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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<TextEntry> entries = new ArrayList<>();
public class CoreRenderTarget extends TextFrameBuffer<Component> {
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<Component> 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<Component> 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<Component> 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<Component> entry = texts.get(line);
return new Point2f(entry.width, entry.height);
}
@@ -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);
}
@@ -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<TextItem> texts = new ArrayList<>();
public abstract class TextFrameBuffer<T> {
protected final List<TextItem<T>> 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<T> 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<T> 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<T> {
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;
}
}
}
+9 -9
View File
@@ -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 {