Template - landonjw/GooeyLibs GitHub Wiki
Template
A template contains the layout of buttons on the user interface. This can contain many buttons in order to make a page interactive, and often provides convenience methods for quickly designing user interfaces. Gooey 2.0 now provides several different interface types outside of chests.
ChestTemplate
An example of using ChestTemplate
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) // Defines a chest template with 6 rows
.set(0, 0, diamond) // Sets a diamond button in the first row, first column of chest
.row(1, emerald) // Fills the entire second row with the emerald button
.fill(dirt) // Fills any empty slots in the chest with dirt button
.build();
This example will produce a template with the following results
BrewingStandTemplate
An example of using a BrewingStandTemplate
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();
BrewingStandTemplate template = BrewingStandTemplate.builder()
.bottles(dirt) // Applies dirt button to all bottle slots
.bottle(0, diamond) // Applies diamond button to first bottle slot
.ingredient(emerald) // Applies emerald button to ingredient slot
.fuel(diamond) // Applies diamond button to fuel slot
.build();
This example will produce a template with the following results
CraftingTableTemplate
An example of using a CraftingTableTemplate
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();
CraftingTableTemplate template = CraftingTableTemplate.builder()
.fillGrid(dirt) // Fills the crafting grid with dirt button
.setGrid(0, 0, emerald) // Applies dirt button to first row and first column in crafting grid
.setResultItem(diamond) // Sets the resulting slot to diamond button
.build();
This example will produce a template with the following results
DispenserTemplate
An example of using a DispenserTemplate
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();
DispenserTemplate template = DispenserTemplate.builder()
.fill(dirt) // Fills all slots that are empty with dirt button
.set(0, diamond) // Sets the first slot to diamond button
.set(0, 1, emerald) // Sets the slot in first row and second column to emerald button
.build();
This example will produce a template with the following results
HopperTemplate
An example of using a HopperTemplate
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();
HopperTemplate template = HopperTemplate.builder()
.set(0, diamond)
.set(1, emerald)
.set(2, dirt)
.build();
This example will produce a template with the following results
FurnaceTemplate
An example of using a FurnaceTemplate
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();
FurnaceTemplate template = FurnaceTemplate.builder()
.inputMaterial(diamond)
.outputMaterial(emerald)
.fuel(dirt)
.build();
This example will produce a template with the following results
InventoryTemplate
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