-
Notifications
You must be signed in to change notification settings - Fork 0
7. Items (ItemMapper)
zawarka03 edited this page Jul 28, 2026
·
1 revision
Monolith API seamlessly integrates custom blocks with Bukkit's ItemStack system using Persistent Data Containers (PDC).
You can generate an ItemStack representing a custom block. The API automatically applies the block's display name and embeds its identifier within the item's PDC.
// Kotlin Example
import io.github.zawarka03.monolithAPI.MonolithAPI
import io.github.zawarka03.monolithAPI.api.block.BlockDefinition
import org.bukkit.inventory.ItemStack
val definition: BlockDefinition = ... // Your custom block definition
// Generate the ItemStack
val item: ItemStack = MonolithAPI.api.items.toItem(definition)
// Give the item to a player
player.inventory.addItem(item)Conversely, you can inspect an ItemStack to determine if it represents a custom block and retrieve its corresponding BlockDefinition.
// Java Example
import io.github.zawarka03.monolithAPI.MonolithAPI;
import io.github.zawarka03.monolithAPI.api.block.BlockDefinition;
import org.bukkit.inventory.ItemStack;
public void checkItem(ItemStack item) {
// Attempt to retrieve the definition
BlockDefinition definition = MonolithAPI.api().items().fromItem(item);
if (definition != null) {
System.out.println("This item is a custom block: " + definition.getIdentifier());
} else {
System.out.println("This is a standard vanilla item.");
}
}