TransactionBuilderInventory
        
        extends BaseInventory
    
    
            
            in package
            
        
    
    
    
        
            This class facilitates generating SlotChangeActions to build an inventory transaction.
It wraps around the inventory you want to modify under transaction, and generates a diff of changes. This allows you to use the normal Inventory API methods like addItem() and so on to build a transaction, without modifying the original inventory.
Table of Contents
- $listeners : array<string|int, InventoryListener>|ObjectSet
- $maxStackSize : int
- $viewers : array<string|int, Player>
- $actualInventory : Inventory
- $changedSlots : SplFixedArray
- __construct() : mixed
- addItem() : array<string|int, Item>
- Stores the given Items in the inventory. This will try to fill existing stacks and empty slots as well as it can.
- all() : array<string|int, Item>
- Will return all the Items that has the same id and metadata (if not null).
- canAddItem() : bool
- Checks if a given Item can be added to the inventory
- clear() : void
- Will clear a specific slot
- clearAll() : void
- Clears all the slots
- contains() : bool
- Checks if the inventory contains any Item with the same material data.
- first() : int
- Returns the first slot number containing an item with the same ID, damage (if not any-damage), NBT (if not empty) and count >= to the count of the specified item stack.
- firstEmpty() : int
- Returns the first empty slot, or -1 if not found
- generateActions() : array<string|int, SlotChangeAction>
- getAddableItemQuantity() : int
- Returns how many items from the given itemstack can be added to this inventory.
- getContents() : array<string|int, mixed>
- getItem() : Item
- getListeners() : array<string|int, InventoryListener>|ObjectSet
- getMaxStackSize() : int
- getSize() : int
- getViewers() : array<string|int, Player>
- Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.
- isSlotEmpty() : bool
- Returns whether the given slot is empty.
- onClose() : void
- onOpen() : void
- Called when a player opens this inventory.
- remove() : void
- Will remove all the Items that has the same id and metadata (if not null)
- removeAllViewers() : void
- Removes the inventory window from all players currently viewing it.
- removeItem() : array<string|int, Item>
- Removes the given Item from the inventory.
- setContents() : void
- setItem() : void
- Puts an Item in a slot.
- setMaxStackSize() : void
- slotExists() : bool
- Returns whether the specified slot exists in the inventory.
- swap() : void
- Swaps the specified slots.
- internalSetContents() : void
- internalSetItem() : void
- onContentChange() : void
- onSlotChange() : void
- internalAddItem() : Item
Properties
$listeners
    protected
        array<string|int, InventoryListener>|ObjectSet
    $listeners
    
    
    
    
    Tags
$maxStackSize
    protected
        int
    $maxStackSize
     = \pocketmine\inventory\Inventory::MAX_STACK
    
    
    
$viewers
    protected
        array<string|int, Player>
    $viewers
     = []
    
    
    
$actualInventory
    private
        Inventory
    $actualInventory
    
        
        
    
$changedSlots
    private
        SplFixedArray
    $changedSlots
    
    
    
    
    Tags
Methods
__construct()
    public
                    __construct(Inventory $actualInventory) : mixed
        
        Parameters
- $actualInventory : Inventory
Return values
mixed —addItem()
Stores the given Items in the inventory. This will try to fill existing stacks and empty slots as well as it can.
    public
                    addItem(Item ...$slots) : array<string|int, Item>
        Returns the Items that did not fit.
Parameters
- $slots : Item
Return values
array<string|int, Item> —all()
Will return all the Items that has the same id and metadata (if not null).
    public
                    all(Item $item) : array<string|int, Item>
        Won't check amount
Parameters
- $item : Item
Return values
array<string|int, Item> —canAddItem()
Checks if a given Item can be added to the inventory
    public
                    canAddItem(Item $item) : bool
    
        Parameters
- $item : Item
Return values
bool —clear()
Will clear a specific slot
    public
                    clear(int $index) : void
    
        Parameters
- $index : int
Return values
void —clearAll()
Clears all the slots
    public
                    clearAll() : void
    
    
    
        Return values
void —contains()
Checks if the inventory contains any Item with the same material data.
    public
                    contains(Item $item) : bool
        It will check id, amount, and metadata (if not null)
