public PageData findPage(int number, @Nullable GuiBook.AdvancementCache advancementCache) { if(number < 0) { return null; } int pages = 0; for(SectionData section : sections) { section.update(advancementCache); if(!section.isUnlocked(advancementCache)) { continue; } if(pages + section.getPageCount() > number) { return section.pages.get(number - pages); } else { pages += section.getPageCount(); } } return null; }
public int getPageCount(@Nullable GuiBook.AdvancementCache advancementCache) { int pages = 0; for(SectionData section : sections) { section.update(advancementCache); pages += section.isUnlocked(advancementCache) ? section.getPageCount() : 0; } return pages; }
public int findPageNumber(String location, @Nullable GuiBook.AdvancementCache advancementCache) { location = location.toLowerCase(); int pages = 0; if(!location.contains(".")) { return -1; } String sectionName = location.substring(0, location.indexOf('.')); String pageName = location.substring(location.indexOf('.') + 1); for(SectionData section : sections) { section.update(advancementCache); if(!section.isUnlocked(advancementCache)) { continue; } if(!sectionName.equals(section.name)) { pages += section.getPageCount(); continue; } for(PageData page : section.pages) { if(!pageName.equals(page.name)) { pages++; continue; } return pages + 1; } } return -1; }
public int getFirstPageNumber(SectionData section, @Nullable GuiBook.AdvancementCache advancementCache) { int pages = 0; for(SectionData sect : sections) { sect.update(advancementCache); if(section == sect) { return section.isUnlocked(advancementCache) ? pages + 1 : -1; } if(!sect.isUnlocked(advancementCache)) { continue; } pages += sect.getPageCount(); } return -1; }
int genPages = (int) Math.ceil(section.getPageCount() * 1.F / ENTRIES_PER_PAGE); pages[i].name = "tableofcontents" + i; TextData[] text = new TextData[i > pages.length - 1 ? ENTRIES_PER_PAGE : section .getPageCount() - (genPages - 1) * ENTRIES_PER_PAGE]; for(int j = 0; j < text.length; j++) { text[j] = new TextData((i * ENTRIES_PER_PAGE + j + 1) + ". " + section.pages.get(i * ENTRIES_PER_PAGE + j)