Skip to content

Commit

Permalink
Fix Server Links button on top of Mods button in Insert mode
Browse files Browse the repository at this point in the history
- Fixed "Server Links" button overlapping Mods button in "Insert" mode
  • Loading branch information
Prospector committed Jun 21, 2024
1 parent fc50c22 commit bfa093d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.text.TranslatableTextContent;
import net.minecraft.util.Identifier;

import java.util.Arrays;
import java.util.List;

public class ModMenuEventHandler {
Expand Down Expand Up @@ -133,12 +134,13 @@ private static void onClientEndTick(MinecraftClient client) {
}
}

public static boolean buttonHasText(Widget widget, String translationKey) {
public static boolean buttonHasText(Widget widget, String... translationKeys) {
if (widget instanceof ButtonWidget button) {
Text text = button.getMessage();
TextContent textContent = text.getContent();
return textContent instanceof TranslatableTextContent &&
((TranslatableTextContent) textContent).getKey().equals(translationKey);

return textContent instanceof TranslatableTextContent && Arrays.stream(translationKeys)
.anyMatch(s -> ((TranslatableTextContent) textContent).getKey().equals(s));
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void onInitWidgets(CallbackInfo ci, GridWidget gridWidget, GridWidget.Ad
Widget widget = buttons.get(i);
if (style == ModMenuConfig.GameMenuButtonStyle.INSERT) {
if (!(widget instanceof ClickableWidget button) || button.visible) {
ModMenuEventHandler.shiftButtons(widget, modsButtonIndex == -1 || ModMenuEventHandler.buttonHasText(widget, "menu.reportBugs"), spacing);
ModMenuEventHandler.shiftButtons(widget, modsButtonIndex == -1 || ModMenuEventHandler.buttonHasText(widget, "menu.reportBugs", "menu.server_links"), spacing);
if (modsButtonIndex == -1) {
buttonsY = widget.getY();
}
Expand Down

0 comments on commit bfa093d

Please sign in to comment.