Parameters
- $item : Item
Return values
bool —first()
Returns the first slot number containing an item with the same ID, damage (if not any-damage), NBT (if not empty) and count >= to the count of the specified item stack.
    public
                    first(Item $item[, bool $exact = false ]) : int
        If $exact is true, only items with equal ID, damage, NBT and count will match.
Parameters
- $item : Item
- $exact : bool = false
Return values
int —firstEmpty()
Returns the first empty slot, or -1 if not found
    public
                    firstEmpty() : int
    
    
    
        Return values
int —generateActions()
    public
                    generateActions() : array<string|int, SlotChangeAction>
    
    
    
        Return values
array<string|int, SlotChangeAction> —getAddableItemQuantity()
Returns how many items from the given itemstack can be added to this inventory.
    public
                    getAddableItemQuantity(Item $item) : int
    
        Parameters
- $item : Item
Return values
int —getContents()
    public
                    getContents([bool $includeEmpty = false ]) : array<string|int, mixed>
        
        Parameters
- $includeEmpty : bool = false
Return values
array<string|int, mixed> —getItem()
    public
                    getItem(int $index) : Item
        
        Parameters
- $index : int
Return values
Item —getListeners()
    public
                    getListeners() : array<string|int, InventoryListener>|ObjectSet
    
    
    
        Return values
array<string|int, InventoryListener>|ObjectSet —getMaxStackSize()
    public
                    getMaxStackSize() : int
        
    
    
        Return values
int —getSize()
    public
                    getSize() : int
        
    
    
        Return values
int —getViewers()
Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.
    public
                    getViewers() : array<string|int, Player>
    
    
    
        Return values
array<string|int, Player> —isSlotEmpty()
Returns whether the given slot is empty.
    public
                    isSlotEmpty(int $index) : bool
    
        Parameters
- $index : int
Return values
bool —onClose()
    public
                    onClose(Player $who) : void
        
        Parameters
- $who : Player
Return values
void —onOpen()
Called when a player opens this inventory.
    public
                    onOpen(Player $who) : void
    
        Parameters
- $who : Player
Return values
void —remove()
Will remove all the Items that has the same id and metadata (if not null)
    public
                    remove(Item $item) : void
    
        Parameters
- $item : Item
Return values
void —removeAllViewers()
Removes the inventory window from all players currently viewing it.
    public
                    removeAllViewers() : void
    
    
    
        Return values
void —removeItem()
Removes the given Item from the inventory.
    public
                    removeItem(Item ...$slots) : array<string|int, Item>
        It will return the Items that couldn't be removed.
Parameters
- $slots : Item
Return values
array<string|int, Item> —setContents()
    public
                    setContents(array<string|int, Item> $items) : void
    
        Parameters
- $items : array<string|int, Item>
Return values
void —setItem()
Puts an Item in a slot.
    public
                    setItem(int $index, Item $item) : void
    
        Parameters
- $index : int
- $item : Item
Return values
void —setMaxStackSize()
    public
                    setMaxStackSize(int $size) : void
        
        Parameters
- $size : int
Return values
void —slotExists()
Returns whether the specified slot exists in the inventory.
    public
                    slotExists(int $slot) : bool
    
        Parameters
- $slot : int
Return values
bool —swap()
Swaps the specified slots.
    public
                    swap(int $slot1, int $slot2) : void
    
        Parameters
- $slot1 : int
- $slot2 : int
Return values
void —internalSetContents()
    protected
                    internalSetContents(array<string|int, mixed> $items) : void
    
        Parameters
- $items : array<string|int, mixed>
Return values
void —internalSetItem()
    protected
                    internalSetItem(int $index, Item $item) : void
        
        Parameters
- $index : int
- $item : Item
Return values
void —onContentChange()
    protected
                    onContentChange(array<string|int, Item> $itemsBefore) : void
    
        Parameters
- $itemsBefore : array<string|int, Item>
Tags
Return values
void —onSlotChange()
    protected
                    onSlotChange(int $index, Item $before) : void
        
        Parameters
- $index : int
- $before : Item
Return values
void —internalAddItem()
    private
                    internalAddItem(Item $slot) : Item
        
        Parameters
- $slot : Item