Skip to content

Commit

Permalink
Fix pause screen crash
Browse files Browse the repository at this point in the history
- Fixed a crash on the pause screen
  • Loading branch information
jackassmc committed Dec 10, 2022
1 parent 238f611 commit 762b7af
Showing 1 changed file with 30 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,40 +93,42 @@ private static void afterTitleScreenInit(Screen screen) {
}

private static void afterGameMenuScreenInit(Screen screen) {
GridWidget grid = (GridWidget) Screens.getButtons(screen).get(0);
final List<ClickableWidget> buttons = ((IGridWidgetAccessor) grid).getChildren();
if (ModMenuConfig.MODIFY_GAME_MENU.getValue()) {
int modsButtonIndex = -1;
final int spacing = 24;
int buttonsY = screen.height / 4 + 8;
ModMenuConfig.ModsButtonStyle style = ModMenuConfig.MODS_BUTTON_STYLE.getValue().forGameMenu();
for (int i = 0; i < buttons.size(); i++) {
ClickableWidget button = buttons.get(i);
if (style == ModMenuConfig.ModsButtonStyle.CLASSIC) {
if (button.visible) {
shiftButtons(button, modsButtonIndex == -1, spacing);
if (modsButtonIndex == -1) {
buttonsY = button.getY();
ClickableWidget widget = Screens.getButtons(screen).get(0);
if (widget instanceof GridWidget) {
final List<ClickableWidget> buttons = ((IGridWidgetAccessor) widget).getChildren();
if (ModMenuConfig.MODIFY_GAME_MENU.getValue()) {
int modsButtonIndex = -1;
final int spacing = 24;
int buttonsY = screen.height / 4 + 8;
ModMenuConfig.ModsButtonStyle style = ModMenuConfig.MODS_BUTTON_STYLE.getValue().forGameMenu();
for (int i = 0; i < buttons.size(); i++) {
ClickableWidget button = buttons.get(i);
if (style == ModMenuConfig.ModsButtonStyle.CLASSIC) {
if (button.visible) {
shiftButtons(button, modsButtonIndex == -1, spacing);
if (modsButtonIndex == -1) {
buttonsY = button.getY();
}
}
}
}
if (buttonHasText(button, "menu.reportBugs")) {
modsButtonIndex = i + 1;
if (style == ModMenuConfig.ModsButtonStyle.SHRINK) {
buttons.set(i, new ModMenuButtonWidget(button.getX(), button.getY(), button.getWidth(), button.getHeight(), ModMenuApi.createModsButtonText(), screen));
} else {
if (buttonHasText(button, "menu.reportBugs")) {
modsButtonIndex = i + 1;
if (button.visible) {
buttonsY = button.getY();
if (style == ModMenuConfig.ModsButtonStyle.SHRINK) {
buttons.set(i, new ModMenuButtonWidget(button.getX(), button.getY(), button.getWidth(), button.getHeight(), ModMenuApi.createModsButtonText(), screen));
} else {
modsButtonIndex = i + 1;
if (button.visible) {
buttonsY = button.getY();
}
}
}
}
}
if (modsButtonIndex != -1) {
if (style == ModMenuConfig.ModsButtonStyle.CLASSIC) {
buttons.add(modsButtonIndex, new ModMenuButtonWidget(screen.width / 2 - 102, buttonsY + spacing, 204, 20, ModMenuApi.createModsButtonText(), screen));
} else if (style == ModMenuConfig.ModsButtonStyle.ICON) {
buttons.add(modsButtonIndex, new ModMenuTexturedButtonWidget(screen.width / 2 + 4 + 100 + 2, screen.height / 4 + 72 - 16, 20, 20, 0, 0, FABRIC_ICON_BUTTON_LOCATION, 32, 64, button -> MinecraftClient.getInstance().setScreen(new ModsScreen(screen)), ModMenuApi.createModsButtonText()));
if (modsButtonIndex != -1) {
if (style == ModMenuConfig.ModsButtonStyle.CLASSIC) {
buttons.add(modsButtonIndex, new ModMenuButtonWidget(screen.width / 2 - 102, buttonsY + spacing, 204, 20, ModMenuApi.createModsButtonText(), screen));
} else if (style == ModMenuConfig.ModsButtonStyle.ICON) {
buttons.add(modsButtonIndex, new ModMenuTexturedButtonWidget(screen.width / 2 + 4 + 100 + 2, screen.height / 4 + 72 - 16, 20, 20, 0, 0, FABRIC_ICON_BUTTON_LOCATION, 32, 64, button -> MinecraftClient.getInstance().setScreen(new ModsScreen(screen)), ModMenuApi.createModsButtonText()));
}
}
}
}
Expand Down

0 comments on commit 762b7af

Please sign in to comment.