Package cn.nukkit.inventory
Class InventorySlice
java.lang.Object
cn.nukkit.inventory.InventorySlice
- All Implemented Interfaces:
Inventory
@Since("1.19.50-r3")
@PowerNukkitXOnly
public class InventorySlice
extends Object
implements Inventory
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionItem[]
void
addListener
(InventoryListener listener) boolean
canAddItem
(Item item) boolean
clear
(int index, boolean send) void
clearAll()
void
boolean
void
decreaseCount
(int slot) int
int
firstEmpty
(Item item) int
getItem
(int index) 获取该库存指定索引处的物品int
获取最大库存大小getName()
获取该库存的名字int
getSize()
获取该库存大小int
getTitle()
获取该库存的标题getType()
boolean
isEmpty()
boolean
isFull()
void
void
void
onSlotChange
(int index, Item before, boolean send) 当执行Inventory.setItem(int, Item)
时该方法会被调用,此时物品已经put进slotsboolean
void
Item[]
removeItem
(Item... slots) void
removeListener
(InventoryListener listener) void
sendContents
(Player player) void
sendContents
(Player... players) void
sendContents
(Collection<Player> players) void
void
void
sendSlot
(int index, Collection<Player> players) void
setContents
(Map<Integer, Item> items) void
setEndSlot
(int endSlot) boolean
设置该库存指定索引处的物品void
setMaxStackSize
(int size) 设置最大库存大小void
setStartSlot
(int startSlot) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cn.nukkit.inventory.Inventory
clear, first, getUnclonedItem, setItem, setItemByPlayer
-
Constructor Details
-
InventorySlice
-
-
Method Details
-
setStartSlot
public void setStartSlot(int startSlot) -
setEndSlot
public void setEndSlot(int endSlot) -
getStartSlot
public int getStartSlot() -
getEndSlot
public int getEndSlot() -
getSize
public int getSize()Description copied from interface:Inventory
获取该库存大小 -
getMaxStackSize
public int getMaxStackSize()Description copied from interface:Inventory
获取最大库存大小- Specified by:
getMaxStackSize
in interfaceInventory
-
setMaxStackSize
public void setMaxStackSize(int size) Description copied from interface:Inventory
设置最大库存大小- Specified by:
setMaxStackSize
in interfaceInventory
-
getName
Description copied from interface:Inventory
获取该库存的名字 -
getTitle
Description copied from interface:Inventory
获取该库存的标题 -
getItem
Description copied from interface:Inventory
获取该库存指定索引处的物品 -
setItem
Description copied from interface:Inventory
设置该库存指定索引处的物品 -
addItem
-
canAddItem
- Specified by:
canAddItem
in interfaceInventory
-
removeItem
- Specified by:
removeItem
in interfaceInventory
-
getContents
- Specified by:
getContents
in interfaceInventory
-
setContents
- Specified by:
setContents
in interfaceInventory
-
sendContents
- Specified by:
sendContents
in interfaceInventory
-
sendContents
- Specified by:
sendContents
in interfaceInventory
-
sendContents
- Specified by:
sendContents
in interfaceInventory
-
sendSlot
-
sendSlot
-
sendSlot
-
contains
-
all
-
first
-
firstEmpty
- Specified by:
firstEmpty
in interfaceInventory
-
decreaseCount
public void decreaseCount(int slot) - Specified by:
decreaseCount
in interfaceInventory
-
remove
-
clear
public boolean clear(int index, boolean send) -
clearAll
public void clearAll() -
isFull
public boolean isFull() -
isEmpty
public boolean isEmpty() -
getViewers
- Specified by:
getViewers
in interfaceInventory
-
getType
-
getHolder
-
onOpen
-
open
-
close
-
onClose
-
onSlotChange
Description copied from interface:Inventory
当执行Inventory.setItem(int, Item)
时该方法会被调用,此时物品已经put进slotsThis method is called when
Inventory.setItem(int, Item)
is executed, and the item has been put into slots- Specified by:
onSlotChange
in interfaceInventory
- Parameters:
index
- 物品变动的格子索引
The grid index of the item's changesbefore
- 变动前的物品
Items before the changesend
- 是否发送InventorySlotPacket
到客户端
Whether to sendInventorySlotPacket
to the client
-
addListener
- Specified by:
addListener
in interfaceInventory
-
removeListener
- Specified by:
removeListener
in interfaceInventory
-