addBehavior

open override fun addBehavior(identifier: KIdentifier, block: ItemStack.(context: KItemBehaviorContext) -> Unit): KItemBehavior

Adds a behavior to the item with a specific identifier and functionality block.

This method registers a new behavior to the item, allowing custom functionality when specific actions or events are triggered on the item. The added behavior persists through the item's lifecycle and is identified using the provided identifier.

Return

the created KItemBehavior instance associated with the registered behavior

Parameters

identifier

the unique identifier for the behavior

block

the functionality block defining the behavior, receiving an ItemStack and a context of type KItemBehaviorContext

See also

KBehavior

open override fun addBehavior(kItemBehavior: KItemBehavior): KItemBehavior

Adds a behavior to the item.

This method registers the provided behavior to the item, allowing it to respond to certain actions or events. The added behavior is tied to the item's functionality and may persist through the item's lifecycle.

Return

the added behavior instance

Parameters

kItemBehavior

the behavior to add