Search in sources :

Example 1 with ContentPageIconList

use of slimeknights.tconstruct.library.client.book.content.ContentPageIconList in project TinkersConstruct by SlimeKnights.

the class AbstractMaterialSectionTransformer method transform.

@Override
public void transform(BookData book, SectionData sectionData) {
    sectionData.source = BookRepository.DUMMY;
    sectionData.parent = book;
    List<IMaterial> materialList = MaterialRegistry.getMaterials().stream().filter(this::isValidMaterial).toList();
    if (materialList.isEmpty()) {
        return;
    }
    // calculate pages needed
    List<ContentPageIconList> listPages = ContentPageIconList.getPagesNeededForItemCount(materialList.size(), sectionData, book.translate(this.sectionName), book.strings.get(String.format("%s.subtext", this.sectionName)));
    ListIterator<ContentPageIconList> iter = listPages.listIterator();
    ContentPageIconList overview = iter.next();
    for (IMaterial material : materialList) {
        MaterialId materialId = material.getIdentifier();
        ContentMaterial contentMaterial = this.getPageContent(materialId);
        PageData page = this.addPage(sectionData, materialId.toString(), ContentMaterial.ID, contentMaterial);
        SizedBookElement icon = new ItemElement(0, 0, 1f, contentMaterial.getDisplayStacks());
        while (!overview.addLink(icon, contentMaterial.getTitleComponent(), page)) {
            overview = iter.next();
        }
    }
}
Also used : ItemElement(slimeknights.mantle.client.screen.book.element.ItemElement) IMaterial(slimeknights.tconstruct.library.materials.definition.IMaterial) ContentPageIconList(slimeknights.tconstruct.library.client.book.content.ContentPageIconList) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) PageData(slimeknights.mantle.client.book.data.PageData) SizedBookElement(slimeknights.mantle.client.screen.book.element.SizedBookElement) ContentMaterial(slimeknights.tconstruct.library.client.book.content.ContentMaterial)

Aggregations

PageData (slimeknights.mantle.client.book.data.PageData)1 ItemElement (slimeknights.mantle.client.screen.book.element.ItemElement)1 SizedBookElement (slimeknights.mantle.client.screen.book.element.SizedBookElement)1 ContentMaterial (slimeknights.tconstruct.library.client.book.content.ContentMaterial)1 ContentPageIconList (slimeknights.tconstruct.library.client.book.content.ContentPageIconList)1 IMaterial (slimeknights.tconstruct.library.materials.definition.IMaterial)1 MaterialId (slimeknights.tconstruct.library.materials.definition.MaterialId)1