kotlin
operator fun Container.get(slot: Int): ItemStack从容器槽位中获取物品。
operator fun Container.get(slot: Int): ItemStack从容器槽位中获取物品。
operator fun Container.set(slot: Int, itemStack: ItemStack)将物品设置到容器槽位中。
operator fun Inventory.minusAssign(itemStack: ItemStack)从背包中移除物品。
operator fun Inventory.plusAssign(itemStack: ItemStack)向背包添加物品。
operator fun SlotProvider.get(slot: KattonItemCollection.KattonItemSlot): ItemStack?从槽位提供器的 KattonItemSlot 中获取物品。
operator fun SlotProvider.set(slot: KattonItemCollection.KattonItemSlot, itemStack: ItemStack)将物品设置到槽位提供器的 KattonItemSlot 中。
operator fun Container.get(slots: List<KattonItemCollection.KattonItemSlot>): List<ItemStack?>从容器的多个槽位中获取物品。
val Container.slots: KattonItemCollection用于访问容器槽位的扩展属性。
class KattonItemCollection(val container: net.minecraft.world.Container)提供便捷访问方式的物品槽位集合。
| 属性 | 说明 |
|---|---|
container | 底层 Container。 |
operator fun get(slot: KattonItemSlot): SlotAccess?获取指定槽位的 SlotAccess。
operator fun get(slots: List<KattonItemSlot>): List<SlotAccess?>获取多个槽位的 SlotAccess。
open class KattonItemSlot( val index: Int )通过索引表示单个物品槽位。
interface KattonItemSlotGroup物品槽位组接口。
open class KattonItemSlotList( val offset: Int, size: Int ) : Iterable<KattonItemSlot>, KattonItemSlotGroup连续物品槽位列表。
object Contents : KattonItemSlot(0)第一个内容槽位。
object Container : KattonItemSlotList(0, 54)全部容器槽位(0-53)。
object Hotbar : KattonItemSlotList(0, 9)快捷栏槽位(0-8)。
object Inventory : KattonItemSlotList(9, 27)主背包槽位(9-35)。
object EnderChest : KattonItemSlotList(200, 27)末影箱槽位(200-226)。
object MobInventory : KattonItemSlotList(300, 8)生物背包槽位(300-307)。
object Horse : KattonItemSlotList(500, 15)马背包槽位(500-514)。
object Weapon : KattonItemSlotGroup武器槽位(主手和副手)。
object MainHand : KattonItemSlot(EquipmentSlot.MAINHAND.getIndex(98))主手槽位。
object OffHand : KattonItemSlot(EquipmentSlot.OFFHAND.getIndex(98))副手槽位。
object Armor : KattonItemSlotGroup护甲槽位(头盔、胸甲、护腿、靴子)。
object Head : KattonItemSlot(EquipmentSlot.HEAD.getIndex(100))头盔槽位。
object Chest : KattonItemSlot(EquipmentSlot.CHEST.getIndex(100))胸甲槽位。
object Legs : KattonItemSlot(EquipmentSlot.LEGS.getIndex(100))护腿槽位。
object Feet : KattonItemSlot(EquipmentSlot.FEET.getIndex(100))靴子槽位。