use of slimeknights.mantle.client.screen.book.element.SizedBookElement 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();
}
}
}
Aggregations