Player Inventory Template - landonjw/GooeyLibs GitHub Wiki

An InventoryTemplate is a special template that is used to represent the player's inventory on a Page. This has an identical builder to the ChestTemplate.

This template is often used in conjunction to InventoryListenerButtons in order to mock the users inventory with additional logic when clicked.

When a page is opened with a defined InventoryTemplate, it will appear as though the users inventory has been modified, but it is purely client-side, and the inventories original contents will be refreshed upon the container being closed.

An example of using a PlayerInventoryTemplate is:

        GooeyButton diamond = GooeyButton.builder()
                .display(new ItemStack(Items.DIAMOND))
                .build();

        GooeyButton emerald = GooeyButton.builder()
                .display(new ItemStack(Items.EMERALD))
                .build();

        GooeyButton dirt = GooeyButton.builder()
                .display(new ItemStack(Blocks.DIRT))
                .build();

        ChestTemplate template = ChestTemplate.builder(6)
                .fill(diamond)
                .build();

        InventoryTemplate playerInvTemplate = InventoryTemplate.builder()
                .row(1, diamond) // Sets the second row to diamond
                .column(2, dirt) // Sets the third column to dirt
                .set(0, 1, emerald) // Sets the slot in the first row and second column to emerald
                .build();

        GooeyPage gooeyPage = GooeyPage.builder()
                .template(template)
                .inventory(playerInvTemplate) // Adds the inventory template to the page
                .build();

This example will produce a template with the following results