Skip to content

Commit

Permalink
Merge pull request #4 from CrystalMoling/master
Browse files Browse the repository at this point in the history
Fix extra page problem
  • Loading branch information
ToberoCat committed Aug 9, 2023
2 parents 8fea260 + ff7e0a4 commit 78bd049
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public void addPage(@NotNull GuiContext page, int position) {
public void addComponent(@NotNull GuiComponent component) {
assert null != api;

if (currentPatternIndex >= pattern.length) {
currentPatternIndex = 0;
addPage(createEmptyPage());
}

GuiContext page = pages.get(pages.size() - 1);
int slot = pattern[currentPatternIndex];
currentPatternIndex++;
Expand All @@ -147,9 +152,6 @@ public void addComponent(@NotNull GuiComponent component) {
page.add(api, component);

embedded = pages.get(Math.min(showingPage, pages.size() - 1));
if (currentPatternIndex < pattern.length) return;
currentPatternIndex = 0;
addPage(createEmptyPage());
}

@Override
Expand Down

0 comments on commit 78bd049

Please sign in to comment.