限定符和类型 | 方法和说明 |
---|---|
int |
clear(int id,
int data)
已过时。
Magic value
|
ItemStack[] |
getArmorContents()
获取装备槽内的全部物品.
|
ItemStack |
getBoots()
返回靴子槽内的物品.
|
ItemStack |
getChestplate()
返回胸甲槽内的物品.
|
ItemStack[] |
getExtraContents()
获取存储在此背包的所有额外物品.
|
int |
getHeldItemSlot()
获取玩家握着的物品所在的物品槽位.
|
ItemStack |
getHelmet()
返回头盔槽内的物品.
|
HumanEntity |
getHolder()
获得此物品栏的持有者(方块或实体).
|
ItemStack |
getItemInHand()
已过时。
players can duel wield now use the methods for the
specific hand instead
|
ItemStack |
getItemInMainHand()
获得玩家握在主手的物品(的副本).
|
ItemStack |
getItemInOffHand()
获取玩家握在副手的物品(的副本).
|
ItemStack |
getLeggings()
返回护腿槽内的物品.
|
void |
setArmorContents(ItemStack[] items)
设置装备槽的全部物品.
|
void |
setBoots(ItemStack boots)
设置靴子物品栏内的物品.
|
void |
setChestplate(ItemStack chestplate)
设置胸甲物品栏内的物品.
|
void |
setExtraContents(ItemStack[] items)
将给定的物品放在额外物品槽内.
|
void |
setHeldItemSlot(int slot)
设置玩家握着哪一个槽位的物品.
|
void |
setHelmet(ItemStack helmet)
设置头盔物品栏内的物品.
|
void |
setItem(int index,
ItemStack item)
把物品放在背包的指定位置.
|
void |
setItemInHand(ItemStack stack)
已过时。
players can duel wield now use the methods for the
specific hand instead
|
void |
setItemInMainHand(ItemStack item)
设置玩家握在主手的物品.
|
void |
setItemInOffHand(ItemStack item)
设置玩家握在副手的物品.
|
void |
setLeggings(ItemStack leggings)
设置护腿物品栏内的物品.
|
addItem, all, all, all, clear, clear, contains, contains, contains, contains, contains, contains, containsAtLeast, first, first, first, firstEmpty, getContents, getItem, getLocation, getMaxStackSize, getName, getSize, getStorageContents, getTitle, getType, getViewers, iterator, iterator, remove, remove, remove, removeItem, setContents, setMaxStackSize, setStorageContents
ItemStack[] getArmorContents()
原文: Get all ItemStacks from the armor slots
ItemStack[] getExtraContents()
注意:额外的物品槽是由实现来定义的,但这些额外的物品不会在Inventory.getStorageContents()
或getArmorContents()
之内.
原文:Get all additional ItemStacks stored in this inventory.
NB: What defines an extra slot is up to the implementation, however it will not be contained within Inventory.getStorageContents()
or getArmorContents()
ItemStack getHelmet()
原文: Return the ItemStack from the helmet slot
ItemStack getChestplate()
原文: Return the ItemStack from the chestplate slot
ItemStack getLeggings()
原文: Return the ItemStack from the leg slot
ItemStack getBoots()
原文: Return the ItemStack from the boots slot
void setItem(int index, ItemStack item)
索引值0~8指向平视显示器(HUD)上的工具栏. 9~35指向主物品栏(中间的27个物品槽), 从主物品栏的左上角往上数(索引值9指向主物品栏左上角的物品槽),向右移动, 到行末时再从下一行的最左的物品槽继续往上数.
索引值36~39指向玩家的盔甲槽. 即使你可以使用本方法设置盔甲槽内的物品, 我们还是建议你使用我们提供的相关的设置盔甲槽内物品的方法来设置.
如果你试图传递错误的index值(取值范围为0≤index≤39)给本方法, 将抛出ArrayIndexOutOfBounds异常.
原文:Stores the ItemStack at the given index of the inventory.
Indexes 0 through 8 refer to the hotbar. 9 through 35 refer to the main inventory, counting up from 9 at the top left corner of the inventory, moving to the right, and moving to the row below it back on the left side when it reaches the end of the row. It follows the same path in the inventory like you would read a book.
Indexes 36 through 39 refer to the armor slots. Though you can set armor with this method using these indexes, you are encouraged to use the provided methods for those slots.
If you attempt to use this method with an index less than 0 or greater than 39, an ArrayIndexOutOfBounds exception will be thrown.
setItem
在接口中 Inventory
index
- 将物品放在哪item
- 要放置的物品java.lang.ArrayIndexOutOfBoundsException
- 当 index 值 < 0 || index > 39setBoots(ItemStack)
,
setChestplate(ItemStack)
,
setHelmet(ItemStack)
,
setLeggings(ItemStack)
void setArmorContents(ItemStack[] items)
原文: Put the given ItemStacks into the armor slots
items
- 用作装备的物品(任意)void setExtraContents(ItemStack[] items)
请到 getExtraContents()
去了解额外物品槽是什么.
原文:Put the given ItemStacks into the extra slots
See getExtraContents()
for an explanation of extra slots.
items
- 额外物品void setHelmet(ItemStack helmet)
原文: Put the given ItemStack into the helmet slot. This does not check if the ItemStack is a helmet
helmet
- 作为头盔的物品void setChestplate(ItemStack chestplate)
原文: Put the given ItemStack into the chestplate slot. This does not check if the ItemStack is a chestplate
chestplate
- 作为胸甲的物品void setLeggings(ItemStack leggings)
原文: Put the given ItemStack into the leg slot. This does not check if the ItemStack is a pair of leggings
leggings
- 作为护腿的物品void setBoots(ItemStack boots)
原文: Put the given ItemStack into the boots slot. This does not check if the ItemStack is a boots
boots
- 作为靴子的物品ItemStack getItemInMainHand()
原文:Gets a copy of the item the player is currently holding in their main hand.
void setItemInMainHand(ItemStack item)
原文:Sets the item the player is holding in their main hand.
item
- 要放在玩家手上的物品ItemStack getItemInOffHand()
原文:Gets a copy of the item the player is currently holding in their off hand.
void setItemInOffHand(ItemStack item)
原文:Sets the item the player is holding in their off hand.
item
- 要放在玩家副手上的物品@Deprecated ItemStack getItemInHand()
getItemInMainHand()
,
getItemInOffHand()
@Deprecated void setItemInHand(ItemStack stack)
stack
- The item to put into the player's handsetItemInMainHand(ItemStack)
,
setItemInOffHand(ItemStack)
int getHeldItemSlot()
原文:Get the slot number of the currently held item
void setHeldItemSlot(int slot)
本方法会验证“slot”的取值是否符合该不等式:0≤slot≤8.
原文:Set the slot number of the currently held item.
This validates whether the slot is between 0 and 8 inclusive.
slot
- 槽位java.lang.IllegalArgumentException
- 如果slot的取值有误@Deprecated int clear(int id, int data)
id
- the id of the item you want to clear from the inventorydata
- the data of the item you want to clear from the inventoryHumanEntity getHolder()
Inventory
原文:Gets the block or entity belonging to the open inventory