ItemAction

interface ItemAction

An action to be applied to an item after an interaction.

Inheritors

Types

Link copied to clipboard
class Composite(val actions: List<ItemAction>) : ItemAction

Applies actions in sequence.

Link copied to clipboard
class Consume(val decrement: Int = 1) : ItemAction

The stack is shrunk by decrement and a corresponding amount of use remainder items is added, if there is one.

Link copied to clipboard
class ConvertOne(newItemStack: ItemStack) : ItemAction

One item from the stack is converted into newItemStack. newItemStack will not be modified.

Link copied to clipboard
class ConvertStack(newItemStack: ItemStack) : ItemAction

The entire stack is converted into newItemStack. newItemStack will not be modified.

Link copied to clipboard
class Damage(val damage: Int = 1) : ItemAction

The item is damaged by damage.

Link copied to clipboard
data object None : ItemAction

No action is applied.

Functions

Link copied to clipboard
abstract fun apply(world: World, itemStack: ItemStack): List<ItemStack>

Applies this action to a copy of itemStack, in the context of world, then returns it. Does not modify the original itemStack. This function is used in cases where the item interaction was not triggered by an entity.

abstract fun apply(entity: LivingEntity, slot: EquipmentSlot)

Applies this action to the item in the slot of entity.