From ecafafe57e667b3064036caea269a1eacb504962 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 12 Nov 2016 16:06:30 +0100 Subject: [PATCH] Fix a crash when typing in the search bar ~ --- .../actuallyadditions/mod/booklet/gui/GuiEntry.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java index 574a00231..865be4d18 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java @@ -44,8 +44,13 @@ public class GuiEntry extends GuiBooklet{ this.focusSearch = focusSearch; this.chapters = entry.getChaptersForDisplay(search); - IBookletChapter lastChap = this.chapters.get(this.chapters.size()-1); - this.pageAmount = lastChap == null ? 1 : calcEntryPage(this.entry, lastChap, this.searchText)+1; + if(!this.chapters.isEmpty()){ + IBookletChapter lastChap = this.chapters.get(this.chapters.size()-1); + this.pageAmount = lastChap == null ? 1 : calcEntryPage(this.entry, lastChap, this.searchText)+1; + } + else{ + this.pageAmount = 1; + } } public GuiEntry(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, IBookletChapter chapterForPageCalc, String search, boolean focusSearch){