From 9f853cf993b3d58d05d8a6c6d0e746479465f17d Mon Sep 17 00:00:00 2001 From: ParadoxGitHub <70107937+ParadoxGitHub@users.noreply.github.com> Date: Sat, 11 Mar 2023 17:42:41 -0500 Subject: [PATCH] fix password hiding --- .gitignore | 3 +- .../net/minecraft/client/gui/GuiChat.java | 3 ++ .../minecraft/client/gui/GuiTextField.java | 45 ++++++++++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d009412d..8f1bd563 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ desktopRuntime/eclipseProject/bin* desktopRuntime/hs_err_* desktopRuntime/crash-reports/* desktopRuntime/options.txt -desktopRuntime/_eagstorage* \ No newline at end of file +desktopRuntime/_eagstorage* +/.metadata/ diff --git a/src/main/java/net/minecraft/client/gui/GuiChat.java b/src/main/java/net/minecraft/client/gui/GuiChat.java index 7b442b14..f37c080b 100644 --- a/src/main/java/net/minecraft/client/gui/GuiChat.java +++ b/src/main/java/net/minecraft/client/gui/GuiChat.java @@ -284,6 +284,9 @@ public class GuiChat extends GuiScreen { GlUtils.startTranslate(0, 29 - (int) animation.getValue()); drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE); this.inputField.drawTextBox(); + if (this.inputField.isTypingPassword) + this.mc.fontRendererObj.drawStringWithShadow("Password Hidden", 2, this.height - 25, 16770425); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY()); if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) { diff --git a/src/main/java/net/minecraft/client/gui/GuiTextField.java b/src/main/java/net/minecraft/client/gui/GuiTextField.java index 70939a4f..83015915 100644 --- a/src/main/java/net/minecraft/client/gui/GuiTextField.java +++ b/src/main/java/net/minecraft/client/gui/GuiTextField.java @@ -66,6 +66,8 @@ public class GuiTextField extends Gui { private boolean visible = true; private GuiPageButtonList.GuiResponder field_175210_x; private Predicate field_175209_y = Predicates.alwaysTrue(); + + public boolean isTypingPassword = false; public GuiTextField(int componentId, FontRenderer fontrendererObj, int x, int y, int par5Width, int par6Height) { this.id = componentId; @@ -450,10 +452,49 @@ public class GuiTextField extends Gui { if (k > s.length()) { k = s.length(); } + + if (s.length() > 0) { - String s1 = flag ? s.substring(0, j) : s; - String s2 = s1.startsWith("/login ") ? "/login *" : s1.startsWith("/l ") ? "/l *" : s1; + + String s1 = flag ? s.substring(0, j) : s; + String s2 = s1; + + if (s1.startsWith("/l ") || s1.startsWith("/login ") || s1.startsWith("/log ")) { + s2 = ""; + String password = ""; + // password isnt sent anywhere, its just used for counting how many "*" you need for hiding the password. + + if (s1.startsWith("/l ")) { + s2 = s1.substring(0, 3); + password = s1.substring(3); + } + + if (s1.startsWith("/login ")) { + s2 = s1.substring(0, 7); + password = s1.substring(7); + } + + if (s1.startsWith("/log ")) { + s2 = s1.substring(0, 5); + password = s1.substring(7); + } + + if (password.length() > 0) { + isTypingPassword = true; + for (int n = 0; n < password.length(); n++) { + s2 += "*"; + } + } + + + + } + else { + isTypingPassword = false; + } + + j1 = this.fontRendererInstance.drawStringWithShadow(s2, (float) l, (float) i1, i); }