It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.entity.type.player.Inventory;

已实现的接口

Link to 已实现的接口

Inventory implements the following interfaces. That means all methods defined in these interfaces are also available in Inventory

Name: add

Return Type: boolean

ZenScript
Copy
Inventory.add(stack as ItemStack) as boolean
参数类型描述
参数
堆叠
类型
物品应用
描述
No Description Provided

Name: add

Return Type: boolean

ZenScript
Copy
Inventory.add(index as int, stack as ItemStack) as boolean
参数类型描述
参数
index
类型
int
描述
No Description Provided
参数
堆叠
类型
物品应用
描述
No Description Provided

Name: contains

Return Type: boolean

ZenScript
Copy
Inventory.contains(stack as ItemStack) as boolean
参数类型描述
参数
堆叠
类型
物品应用
描述
No Description Provided

Name: contains

Return Type: boolean

ZenScript
Copy
Inventory.contains(tag as MCTag<ItemDefinition>) as boolean
参数类型描述
参数
tag #标签
类型
MCTag<ItemDefinition>
描述
No Description Provided

Name: dropAll

Return Type: void

ZenScript
Copy
// Inventory.dropAll() as void

myInventory.dropAll();

Link to findSlotMatchingItem

Name: findSlotMatchingItem

Return Type: int

ZenScript
Copy
Inventory.findSlotMatchingItem(stack as ItemStack) as int
参数类型描述
参数
堆叠
类型
物品应用
描述
No Description Provided

Link to findSlotMatchingUnusedItem

Name: findSlotMatchingUnusedItem

Return Type: int

ZenScript
Copy
Inventory.findSlotMatchingUnusedItem(stack as ItemStack) as int
参数类型描述
参数
堆叠
类型
物品应用
描述
No Description Provided

Name: getArmor

Return Type: ItemStack

ZenScript
Copy
Inventory.getArmor(armorIndex as int) as ItemStack
参数类型描述
参数
armorIndex
类型
int
描述
No Description Provided

Name: getFreeSlot

Return Type: int

ZenScript
Copy
// Inventory.getFreeSlot() as int

myInventory.getFreeSlot();

Name: getSelected

Return Type: ItemStack

ZenScript
Copy
// Inventory.getSelected() as ItemStack

myInventory.getSelected();

Link to getSlotWithRemainingSpace

Name: getSlotWithRemainingSpace

Return Type: int

ZenScript
Copy
Inventory.getSlotWithRemainingSpace(stack as ItemStack) as int
参数类型描述
参数
堆叠
类型
物品应用
描述
No Description Provided

Link to getSuitableHotbarSlot

Name: getSuitableHotbarSlot

Return Type: int

ZenScript
Copy
// Inventory.getSuitableHotbarSlot() as int

myInventory.getSuitableHotbarSlot();

Name: getTimesChanged

Return Type: int

ZenScript
Copy
// Inventory.getTimesChanged() as int

myInventory.getTimesChanged();

Name: hurtArmor

Return Type: void

ZenScript
Copy
Inventory.hurtArmor(source as DamageSource, damage as float, armorSlots as int[]) as void
参数类型描述
参数
来源
类型
DamageSource
描述
No Description Provided
参数
damage
类型
float
描述
No Description Provided
参数
armorSlots
类型
整型[]
描述
No Description Provided

Name: pickSlot

Return Type: void

ZenScript
Copy
Inventory.pickSlot(index as int) as void
参数类型描述
参数
index
类型
int
描述
No Description Provided

Name: removeItem

Return Type: void

ZenScript
Copy
Inventory.removeItem(stack as ItemStack) as void
参数类型描述
参数
堆叠
类型
物品应用
描述
No Description Provided

Name: setPickedItem

Return Type: void

ZenScript
Copy
Inventory.setPickedItem(stack as ItemStack) as void
参数类型描述
参数
堆叠
类型
物品应用
描述
No Description Provided
名称类型可获得可设置描述
名称
freeSlot
类型
int
可获得
true
可设置
false
描述
No Description Provided
名称
selected
类型
物品应用
可获得
true
可设置
false
描述
No Description Provided
名称
suitableHotbarSlot
类型
int
可获得
true
可设置
false
描述
No Description Provided
名称
timesChanged
类型
int
可获得
true
可设置
false
描述
No Description Provided