Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 16999ee

Browse files
committed
disable text background on news screens
1 parent c025e35 commit 16999ee

File tree

7 files changed

+49
-23
lines changed

7 files changed

+49
-23
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/api/NewsScreen.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void render(MatrixStack graphics, int mouseX, int mouseY, float delta) {
5959

6060
@Override
6161
protected void init() {
62-
addButton(new NewsWidget(25, 35, width - 50, height - 100, new TranslatableText(GlobalDataRequest.get().notes().replaceAll("([^\n])\n([^\n])", "$1 $2"))));
62+
addButton(new NewsWidget(25, 35, width - 50, height - 100, new TranslatableText(GlobalDataRequest.get().notes().trim().replaceAll("([^\n])\n([^\n])", "$1 $2"))));
6363

6464
addButton(new ButtonWidget(width / 2 - 100, height - 45, 200, 20, ScreenTexts.BACK, buttonWidget -> client.openScreen(parent)));
6565
}
@@ -98,13 +98,17 @@ protected double scrollRate() {
9898
protected MutableText getNarrationMessage() {
9999
return getMessage().copy();
100100
}
101+
102+
@Override
103+
protected void renderBackground(MatrixStack stack) {
104+
}
101105
}
102106

103107
public abstract static class AbstractTextAreaWidget extends AbstractScrollArea {
104108
private static final int INNER_PADDING = 4;
105109

106-
public AbstractTextAreaWidget(int i, int j, int k, int l, Text component) {
107-
super(i, j, k, l, component);
110+
public AbstractTextAreaWidget(int x, int y, int width, int height, Text component) {
111+
super(x, y, width, height, component);
108112
}
109113

110114
@Override
@@ -210,8 +214,8 @@ public abstract static class AbstractScrollArea extends AbstractButtonWidget {
210214
private double scrollAmount;
211215
private boolean scrolling;
212216

213-
public AbstractScrollArea(int i, int j, int k, int l, Text component) {
214-
super(i, j, k, l, component);
217+
public AbstractScrollArea(int x, int y, int width, int height, Text component) {
218+
super(x, y, width, height, component);
215219
}
216220

217221
@Override

1.20/src/main/java/io/github/axolotlclient/api/NewsScreen.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import net.minecraft.client.gui.GuiGraphics;
2929
import net.minecraft.client.gui.screen.Screen;
3030
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
31+
import net.minecraft.client.gui.screen.narration.NarrationPart;
3132
import net.minecraft.client.gui.widget.ButtonWidget;
3233
import net.minecraft.client.gui.widget.ClickableWidget;
3334
import net.minecraft.client.sound.SoundManager;
@@ -57,7 +58,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
5758

5859
@Override
5960
protected void init() {
60-
addDrawableChild(new NewsWidget(25, 35, width - 50, height - 100, Text.literal(GlobalDataRequest.get().notes().replaceAll("([^\n])\n([^\n])", "$1 $2"))));
61+
addDrawableChild(new NewsWidget(25, 35, width - 50, height - 100, Text.literal(GlobalDataRequest.get().notes().trim().replaceAll("([^\n])\n([^\n])", "$1 $2"))));
6162

6263
addDrawableChild(ButtonWidget.builder(CommonTexts.BACK, buttonWidget -> client.setScreen(parent))
6364
.positionAndSize(width / 2 - 100, height - 45, 200, 20)
@@ -96,15 +97,19 @@ protected double scrollRate() {
9697

9798
@Override
9899
protected void updateNarration(NarrationMessageBuilder narrationElementOutput) {
100+
narrationElementOutput.put(NarrationPart.TITLE, getMessage());
101+
}
99102

103+
@Override
104+
protected void renderBackground(GuiGraphics guiGraphics) {
100105
}
101106
}
102107

103108
public abstract static class AbstractTextAreaWidget extends AbstractScrollArea {
104109
private static final int INNER_PADDING = 4;
105110

106-
public AbstractTextAreaWidget(int i, int j, int k, int l, Text component) {
107-
super(i, j, k, l, component);
111+
public AbstractTextAreaWidget(int x, int y, int width, int height, Text component) {
112+
super(x, y, width, height, component);
108113
}
109114

110115
@Override
@@ -210,8 +215,8 @@ public abstract static class AbstractScrollArea extends ClickableWidget {
210215
private double scrollAmount;
211216
private boolean scrolling;
212217

213-
public AbstractScrollArea(int i, int j, int k, int l, Text component) {
214-
super(i, j, k, l, component);
218+
public AbstractScrollArea(int x, int y, int width, int height, Text component) {
219+
super(x, y, width, height, component);
215220
}
216221

217222
@Override

1.21.4/src/main/java/io/github/axolotlclient/api/NewsScreen.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import net.minecraft.client.gui.GuiGraphics;
2929
import net.minecraft.client.gui.components.AbstractTextAreaWidget;
3030
import net.minecraft.client.gui.components.Button;
31+
import net.minecraft.client.gui.narration.NarratedElementType;
3132
import net.minecraft.client.gui.narration.NarrationElementOutput;
3233
import net.minecraft.client.gui.screens.Screen;
3334
import net.minecraft.network.chat.CommonComponents;
@@ -52,7 +53,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
5253

5354
@Override
5455
protected void init() {
55-
addRenderableWidget(new NewsWidget(25, 35, width - 50, height - 100, Component.literal(GlobalDataRequest.get().notes().replaceAll("([^\n])\n([^\n])", "$1 $2"))));
56+
addRenderableWidget(new NewsWidget(25, 35, width - 50, height - 100, Component.literal(GlobalDataRequest.get().notes().trim().replaceAll("([^\n])\n([^\n])", "$1 $2"))));
5657
addRenderableWidget(Button.builder(CommonComponents.GUI_BACK, buttonWidget -> minecraft.setScreen(parent)).bounds(width / 2 - 100, height - 45, 200, 20).build());
5758
}
5859

@@ -88,7 +89,11 @@ protected double scrollRate() {
8889

8990
@Override
9091
protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) {
92+
narrationElementOutput.add(NarratedElementType.TITLE, getMessage());
93+
}
9194

95+
@Override
96+
protected void renderBackground(GuiGraphics guiGraphics) {
9297
}
9398
}
9499
}

1.21/src/main/java/io/github/axolotlclient/api/NewsScreen.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import net.minecraft.client.gui.GuiGraphics;
2929
import net.minecraft.client.gui.screen.Screen;
3030
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
31+
import net.minecraft.client.gui.screen.narration.NarrationPart;
3132
import net.minecraft.client.gui.widget.ClickableWidget;
3233
import net.minecraft.client.gui.widget.ClickableWidgetStateTextures;
3334
import net.minecraft.client.gui.widget.button.ButtonWidget;
@@ -58,7 +59,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
5859

5960
@Override
6061
protected void init() {
61-
addDrawableSelectableElement(new NewsWidget(25, 35, width - 50, height - 100, Text.literal(GlobalDataRequest.get().notes().replaceAll("([^\n])\n([^\n])", "$1 $2"))));
62+
addDrawableSelectableElement(new NewsWidget(25, 35, width - 50, height - 100, Text.literal(GlobalDataRequest.get().notes().trim().replaceAll("([^\n])\n([^\n])", "$1 $2"))));
6263

6364
addDrawableSelectableElement(ButtonWidget.builder(CommonTexts.BACK, buttonWidget -> client.setScreen(parent))
6465
.positionAndSize(width / 2 - 100, height - 45, 200, 20)
@@ -97,7 +98,11 @@ protected double scrollRate() {
9798

9899
@Override
99100
protected void updateNarration(NarrationMessageBuilder narrationElementOutput) {
101+
narrationElementOutput.put(NarrationPart.TITLE, getMessage());
102+
}
100103

104+
@Override
105+
protected void renderBackground(GuiGraphics guiGraphics) {
101106
}
102107
}
103108

@@ -107,8 +112,8 @@ public abstract static class AbstractTextAreaWidget extends AbstractScrollArea {
107112
);
108113
private static final int INNER_PADDING = 4;
109114

110-
public AbstractTextAreaWidget(int i, int j, int k, int l, Text component) {
111-
super(i, j, k, l, component);
115+
public AbstractTextAreaWidget(int x, int y, int width, int height, Text component) {
116+
super(x, y, width, height, component);
112117
}
113118

114119
@Override
@@ -213,8 +218,8 @@ public abstract static class AbstractScrollArea extends ClickableWidget {
213218
private double scrollAmount;
214219
private boolean scrolling;
215220

216-
public AbstractScrollArea(int i, int j, int k, int l, Text component) {
217-
super(i, j, k, l, component);
221+
public AbstractScrollArea(int x, int y, int width, int height, Text component) {
222+
super(x, y, width, height, component);
218223
}
219224

220225
@Override

1.8.9/src/main/java/io/github/axolotlclient/api/NewsScreen.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void render(int mouseX, int mouseY, float delta) {
5454

5555
@Override
5656
public void init() {
57-
addDrawableChild(new NewsWidget(25, 35, width - 50, height - 100, GlobalDataRequest.get().notes().replaceAll("([^\n])\n([^\n])", "$1 $2")));
57+
addDrawableChild(new NewsWidget(25, 35, width - 50, height - 100, GlobalDataRequest.get().notes().trim().replaceAll("([^\n])\n([^\n])", "$1 $2")));
5858

5959
addDrawableChild(new VanillaButtonWidget(width / 2 - 100, height - 45, 200, 20, I18n.translate("gui.back"), buttonWidget -> minecraft.openScreen(parent)));
6060
}
@@ -88,13 +88,17 @@ protected void renderContents(int mouseX, int mouseY, float partialTick) {
8888
protected double scrollRate() {
8989
return textRenderer.fontHeight;
9090
}
91+
92+
@Override
93+
protected void renderBackground() {
94+
}
9195
}
9296

9397
public abstract static class AbstractTextAreaWidget extends AbstractScrollArea {
9498
private static final int INNER_PADDING = 4;
9599

96-
public AbstractTextAreaWidget(int i, int j, int k, int l, String component) {
97-
super(i, j, k, l, component);
100+
public AbstractTextAreaWidget(int x, int y, int width, int height, String component) {
101+
super(x, y, width, height, component);
98102
}
99103

100104
@Override
@@ -200,8 +204,8 @@ public abstract static class AbstractScrollArea extends ClickableWidget {
200204
private double scrollAmount;
201205
private boolean scrolling;
202206

203-
public AbstractScrollArea(int i, int j, int k, int l, String component) {
204-
super(i, j, k, l, component);
207+
public AbstractScrollArea(int x, int y, int width, int height, String component) {
208+
super(x, y, width, height, component);
205209
}
206210

207211
@Override

common/src/main/java/io/github/axolotlclient/api/ClientEndpoint.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import java.nio.ByteBuffer;
2727
import java.util.concurrent.CompletionStage;
2828

29+
import io.github.axolotlclient.util.ThreadExecuter;
30+
2931

3032
public class ClientEndpoint implements WebSocket.Listener {
3133

@@ -38,7 +40,8 @@ public CompletionStage<?> onText(WebSocket webSocket, CharSequence data, boolean
3840
}
3941
buf.append(data);
4042
if (last) {
41-
API.getInstance().onMessage(buf.toString());
43+
String s = buf.toString();
44+
ThreadExecuter.scheduleTask(() -> API.getInstance().onMessage(s));
4245
buf = null;
4346
}
4447
webSocket.request(1);

common/src/main/java/io/github/axolotlclient/modules/auth/Account.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public boolean isExpired() {
103103
}
104104

105105
public boolean needsRefresh() {
106-
return expiration.isBefore(Instant.now().minus(6, ChronoUnit.HOURS));
106+
return Instant.now().isAfter(expiration.minus(6, ChronoUnit.HOURS));
107107
}
108108

109109
@Override

0 commit comments

Comments
 (0)