-
Notifications
You must be signed in to change notification settings - Fork 30
Code Samples
Natan Vieira edited this page Jul 16, 2023
·
16 revisions
private final MutableIntState counterState = mutableState(0);
@Override
public void onInit(ViewConfigBuilder config) {
config.title("Counter")
.cancelOnClick()
.layout(" - # + ");
}
@Override
public void onFirstRender(RenderContext render) {
// Current count item
render.layoutSlot('#')
// The `watch` here updates the item when `counterState` updates
.watch(counterState)
.renderWith(() -> new ItemStack(
/* type = */ Material.GOLD_INGOT,
/* amount = */ counterState.get(render)
));
// Decrement button
render.layoutSlot('-', new ItemStack(Material.ARROW))
.onClick(counterState::decrement);
// Increment button
render.layoutSlot('+', new ItemStack(Material.ARROW))
.onClick(counterState::increment);
}Welcome to the Inventory Framework documentation.
- Pagination — Display large collections of items across multiple pages.
- Layouts (a.k.a. Masks or Patterns) — Define visual patterns for item placement.
- Scheduled Updates
- Anvil Input — Capture text input from players using an anvil GUI.
- Dynamic Title Update — Update the inventory’s title in real time.
You can find practical examples in the examples directory.