Search in sources :

Example 1 with ItemElement

use of slimeknights.mantle.client.screen.book.element.ItemElement in project TinkersConstruct by SlimeKnights.

the class ContentMaterialSkull method addPrimaryDisplayItems.

@Override
protected void addPrimaryDisplayItems(List<ItemElement> displayTools, MaterialVariantId materialId) {
    displayTools.add(new TinkerItemElement(TinkerToolParts.repairKit.get().withMaterialForDisplay(materialId)));
    super.addPrimaryDisplayItems(displayTools, materialId);
    // add skull recipe to display items
    IDisplayableCastingRecipe skullRecipe = getSkullRecipe();
    if (skullRecipe != null) {
        // add repair kit
        List<ItemStack> casts = skullRecipe.getCastItems();
        if (!casts.isEmpty()) {
            ItemElement elementItem = new TinkerItemElement(0, 0, 1, casts);
            elementItem.tooltip = ImmutableList.of(new TranslatableComponent(SKULL_FROM, casts.get(0).getHoverName()));
            displayTools.add(elementItem);
        }
    }
}
Also used : ItemElement(slimeknights.mantle.client.screen.book.element.ItemElement) TinkerItemElement(slimeknights.tconstruct.library.client.book.elements.TinkerItemElement) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TinkerItemElement(slimeknights.tconstruct.library.client.book.elements.TinkerItemElement) IDisplayableCastingRecipe(slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe) ItemStack(net.minecraft.world.item.ItemStack)

Example 2 with ItemElement

use of slimeknights.mantle.client.screen.book.element.ItemElement in project TinkersConstruct by SlimeKnights.

the class ContentPageIconList method build.

@Override
public void build(BookData book, ArrayList<BookElement> list, boolean rightSide) {
    int yOff = 0;
    if (this.title != null) {
        this.addTitle(list, this.title, false);
        yOff = getTitleHeight();
    }
    if (this.subText != null) {
        int height = this.addText(list, this.subText, false, 0, yOff);
        yOff = height + 16;
    }
    int offset = 15;
    int x = offset;
    int y = yOff;
    int pageW = BookScreen.PAGE_WIDTH - 2 * offset;
    int pageH = BookScreen.PAGE_HEIGHT - yOff;
    float scale = this.maxScale;
    int scaledWidth = this.width;
    int scaledHeight = this.height;
    boolean fits = false;
    while (!fits && scale > 1f) {
        scale -= 0.25f;
        scaledWidth = (int) (this.width * scale);
        scaledHeight = (int) (this.height * scale);
        int rows = pageW / scaledWidth;
        int cols = pageH / scaledHeight;
        fits = rows * cols >= this.elements.size();
    }
    for (PageIconLinkElement element : this.elements) {
        element.x = x;
        element.y = y;
        element.displayElement.x = x + (int) (scale * (this.width - element.displayElement.width) / 2);
        element.displayElement.y = y + (int) (scale * (this.height - element.displayElement.height) / 2);
        element.width = scaledWidth;
        element.height = scaledHeight;
        if (element.displayElement instanceof ItemElement) {
            ((ItemElement) element.displayElement).scale = scale;
        }
        list.add(element);
        x += scaledWidth;
        if (x > BookScreen.PAGE_WIDTH - offset - scaledWidth) {
            x = offset;
            y += scaledHeight;
            // do not draw over the page
            if (y > BookScreen.PAGE_HEIGHT - scaledHeight) {
                break;
            }
        }
    }
}
Also used : PageIconLinkElement(slimeknights.tconstruct.library.client.book.elements.PageIconLinkElement) ItemElement(slimeknights.mantle.client.screen.book.element.ItemElement)

Example 3 with ItemElement

use of slimeknights.mantle.client.screen.book.element.ItemElement 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

ItemElement (slimeknights.mantle.client.screen.book.element.ItemElement)3 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 ItemStack (net.minecraft.world.item.ItemStack)1 PageData (slimeknights.mantle.client.book.data.PageData)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 PageIconLinkElement (slimeknights.tconstruct.library.client.book.elements.PageIconLinkElement)1 TinkerItemElement (slimeknights.tconstruct.library.client.book.elements.TinkerItemElement)1 IMaterial (slimeknights.tconstruct.library.materials.definition.IMaterial)1 MaterialId (slimeknights.tconstruct.library.materials.definition.MaterialId)1 IDisplayableCastingRecipe (slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe)1