Skip to content

Code Samples

Natan Vieira edited this page Jul 16, 2023 · 16 revisions

Counter

Preview
privatefinalMutableIntStatecounterState = mutableState(0);
@OverridepublicvoidonInit(ViewConfigBuilderconfig) {
config.title("Counter")
.cancelOnClick()
.layout(" - # + ");
}
@OverridepublicvoidonFirstRender(RenderContextrender) {
// Current count itemrender.layoutSlot('#')
// The `watch` here updates the item when `counterState` updates
.watch(counterState)
.renderWith(() -> newItemStack(
/* type = */Material.GOLD_INGOT,
/* amount = */counterState.get(render)
));
// Decrement buttonrender.layoutSlot('-', newItemStack(Material.ARROW))
.onClick(counterState::decrement);
// Increment buttonrender.layoutSlot('+', newItemStack(Material.ARROW))
.onClick(counterState::increment);
}

Welcome to the Inventory Framework documentation.

▶️ Introduction

🧩 Core Topics

💡 Built-In Features

🧰 Extra Features

🤓 Advanced Usage

⚙️ Internal Mechanisms

🛠️ Tooling

You can find practical examples in the examples directory.

Clone this wiki locally