|
16 | 16 |
|
17 | 17 | import org.lwjgl.glfw.GLFW; |
18 | 18 |
|
| 19 | +import net.minecraft.client.gui.Click; |
19 | 20 | import net.minecraft.client.gui.DrawContext; |
20 | 21 | import net.minecraft.client.gui.Drawable; |
21 | 22 | import net.minecraft.client.gui.screen.Screen; |
22 | 23 | import net.minecraft.client.gui.widget.ButtonWidget; |
23 | 24 | import net.minecraft.client.gui.widget.TextFieldWidget; |
| 25 | +import net.minecraft.client.input.KeyInput; |
24 | 26 | import net.minecraft.text.OrderedText; |
25 | 27 | import net.minecraft.text.Style; |
26 | 28 | import net.minecraft.text.Text; |
@@ -66,12 +68,9 @@ public final void init() |
66 | 68 | passwordBox = new TextFieldWidget(textRenderer, width / 2 - 100, 100, |
67 | 69 | 200, 20, Text.literal("")); |
68 | 70 | passwordBox.setText(getDefaultPassword()); |
69 | | - passwordBox.setRenderTextProvider((text, int_1) -> { |
70 | | - String stars = ""; |
71 | | - for(int i = 0; i < text.length(); i++) |
72 | | - stars += "*"; |
73 | | - return OrderedText.styledForwardsVisitedString(stars, Style.EMPTY); |
74 | | - }); |
| 71 | + passwordBox.addFormatter( |
| 72 | + (text, startIndex) -> OrderedText.styledForwardsVisitedString( |
| 73 | + "*".repeat(text.length()), Style.EMPTY)); |
75 | 74 | passwordBox.setMaxLength(256); |
76 | 75 | addSelectableChild(passwordBox); |
77 | 76 |
|
@@ -203,30 +202,30 @@ private final String stealSkin(String name) |
203 | 202 | } |
204 | 203 |
|
205 | 204 | @Override |
206 | | - public boolean keyPressed(int keyCode, int scanCode, int int_3) |
| 205 | + public boolean keyPressed(KeyInput context) |
207 | 206 | { |
208 | | - if(keyCode == GLFW.GLFW_KEY_ENTER) |
209 | | - doneButton.onPress(); |
| 207 | + if(context.key() == GLFW.GLFW_KEY_ENTER) |
| 208 | + doneButton.onPress(context); |
210 | 209 |
|
211 | | - return super.keyPressed(keyCode, scanCode, int_3); |
| 210 | + return super.keyPressed(context); |
212 | 211 | } |
213 | 212 |
|
214 | 213 | @Override |
215 | | - public boolean mouseClicked(double x, double y, int button) |
| 214 | + public boolean mouseClicked(Click context, boolean doubleClick) |
216 | 215 | { |
217 | | - nameOrEmailBox.mouseClicked(x, y, button); |
218 | | - passwordBox.mouseClicked(x, y, button); |
| 216 | + nameOrEmailBox.mouseClicked(context, doubleClick); |
| 217 | + passwordBox.mouseClicked(context, doubleClick); |
219 | 218 |
|
220 | 219 | if(nameOrEmailBox.isFocused() || passwordBox.isFocused()) |
221 | 220 | message = ""; |
222 | 221 |
|
223 | | - if(button == GLFW.GLFW_MOUSE_BUTTON_4) |
| 222 | + if(context.button() == GLFW.GLFW_MOUSE_BUTTON_4) |
224 | 223 | { |
225 | 224 | close(); |
226 | 225 | return true; |
227 | 226 | } |
228 | 227 |
|
229 | | - return super.mouseClicked(x, y, button); |
| 228 | + return super.mouseClicked(context, doubleClick); |
230 | 229 | } |
231 | 230 |
|
232 | 231 | @Override |
|
0 commit comments