pages[i] = new PageData(true); pages[i].name = "tableofcontents" + i; TextData[] text = new TextData[i > pages.length - 1 ? ENTRIES_PER_PAGE : section 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) .getTitle()); text[j].action = "go-to-page-rtn:" + section.name + "." + section.pages.get(i * ENTRIES_PER_PAGE + j).name;
@Override public void update(GuiBook.AdvancementCache advancementCache) { pages.clear(); List<SectionData> visibleSections = parent.getVisibleSections(advancementCache); if(visibleSections.isEmpty()) { return; } visibleSections.remove(0); PageData[] pages = new PageData[(int) Math.ceil(visibleSections.size() / 9F)]; for(int i = 0; i < pages.length; i++) { pages[i] = new PageData(true); pages[i].name = "page" + (i + 1); ContentSectionList content = new ContentSectionList(); pages[i].content = content; for(int j = i * 9; j - i * 9 < 9 && j < visibleSections.size(); j++) { content.addSection(visibleSections.get(j)); } } this.pages = new ArrayList<>(Arrays.asList(pages)); } };
TextData head = new TextData(parent.translate("tool.properties")); head.underlined = true; list.add(new ElementText(padding, y, 86 - padding, GuiBook.PAGE_HEIGHT - h - 20, head));
SectionData error = new SectionData(); error.name = "errorenous"; PageData page = new PageData(true); page.name = "errorenous"; page.content = new ContentError("Failed to load repository " + repo.toString() + ".", e); SectionData section = new SectionData(true); section.name = "errorenous"; PageData page = new PageData(true); page.name = "errorenous"; page.content = new ContentError("Failed to load the book due to an unexpected error.", e);
ItemStack partbuilder = new ItemStack(TinkerTools.toolTables, 1, BlockToolTable.TableTypes.PartBuilder.meta); ElementItem elementItem = new ElementTinkerItem(partbuilder); elementItem.tooltip = ImmutableList.of(parent.translate("material.craft_partbuilder")); displayTools.add(elementItem); ItemStack basin = new ItemStack(TinkerSmeltery.castingBlock, 1, BlockCasting.CastingType.BASIN.getMeta()); ElementItem elementItem = new ElementTinkerItem(basin); String text = parent.translate("material.craft_casting"); elementItem.tooltip = ImmutableList.of(String.format(text, material.getFluid().getLocalizedName(new FluidStack(material.getFluid(), 0)))); displayTools.add(elementItem);
public static List<ContentPageIconList> getPagesNeededForItemCount(int count, SectionData data, String title) { List<ContentPageIconList> listPages = Lists.newArrayList(); while(count > 0) { ContentPageIconList overview = new ContentPageIconList(); PageData page = new PageData(true); page.source = data.source; page.parent = data; page.content = overview; page.load(); data.pages.add(page); overview.title = title; listPages.add(overview); count -= overview.getMaxIconCount(); } // ensure same size for all if(listPages.size() > 1) { listPages.forEach(page -> page.maxScale = 1f); } return listPages; } }
TextData head = new TextData(parent.translate("modifier.effect")); head.underlined = true; list.add(new ElementText(10, 20 + h, GuiBook.PAGE_WIDTH / 2 - 5, GuiBook.PAGE_HEIGHT - h - 20, head));
@Override public void transform(BookData book, SectionData data) { ContentListing listing = new ContentListing(); listing.title = book.translate(sectionName); PageData listingPage = new PageData(true); listingPage.name = sectionName; listingPage.source = data.source; listingPage.parent = data; listingPage.content = listing; data.pages.forEach(sectionPage -> processPage(book, listing, sectionPage)); if(listing.hasEntries()) { listingPage.load(); data.pages.add(0, listingPage); } }
@Override public void load() { if(name == null) { name = "section" + parent.unnamedSectionCounter++; } name = name.toLowerCase(); if(!data.equals("no-load")) { IResource pagesInfo = source.getResource(source.getResourceLocation(data)); if(pagesInfo != null) { String data = source.resourceToString(pagesInfo); if(!data.isEmpty()) { try { pages = new ArrayList<>(Arrays.asList(BookLoader.GSON.fromJson(data, PageData[].class))); } catch(Exception e) { pages = new ArrayList<>(); PageData pdError = new PageData(true); pdError.name = "errorrenous"; pdError.content = new ContentError("Failed to load section " + name + ".", e); pages.add(pdError); } } } } for(PageData page : pages) { page.parent = this; page.source = source; page.load(); } icon.location = source.getResourceLocation(icon.file, true); }