Skip to content

Commit 78852cd

Browse files
VerschlxfeneWide-Cat
authored andcommitted
Fix account & proxy button breaking when resizing the multiplayer screen
Minecraft now caches the elements added there and only updates positions on resizing. I also removed the comment since this is normal practice when the target class doesn't override a function from the superclass. Signed-off-by: Verschlxfene <admin@verschlxfene.xyz>
1 parent 92ea89c commit 78852cd

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

src/main/java/meteordevelopment/meteorclient/mixin/MultiplayerScreenMixin.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,43 @@ public abstract class MultiplayerScreenMixin extends Screen {
3636
@Unique
3737
private int loggedInAsLength;
3838

39+
@Unique
40+
private ButtonWidget accounts;
41+
42+
@Unique
43+
private ButtonWidget proxies;
44+
3945
public MultiplayerScreenMixin(Text title) {
4046
super(title);
4147
}
4248

43-
@Inject(method = "init", at = @At("TAIL"))
49+
@Inject(method = "refreshWidgetPositions", at = @At("TAIL"))
4450
private void onInit(CallbackInfo info) {
4551
textColor1 = Color.fromRGBA(255, 255, 255, 255);
4652
textColor2 = Color.fromRGBA(175, 175, 175, 255);
4753

4854
loggedInAs = "Logged in as ";
4955
loggedInAsLength = textRenderer.getWidth(loggedInAs);
5056

51-
addDrawableChild(
52-
new ButtonWidget.Builder(Text.literal("Accounts"), button -> client.setScreen(GuiThemes.get().accountsScreen()))
53-
.position(this.width - 75 - 3, 3)
54-
.size(75, 20)
55-
.build()
56-
);
57-
58-
addDrawableChild(
59-
new ButtonWidget.Builder(Text.literal("Proxies"), button -> client.setScreen(GuiThemes.get().proxiesScreen()))
60-
.position(this.width - 75 - 3 - 75 - 2, 3)
61-
.size(75, 20)
62-
.build()
63-
);
57+
if (accounts == null) {
58+
accounts = addDrawableChild(
59+
new ButtonWidget.Builder(Text.literal("Accounts"), button -> client.setScreen(GuiThemes.get().accountsScreen()))
60+
.size(75, 20)
61+
.build()
62+
);
63+
}
64+
accounts.setPosition(this.width - 75 - 3, 3);
65+
66+
if (proxies == null) {
67+
proxies = addDrawableChild(
68+
new ButtonWidget.Builder(Text.literal("Proxies"), button -> client.setScreen(GuiThemes.get().proxiesScreen()))
69+
.size(75, 20)
70+
.build()
71+
);
72+
}
73+
proxies.setPosition(this.width - 75 - 3 - 75 - 2, 3);
6474
}
6575

66-
// todo this is probably an extremely bad way of doing it but it works for now
6776
@Override
6877
public void render(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
6978
super.render(context, mouseX, mouseY, deltaTicks);

0 commit comments

Comments
 (0)