-
Notifications
You must be signed in to change notification settings - Fork 36
Interaction Handling
Natan Vieira edited this page Mar 4, 2023
·
11 revisions
There are global and component-specific interaction treatments (items are components).
This will send a message whenever the player interacts with the inventory.
import me.devnatan.inventoryframework.View;
class CoolView extends View {
@Override
public void onClick(SlotClickContext slotClick) {
slotClick.getPlayer().sendMessage("Clicked on " + slotClick.getClickedSlot());
}
}Also called in interactions of the player's own inventory, it is possible to distinguish which inventory was clicked using isOnEntityContainer().
import me.devnatan.inventoryframework.View;
class CoolView extends View {
@Override
public void onClick(SlotClickContext slotClick) {
if (slotClick.isOnEntityContainer()) {
// clicked on player inventory (bottom)
} else {
// clicked on view inventory (top)
}
}
}Items have a series of options related to interaction treatment, it is possible to define them individually for each of them
import me.devnatan.inventoryframework.View;
class CoolView extends View {
@Override
public void onFirstRender(RenderContext ctx) {
ctx.firstSlot(new ItemStack(Material.DIAMOND))
.onClick(click -> click.getPlayer().sendMessage("Clicked on diamond"));
}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.
- IntelliJ Tooling Plugin — Live inventory preview and API inspections in the IDE.
You can find practical examples in the examples directory.