Skip to content
On this page

Common

KattonItemApi

top.katton.api.dpcallercommon/src/main/kotlin/top/katton/api/dpcaller/KattonItemApi.kt
Extension property to get/set NBT data on an ItemStack.

nbt

CommonProperty
kotlin
var ItemStack.nbt: CompoundTag

Extension property to get/set NBT data on an ItemStack.

modifyBlockItem

CommonFunction
kotlin
fun modifyBlockItem(pos: BlockPos, slot: Int, modifier: LootItemFunction)

Applies a LootItemFunction modifier to a block container slot.

Parameters

ParameterDescription
posBlock position of the container
slotSlot index to modify
modifierLootItemFunction to apply

modifyEntityItem

CommonFunction
kotlin
fun modifyEntityItem(entity: Entity, slot: Int, modifier: LootItemFunction)

Applies a LootItemFunction to an entity equipment slot.

Parameters

ParameterDescription
entityTarget entity
slotEquipment slot index
modifierLootItemFunction to apply

setBlockItem

CommonFunction
kotlin
fun setBlockItem(pos: BlockPos, slot: Int, itemStack: ItemStack)

Sets an item into a container block slot.

Parameters

ParameterDescription
posBlock position
slotSlot index
itemStackItemStack to set

setEntityItem

CommonFunction
kotlin
fun setEntityItem(entity: Entity, slot: Int, itemStack: ItemStack)

Sets an item into an entity slot.

Parameters

ParameterDescription
entityTarget entity
slotSlot index
itemStackItemStack to set

getBlockItem

CommonFunction
kotlin
fun getBlockItem(pos: BlockPos, slot: Int): ItemStack?

Gets an item from a container block slot.

Parameters

ParameterDescription
posBlock position
slotSlot index

Returns

ItemStack or null if invalid

getEntityItem

CommonFunction
kotlin
fun getEntityItem(entity: Entity, slot: Int): ItemStack?

Gets an item from an entity slot.

Parameters

ParameterDescription
entityTarget entity
slotSlot index

Returns

ItemStack or null if slot missing

applyModifier

CommonFunction
kotlin
fun applyModifier(itemStack: ItemStack, modifier: LootItemFunction): ItemStack

Applies a LootItemFunction to an ItemStack and returns the modified stack.

Parameters

ParameterDescription
itemStackItem to modify
modifierFunction to apply

Returns

Modified ItemStack (size-limited)