Skip to content

Commit 5a7875e

Browse files
committed
Update to mc1.21.3
1 parent 50d8dfe commit 5a7875e

10 files changed

Lines changed: 93 additions & 55 deletions

File tree

common/src/main/java/dev/terminalmc/chatnotify/ChatNotify.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static void afterClientTick(Minecraft mc) {
8989
// Config reset warning toast
9090
if (hasResetConfig && mc.screen instanceof TitleScreen) {
9191
hasResetConfig = false;
92-
mc.getToasts().addToast(new SystemToast(
92+
mc.getToastManager().addToast(new SystemToast(
9393
new SystemToast.SystemToastId(15000L),
9494
localized("toast", "reset.title"),
9595
localized(

common/src/main/java/dev/terminalmc/chatnotify/gui/toast/NotificationToast.java

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import net.minecraft.client.gui.Font;
2121
import net.minecraft.client.gui.GuiGraphics;
2222
import net.minecraft.client.gui.components.toasts.Toast;
23-
import net.minecraft.client.gui.components.toasts.ToastComponent;
23+
import net.minecraft.client.gui.components.toasts.ToastManager;
24+
import net.minecraft.client.renderer.RenderType;
2425
import net.minecraft.network.chat.Component;
2526
import net.minecraft.resources.ResourceLocation;
2627
import net.minecraft.util.FormattedCharSequence;
@@ -41,22 +42,30 @@ public class NotificationToast implements Toast {
4142

4243
private final int lineHeight;
4344
private final List<FormattedCharSequence> messageLines;
45+
private Toast.Visibility wantedVisibility;
4446

4547
public NotificationToast(Component message) {
4648
this.messageLines = Minecraft.getInstance().font.split(message, WIDTH - X_MARGIN * 2);
4749
this.lineHeight = Minecraft.getInstance().font.lineHeight + LINE_SPACE;
4850
}
4951

5052
@Override
51-
public @NotNull Visibility render(
52-
@NotNull GuiGraphics graphics,
53-
@NotNull ToastComponent component,
54-
long elapsedTime
55-
) {
56-
Font font = component.getMinecraft().font;
53+
public @NotNull Visibility getWantedVisibility() {
54+
return wantedVisibility;
55+
}
56+
57+
@Override
58+
public void update(@NotNull ToastManager manager, long elapsedTime) {
59+
this.wantedVisibility =
60+
elapsedTime < DISPLAY_TIME * manager.getNotificationDisplayTimeMultiplier()
61+
? Visibility.SHOW : Visibility.HIDE;
62+
}
63+
64+
@Override
65+
public void render(@NotNull GuiGraphics graphics, @NotNull Font font, long elapsedTime) {
5766
if (messageLines.size() <= 1) {
5867
// Message fits in a single line, render a single sprite
59-
graphics.blitSprite(BACKGROUND_SPRITE, 0, 0, WIDTH, height());
68+
graphics.blitSprite(RenderType::guiTextured, BACKGROUND_SPRITE, 0, 0, WIDTH, height());
6069
} else {
6170
// Message requires multiple lines, stretch vertically by rendering
6271
// multiple sprites
@@ -109,10 +118,6 @@ public NotificationToast(Component message) {
109118
);
110119
}
111120
}
112-
113-
return elapsedTime < DISPLAY_TIME * component.getNotificationDisplayTimeMultiplier()
114-
? Visibility.SHOW
115-
: Visibility.HIDE;
116121
}
117122

118123
private void renderBackgroundRow(
@@ -126,12 +131,24 @@ private void renderBackgroundRow(
126131
int uRemainder = Math.min(60, width - uWidth);
127132

128133
// Left border
129-
graphics.blitSprite(BACKGROUND_SPRITE, WIDTH, HEIGHT, 0, vOffset, 0, y, uWidth, vHeight);
134+
graphics.blitSprite(
135+
RenderType::guiTextured,
136+
BACKGROUND_SPRITE,
137+
WIDTH,
138+
HEIGHT,
139+
0,
140+
vOffset,
141+
0,
142+
y,
143+
uWidth,
144+
vHeight
145+
);
130146

131147
// Middle background
132148
int offset = 64;
133149
for (int x = uWidth; x < width - uRemainder; x += offset) {
134150
graphics.blitSprite(
151+
RenderType::guiTextured,
135152
BACKGROUND_SPRITE,
136153
WIDTH,
137154
HEIGHT,
@@ -146,6 +163,7 @@ private void renderBackgroundRow(
146163

147164
// Right border
148165
graphics.blitSprite(
166+
RenderType::guiTextured,
149167
BACKGROUND_SPRITE,
150168
WIDTH,
151169
HEIGHT,

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/HorizontalList.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.minecraft.client.gui.narration.NarratedElementType;
2828
import net.minecraft.client.gui.narration.NarrationElementOutput;
2929
import net.minecraft.client.gui.screens.Screen;
30+
import net.minecraft.client.renderer.RenderType;
3031
import net.minecraft.network.chat.Component;
3132
import net.minecraft.resources.ResourceLocation;
3233
import net.minecraft.util.Mth;
@@ -246,7 +247,18 @@ protected void renderWidget(
246247
*/
247248
protected void renderListBackground(GuiGraphics graphics) {
248249
RenderSystem.enableBlend();
249-
graphics.blit(MENU_LIST_BACKGROUND, getX(), getY(), 0, 0, getWidth(), getHeight(), 32, 32);
250+
graphics.blit(
251+
RenderType::guiTextured,
252+
MENU_LIST_BACKGROUND,
253+
getX(),
254+
getY(),
255+
0,
256+
0,
257+
getWidth(),
258+
getHeight(),
259+
32,
260+
32
261+
);
250262
RenderSystem.disableBlend();
251263
}
252264

@@ -297,13 +309,21 @@ protected void renderScrollbar(GuiGraphics graphics) {
297309

298310
RenderSystem.enableBlend();
299311
graphics.blitSprite(
312+
RenderType::guiTextured,
300313
SCROLLER_BACKGROUND_SPRITE,
301314
getX(),
302315
y,
303316
getWidth(),
304317
SCROLLBAR_HEIGHT
305318
);
306-
graphics.blitSprite(SCROLLER_SPRITE, scrollerPos, y, scrollerWidth, SCROLLBAR_HEIGHT);
319+
graphics.blitSprite(
320+
RenderType::guiTextured,
321+
SCROLLER_SPRITE,
322+
scrollerPos,
323+
y,
324+
scrollerWidth,
325+
SCROLLBAR_HEIGHT
326+
);
307327
RenderSystem.disableBlend();
308328
}
309329
}
@@ -321,6 +341,7 @@ protected boolean scrollbarVisible() {
321341
protected void renderSeparators(GuiGraphics guiGraphics) {
322342
RenderSystem.enableBlend();
323343
guiGraphics.blit(
344+
RenderType::guiTextured,
324345
LEFT_SEPARATOR,
325346
getX() - 2,
326347
getY() - 1,
@@ -332,6 +353,7 @@ protected void renderSeparators(GuiGraphics guiGraphics) {
332353
32
333354
);
334355
guiGraphics.blit(
356+
RenderType::guiTextured,
335357
RIGHT_SEPARATOR,
336358
getRight(),
337359
getY() - 1,
@@ -343,6 +365,7 @@ protected void renderSeparators(GuiGraphics guiGraphics) {
343365
32
344366
);
345367
guiGraphics.blit(
368+
RenderType::guiTextured,
346369
Screen.HEADER_SEPARATOR,
347370
getX() - 1,
348371
getY() - 2,
@@ -354,6 +377,7 @@ protected void renderSeparators(GuiGraphics guiGraphics) {
354377
2
355378
);
356379
guiGraphics.blit(
380+
RenderType::guiTextured,
357381
Screen.FOOTER_SEPARATOR,
358382
getX() - 1,
359383
getBottom(),

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/HsvColorPicker.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import net.minecraft.network.chat.CommonComponents;
3030
import net.minecraft.network.chat.Component;
3131
import net.minecraft.network.chat.TextColor;
32-
import net.minecraft.util.FastColor;
32+
import net.minecraft.util.ARGB;
3333
import net.minecraft.util.Mth;
3434
import org.jetbrains.annotations.NotNull;
3535

@@ -258,9 +258,9 @@ public int getMaxHeight() {
258258
public void updateColorFromSource() {
259259
int color = source.get();
260260
Color.RGBtoHSB(
261-
FastColor.ARGB32.red(color),
262-
FastColor.ARGB32.green(color),
263-
FastColor.ARGB32.blue(color),
261+
ARGB.red(color),
262+
ARGB.green(color),
263+
ARGB.blue(color),
264264
hsv
265265
);
266266
oldColor = color;
@@ -282,9 +282,9 @@ private void updateColorFromHexField(String s) {
282282
int color = textColor.getValue();
283283
if (!updateFromCursor) {
284284
Color.RGBtoHSB(
285-
FastColor.ARGB32.red(color),
286-
FastColor.ARGB32.green(color),
287-
FastColor.ARGB32.blue(color),
285+
ARGB.red(color),
286+
ARGB.green(color),
287+
ARGB.blue(color),
288288
hsv
289289
);
290290
updateHCursor();

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/list/FilterList.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import net.minecraft.network.chat.Component;
4242
import net.minecraft.network.chat.MutableComponent;
4343
import net.minecraft.network.chat.TextColor;
44-
import net.minecraft.util.FastColor;
44+
import net.minecraft.util.ARGB;
4545
import net.minecraft.util.StringUtil;
4646
import org.jetbrains.annotations.Nullable;
4747

@@ -965,9 +965,9 @@ public NotifOptions(
965965
notif.textStyle.color = color;
966966
float[] hsv = new float[3];
967967
Color.RGBtoHSB(
968-
FastColor.ARGB32.red(color),
969-
FastColor.ARGB32.green(color),
970-
FastColor.ARGB32.blue(color),
968+
ARGB.red(color),
969+
ARGB.green(color),
970+
ARGB.blue(color),
971971
hsv
972972
);
973973
if (hsv[2] < 0.1)

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/list/root/DefaultList.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import net.minecraft.network.chat.Style;
3636
import net.minecraft.network.chat.TextColor;
3737
import net.minecraft.resources.ResourceLocation;
38-
import net.minecraft.util.FastColor;
38+
import net.minecraft.util.ARGB;
3939

4040
import java.awt.*;
4141

@@ -149,9 +149,9 @@ private static class DefaultColor extends Entry {
149149
).setStyle(Style.EMPTY.withColor(textColor)));
150150
float[] hsv = new float[3];
151151
Color.RGBtoHSB(
152-
FastColor.ARGB32.red(color),
153-
FastColor.ARGB32.green(color),
154-
FastColor.ARGB32.blue(color),
152+
ARGB.red(color),
153+
ARGB.green(color),
154+
ARGB.blue(color),
155155
hsv
156156
);
157157
if (hsv[2] < 0.1)

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/list/root/notif/FormatList.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import net.minecraft.network.chat.Component;
3535
import net.minecraft.network.chat.MutableComponent;
3636
import net.minecraft.network.chat.TextColor;
37-
import net.minecraft.util.FastColor;
37+
import net.minecraft.util.ARGB;
3838

3939
import java.awt.*;
4040
import java.time.Duration;
@@ -152,9 +152,9 @@ private static class ColorOptions extends Entry {
152152
mainButton.setMessage(mainButton.getMessage().copy().withColor(color));
153153
float[] hsv = new float[3];
154154
Color.RGBtoHSB(
155-
FastColor.ARGB32.red(color),
156-
FastColor.ARGB32.green(color),
157-
FastColor.ARGB32.blue(color),
155+
ARGB.red(color),
156+
ARGB.green(color),
157+
ARGB.blue(color),
158158
hsv
159159
);
160160
if (hsv[2] < 0.1)

common/src/main/java/dev/terminalmc/chatnotify/mixin/GuiGraphicsMixin.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ public abstract class GuiGraphicsMixin implements IGuiGraphics {
3838
@Final
3939
private PoseStack pose;
4040

41-
@Shadow
42-
protected abstract void flushIfUnmanaged();
43-
4441
@Override
4542
public void chatnotify$fillGradientHorizontal(
4643
int x0,
@@ -56,6 +53,5 @@ public abstract class GuiGraphicsMixin implements IGuiGraphics {
5653
consumer.addVertex(matrix4f, (float) x0, (float) y1, 0F).setColor(colorFrom);
5754
consumer.addVertex(matrix4f, (float) x1, (float) y1, 0F).setColor(colorTo);
5855
consumer.addVertex(matrix4f, (float) x1, (float) y0, 0F).setColor(colorTo);
59-
flushIfUnmanaged();
6056
}
6157
}

common/src/main/java/dev/terminalmc/chatnotify/util/text/MessageUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ private static void showToastMsg(Notification notif, Component msg, Matcher matc
534534
if (notif.toastMsgEnabled) {
535535
Component displayMsg =
536536
notif.toastMsg.isBlank() ? msg : convertMsg(notif.toastMsg, matcher, msg);
537-
Minecraft.getInstance().getToasts().addToast(new NotificationToast(displayMsg));
537+
Minecraft.getInstance().getToastManager().addToast(new NotificationToast(displayMsg));
538538
}
539539
}
540540

gradle.properties

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,37 +55,37 @@ mod_curseforge_slug=chatnotify
5555
# Subproject Build Compatibility
5656
# -> Comment out or unset to disable publishing of a subproject.
5757
mod_loaders_fabric=fabric
58-
mc_versions_fabric=1.21,1.21.1
58+
mc_versions_fabric=1.21.2,1.21.3
5959
mod_loaders_neoforge=neoforge
60-
mc_versions_neoforge=1.21.1
60+
mc_versions_neoforge=1.21.3
6161

6262
# Java
6363
java_version=21
6464
java_versions_fabric=>=21
6565
java_versions_neoforge=[21,)
6666

6767
# Minecraft
68-
minecraft_version=1.21.1
69-
minecraft_versions_fabric=>1.20.6
70-
minecraft_versions_neoforge=[1.21.1,)
68+
minecraft_version=1.21.3
69+
minecraft_versions_fabric=>1.21.1
70+
minecraft_versions_neoforge=[1.21.3,)
7171

7272
# Parchment https://parchmentmc.org/docs/getting-started#choose-a-version
73-
parchment_minecraft_version=1.21.1
74-
parchment_version=2024.11.17
73+
parchment_minecraft_version=1.21.3
74+
parchment_version=2024.12.07
7575

7676
# Fabric https://fabricmc.net/develop
7777
# -> See also 'mixinextras_jij_fabric'
7878
fabric_loader_version=0.16.14
7979
fabric_loader_versions=>=0.16.1
80-
fabric_api_version=0.116.4+1.21.1
80+
fabric_api_version=0.114.1+1.21.3
8181
fabric_api_versions=*
8282

8383
# NeoForge https://projects.neoforged.net/neoforged/neoforge
8484
# -> See also 'mixinextras_jij_neoforge'
85-
neoforge_version=21.1.190
86-
neoforge_versions=[21.1.22,)
85+
neoforge_version=21.3.84
86+
neoforge_versions=[21.3.0-beta,)
8787
# NeoForm https://projects.neoforged.net/neoforged/neoform
88-
neoform_version=1.21.1-20240808.144430
88+
neoform_version=1.21.3-20241023.131943
8989

9090
# Dependency Property Identifiers
9191
# -> These values point to other properties with full dependency specification.
@@ -119,13 +119,13 @@ v_commandkeys_neoforge=PWiUgUsv
119119
d_common_chatheads=-:-:imp:maven.modrinth:Wb5oqrBJ:$v:v_chatheads_neoforge
120120
d_fabric_chatheads=-:-:imp:maven.modrinth:Wb5oqrBJ:$v:v_chatheads_fabric
121121
d_neoforge_chatheads=-:-:imp:maven.modrinth:Wb5oqrBJ:$v:v_chatheads_neoforge
122-
v_chatheads_fabric=44MAqJD2
123-
v_chatheads_neoforge=RVtAqF2n
122+
v_chatheads_fabric=UvaxwNU8
123+
v_chatheads_neoforge=dubnK548
124124

125125
# ModMenu https://modrinth.com/mod/mOgUt4GM/versions
126126
d_fabric_modmenu=-:-:imp:maven.modrinth:mOgUt4GM:$v:-,recommends:modmenu,req:mOgUt4GM,req:modmenu
127-
v_modmenu=11.0.3
128-
vr_fabric_modmenu=>=11.0.0-beta.1
127+
v_modmenu=12.0.0
128+
vr_fabric_modmenu=>=12.0.0-beta.1
129129

130130
# Dependency Version Extensions
131131
# -> Intended for addon mods to show which version they were compiled against.

0 commit comments

Comments
 (0)