Skip to content

Commit 5714d3c

Browse files
committed
Fixed Duplicate Buttons Bug
1 parent e725ad2 commit 5714d3c

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ I did not, nor could I copy their code directly as most are Meteor based mods. S
344344
- Adds mixin buttons to disconnect/kick/ban screens for all cracked/offline servers that have the above functions
345345

346346
### CoordLogger
347-
- Detect world and local events and attempt to position it with ESP and chat messages
347+
- Detect world and local events and attempt to position them with ESP and chat messages
348348
- Events that are too far away the direction will be given
349349
- Toggles for various types of events
350350
- Toggles for debugging and ESP

src/main/java/net/wurstclient/WurstTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private boolean isBuiltInWurstResourcePack(Resource resource)
240240

241241
String id = knownPack.id();
242242
return "wurst".equals(id) || "wurst_testmod".equals(id)
243-
|| "nicewurst".equals(id);
243+
|| "vanilla".equals(id) || "nicewurst".equals(id);
244244
}
245245

246246
}

src/main/java/net/wurstclient/mixin/MultiplayerScreenMixin.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,32 @@ private void onInit(CallbackInfo ci)
5050
if(!WurstClient.INSTANCE.isEnabled())
5151
return;
5252

53-
lastServerButton =
54-
addRenderableWidget(
55-
Button
56-
.builder(Component.literal("Last Server"),
57-
b -> LastServerRememberer.joinLastServer(
58-
(JoinMultiplayerScreen)(Object)this))
59-
.bounds(width / 2 - 154, 10, 100, 20).build());
53+
JoinMultiplayerScreen mpScreen = (JoinMultiplayerScreen)(Object)this;
54+
55+
// Add Last Server button early for better tab navigation
56+
lastServerButton = Button
57+
.builder(Component.nullToEmpty("Last Server"),
58+
b -> LastServerRememberer.joinLastServer(mpScreen))
59+
.width(100).build();
60+
addRenderableWidget(lastServerButton);
61+
}
62+
63+
@Inject(at = @At(value = "INVOKE",
64+
target = "Lnet/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen;repositionElements()V",
65+
ordinal = 0), method = "init()V")
66+
private void afterVanillaButtons(CallbackInfo ci,
67+
@Local(ordinal = 1) LinearLayout footerTopRow,
68+
@Local(ordinal = 2) LinearLayout footerBottomRow)
69+
{
70+
if(!WurstClient.INSTANCE.isEnabled())
71+
return;
72+
// Footer buttons are not added here to avoid duplicates; corner buttons
73+
// are created/positioned in `repositionElements()` instead.
74+
}
75+
76+
@Inject(at = @At("TAIL"), method = "repositionElements()V")
77+
private void onRefreshWidgetPositions(CallbackInfo ci)
78+
{
6079
updateLastServerButton();
6180

6281
if(!WurstClient.INSTANCE.isEnabled())

0 commit comments

Comments
 (0)