Skip to content

Commit ced0cf6

Browse files
committed
Update to mc1.21.11-rc2
1 parent 157f5a3 commit ced0cf6

26 files changed

Lines changed: 311 additions & 254 deletions

common/src/main/java/dev/terminalmc/chatnotify/config/Sound.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import com.google.gson.*;
2020
import dev.terminalmc.chatnotify.config.util.JsonUtil;
21-
import net.minecraft.resources.ResourceLocation;
21+
import net.minecraft.resources.Identifier;
2222
import org.jetbrains.annotations.Nullable;
2323

2424
/**
@@ -36,7 +36,7 @@ public class Sound {
3636
private static final boolean enabledDefault = true;
3737

3838
/**
39-
* The string from which to get the sound {@link ResourceLocation}.
39+
* The string from which to get the sound {@link Identifier}.
4040
*/
4141
private String id;
4242
private static final String idDefault = "block.note_block.bell";
@@ -103,15 +103,15 @@ public void setEnabled(boolean enabled) {
103103
}
104104

105105
/**
106-
* @return the sound {@link ResourceLocation} string.
106+
* @return the sound {@link Identifier} string.
107107
*/
108108
public String getId() {
109109
return id;
110110
}
111111

112112
/**
113-
* Sets the sound {@link ResourceLocation} string to the specified value if it represents a
114-
* valid {@link ResourceLocation}.
113+
* Sets the sound {@link Identifier} string to the specified value if it represents a
114+
* valid {@link Identifier}.
115115
*/
116116
public void setId(String id) {
117117
if (validId(id)) {
@@ -120,10 +120,10 @@ public void setId(String id) {
120120
}
121121

122122
/**
123-
* @return the sound {@link ResourceLocation}.
123+
* @return the sound {@link Identifier}.
124124
*/
125-
public @Nullable ResourceLocation getResourceLocation() {
126-
return ResourceLocation.tryParse(id);
125+
public @Nullable Identifier getIdentifier() {
126+
return Identifier.tryParse(id);
127127
}
128128

129129
public float getVolume() {
@@ -181,10 +181,10 @@ Sound validate() {
181181
}
182182

183183
/**
184-
* @return {@code true} if {@code id} represents a valid {@link ResourceLocation}.
184+
* @return {@code true} if {@code id} represents a valid {@link Identifier}.
185185
*/
186186
public static boolean validId(String id) {
187-
return ResourceLocation.tryParse(id) != null;
187+
return Identifier.tryParse(id) != null;
188188
}
189189

190190
// Deserialization

common/src/main/java/dev/terminalmc/chatnotify/gui/screen/OptionScreen.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected void init() {
134134
}
135135

136136
@Override
137-
public void resize(@NotNull Minecraft mc, int width, int height) {
137+
public void resize(int width, int height) {
138138
this.width = width;
139139
this.height = height;
140140
init();
@@ -190,7 +190,7 @@ protected void addOptions() {
190190
@Override
191191
public void onClose() {
192192
if (lastScreen instanceof OptionScreen screen) {
193-
screen.resize(Minecraft.getInstance(), width, height);
193+
screen.resize(width, height);
194194
}
195195
super.onClose();
196196
}
@@ -308,7 +308,7 @@ private void setChildrenVisible(boolean visible) {
308308
}
309309

310310
@Override
311-
public boolean keyPressed(KeyEvent event) {
311+
public boolean keyPressed(@NotNull KeyEvent event) {
312312
if (overlay != null) {
313313
if (event.key() == InputConstants.KEY_ESCAPE) {
314314
overlay.onClose();
@@ -323,7 +323,7 @@ public boolean keyPressed(KeyEvent event) {
323323
}
324324

325325
@Override
326-
public boolean charTyped(CharacterEvent event) {
326+
public boolean charTyped(@NotNull CharacterEvent event) {
327327
if (overlay != null) {
328328
overlay.charTyped(event);
329329
return true;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
import net.minecraft.client.gui.components.toasts.ToastManager;
2424
import net.minecraft.client.renderer.RenderPipelines;
2525
import net.minecraft.network.chat.Component;
26-
import net.minecraft.resources.ResourceLocation;
26+
import net.minecraft.resources.Identifier;
2727
import net.minecraft.util.FormattedCharSequence;
2828
import org.jetbrains.annotations.NotNull;
2929

3030
import java.util.List;
3131

3232
public class NotificationToast implements Toast {
3333

34-
private static final ResourceLocation BACKGROUND_SPRITE =
35-
ResourceLocation.withDefaultNamespace("toast/advancement");
34+
private static final Identifier BACKGROUND_SPRITE =
35+
Identifier.withDefaultNamespace("toast/advancement");
3636
private static final int WIDTH = 160;
3737
private static final int HEIGHT = 32;
3838
private static final int X_MARGIN = 10;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/**
2525
* A {@link Button} that must be pressed twice to complete an action.
2626
*/
27-
public class ConfirmButton extends Button {
27+
public class ConfirmButton extends Button.Plain {
2828

2929
private Component message;
3030
private Component confirmMessage;
@@ -64,7 +64,7 @@ public void setConfirmMessage(@NotNull Component confirmMessage) {
6464
}
6565

6666
@Override
67-
public void onPress(InputWithModifiers input) {
67+
public void onPress(@NotNull InputWithModifiers input) {
6868
if (!hasBeenPressed) {
6969
hasBeenPressed = true;
7070
super.setMessage(confirmMessage);

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import net.minecraft.client.input.MouseButtonEvent;
3030
import net.minecraft.client.renderer.RenderPipelines;
3131
import net.minecraft.network.chat.Component;
32-
import net.minecraft.resources.ResourceLocation;
32+
import net.minecraft.resources.Identifier;
3333
import net.minecraft.util.Mth;
3434
import org.jetbrains.annotations.NotNull;
3535
import org.jetbrains.annotations.Nullable;
@@ -46,27 +46,27 @@
4646
*/
4747
public class HorizontalList<E extends AbstractWidget> extends AbstractContainerWidget {
4848

49-
private static final ResourceLocation LEFT_SEPARATOR =
50-
ResourceLocation.fromNamespaceAndPath(
49+
private static final Identifier LEFT_SEPARATOR =
50+
Identifier.fromNamespaceAndPath(
5151
ChatNotify.MOD_ID,
5252
"textures/gui/left_separator.png"
5353
);
54-
private static final ResourceLocation RIGHT_SEPARATOR =
55-
ResourceLocation.fromNamespaceAndPath(
54+
private static final Identifier RIGHT_SEPARATOR =
55+
Identifier.fromNamespaceAndPath(
5656
ChatNotify.MOD_ID,
5757
"textures/gui/right_separator.png"
5858
);
59-
private static final ResourceLocation MENU_LIST_BACKGROUND =
60-
ResourceLocation.withDefaultNamespace(
59+
private static final Identifier MENU_LIST_BACKGROUND =
60+
Identifier.withDefaultNamespace(
6161
"textures/gui/menu_list_background.png"
6262
);
63-
private static final ResourceLocation SCROLLER_SPRITE =
64-
ResourceLocation.fromNamespaceAndPath(
63+
private static final Identifier SCROLLER_SPRITE =
64+
Identifier.fromNamespaceAndPath(
6565
ChatNotify.MOD_ID,
6666
"widget/scroller_horizontal"
6767
);
68-
private static final ResourceLocation SCROLLER_BACKGROUND_SPRITE =
69-
ResourceLocation.fromNamespaceAndPath(
68+
private static final Identifier SCROLLER_BACKGROUND_SPRITE =
69+
Identifier.fromNamespaceAndPath(
7070
ChatNotify.MOD_ID,
7171
"widget/scroller_background_horizontal"
7272
);
@@ -419,7 +419,7 @@ protected void ensureVisible(E entry) {
419419
// Scrolling
420420

421421
@Override
422-
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
422+
public boolean mouseClicked(@NotNull MouseButtonEvent event, boolean doubleClick) {
423423
updateScrollingState(event);
424424
if (!isMouseOver(event.x(), event.y())) {
425425
return false;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import net.minecraft.client.input.MouseButtonEvent;
2323
import net.minecraft.client.input.MouseButtonInfo;
2424
import net.minecraft.network.chat.Component;
25+
import org.jetbrains.annotations.NotNull;
2526
import org.lwjgl.glfw.GLFW;
2627

2728
/**
@@ -31,7 +32,7 @@
3132
* {@link net.minecraft.client.gui.components.ContainerObjectSelectionList}, the parent element must
3233
* also be modified to accept right clicks.
3334
*/
34-
public class RightClickableButton extends Button {
35+
public class RightClickableButton extends Button.Plain {
3536

3637
protected final OnPress onRightPress;
3738

@@ -53,7 +54,7 @@ public void onRightPress() {
5354
}
5455

5556
@Override
56-
public void onClick(MouseButtonEvent event, boolean doubleClick) {
57+
public void onClick(@NotNull MouseButtonEvent event, boolean doubleClick) {
5758
if (GLFW.glfwGetMouseButton(
5859
Minecraft.getInstance().getWindow().handle(),
5960
InputConstants.MOUSE_BUTTON_RIGHT
@@ -65,7 +66,7 @@ public void onClick(MouseButtonEvent event, boolean doubleClick) {
6566
}
6667

6768
@Override
68-
protected boolean isValidClickButton(MouseButtonInfo info) {
69+
protected boolean isValidClickButton(@NotNull MouseButtonInfo info) {
6970
return super.isValidClickButton(info) || info.button() == InputConstants.MOUSE_BUTTON_RIGHT;
7071
}
7172
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/**
2525
* A {@link Button} that does not play a sound when pressed.
2626
*/
27-
public class SilentButton extends Button {
27+
public class SilentButton extends Button.Plain {
2828

2929
public SilentButton(int x, int y, int width, int height, Component message, OnPress onPress) {
3030
super(x, y, width, height, message, onPress, DEFAULT_NARRATION);

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/field/DropdownTextField.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import net.minecraft.client.resources.sounds.SoundInstance;
3535
import net.minecraft.client.sounds.SoundManager;
3636
import net.minecraft.network.chat.Component;
37-
import net.minecraft.resources.ResourceLocation;
37+
import net.minecraft.resources.Identifier;
3838
import net.minecraft.sounds.SoundSource;
3939
import org.jetbrains.annotations.NotNull;
4040
import org.jetbrains.annotations.Nullable;
@@ -208,7 +208,7 @@ private void valueResponder(String str) {
208208
}
209209

210210
@Override
211-
public boolean keyPressed(KeyEvent event) {
211+
public boolean keyPressed(@NotNull KeyEvent event) {
212212
// Only textField can handle key presses
213213
if (textField.isFocused()) {
214214
if (!dropdown.isEmpty()) {
@@ -247,7 +247,7 @@ private void tabDown() {
247247
}
248248

249249
@Override
250-
public boolean charTyped(CharacterEvent event) {
250+
public boolean charTyped(@NotNull CharacterEvent event) {
251251
if (textField.isFocused()) {
252252
return textField.charTyped(event);
253253
}
@@ -282,7 +282,7 @@ public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
282282
}
283283

284284
@Override
285-
public boolean mouseDragged(MouseButtonEvent event, double deltaX, double deltaY) {
285+
public boolean mouseDragged(@NotNull MouseButtonEvent event, double deltaX, double deltaY) {
286286
if (textField.isFocused() && mouseOnWidget(textField, event.x(), event.y())) {
287287
return textField.mouseDragged(event, deltaX, deltaY);
288288
} else {
@@ -361,7 +361,7 @@ public static DropdownWidget create(
361361
}
362362

363363
@Override
364-
public void onClick(MouseButtonEvent event, boolean doubleClick) {
364+
public void onClick(@NotNull MouseButtonEvent event, boolean doubleClick) {
365365
consumer.accept(getMessage().getString());
366366
}
367367
}
@@ -399,7 +399,7 @@ public void playDownSound(@NotNull SoundManager soundManager) {
399399
if (lastSound != null)
400400
soundManager.stop(lastSound);
401401
lastSound = new SimpleSoundInstance(
402-
ResourceLocation.parse(getMessage().getString()),
402+
Identifier.parse(getMessage().getString()),
403403
SoundSource.MASTER,
404404
1.0F,
405405
1.0F,

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/field/FakeTextField.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package dev.terminalmc.chatnotify.gui.widget.field;
1818

1919
import net.minecraft.client.input.MouseButtonEvent;
20+
import org.jetbrains.annotations.NotNull;
2021

2122
/**
2223
* A {@link TextField} which renders like a normal editable field, but when clicked, runs a custom
@@ -47,7 +48,7 @@ public boolean isMouseOver(double mouseX, double mouseY) {
4748
}
4849

4950
@Override
50-
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
51+
public boolean mouseClicked(@NotNull MouseButtonEvent event, boolean doubleClick) {
5152
if (isMouseOver(event.x(), event.y())) {
5253
onClick(event, doubleClick);
5354
return true;
@@ -56,7 +57,7 @@ public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
5657
}
5758

5859
@Override
59-
public void onClick(MouseButtonEvent event, boolean doubleClick) {
60+
public void onClick(@NotNull MouseButtonEvent event, boolean doubleClick) {
6061
onClick.run();
6162
}
6263
}

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/field/MultiLineTextField.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import dev.terminalmc.chatnotify.mixin.accessor.MultiLineEditBoxAccessor;
2121
import dev.terminalmc.chatnotify.mixin.accessor.MultilineTextFieldAccessor;
2222
import dev.terminalmc.chatnotify.mixin.accessor.StringViewAccessor;
23-
import net.minecraft.Util;
2423
import net.minecraft.client.Minecraft;
2524
import net.minecraft.client.gui.Font;
2625
import net.minecraft.client.gui.components.MultiLineEditBox;
@@ -30,6 +29,7 @@
3029
import net.minecraft.client.input.KeyEvent;
3130
import net.minecraft.client.input.MouseButtonEvent;
3231
import net.minecraft.network.chat.Component;
32+
import net.minecraft.util.Util;
3333
import org.jetbrains.annotations.NotNull;
3434
import org.jetbrains.annotations.Nullable;
3535

@@ -189,7 +189,7 @@ public void setWidth(int width) {
189189
// Chained clicks
190190

191191
@Override
192-
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
192+
public boolean mouseClicked(@NotNull MouseButtonEvent event, boolean doubleClick) {
193193
if (super.mouseClicked(event, doubleClick)) {
194194
// Double-click to select all
195195
long time = Util.getMillis();
@@ -249,7 +249,7 @@ private void updateHistory(String str) {
249249
}
250250

251251
@Override
252-
public boolean keyPressed(KeyEvent event) {
252+
public boolean keyPressed(@NotNull KeyEvent event) {
253253
if (!super.keyPressed(event)) {
254254
if (TextField.isUndo(event)) {
255255
undo();

0 commit comments

Comments
 (0)