PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
|
Public Member Functions | |
__construct (protected Player $source, array $actions=[]) | |
addAction (InventoryAction $action) | |
addInventory (Inventory $inventory) | |
execute () | |
getActions () | |
getInventories () | |
getSource () | |
hasExecuted () | |
validate () | |
Protected Member Functions | |
callExecuteEvent () | |
findResultItem (Item $needOrigin, array $possibleActions) | |
matchItems (array &$needItems, array &$haveItems) | |
squashDuplicateSlotChanges () | |
Protected Attributes | |
array | $actions = [] |
bool | $hasExecuted = false |
array | $inventories = [] |
This is the basic type for an inventory transaction. This is used for moving items between inventories, dropping items and more. It allows transactions with multiple inputs and outputs.
Validation does not depend on ordering. This means that the actions can appear in any order and still be valid. The only validity requirement for this transaction type is that the balance of items must add up to zero. This means:
A transaction is composed of "actions", which are pairs of inputs and outputs which target a specific itemstack in a specific location. There are multiple types of inventory actions which might be involved in a transaction.
Definition at line 57 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::__construct | ( | protected Player | $source, |
array | $actions = [] ) |
InventoryAction[] | $actions |
Definition at line 69 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::addAction | ( | InventoryAction | $action | ) |
Definition at line 101 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::addInventory | ( | Inventory | $inventory | ) |
Definition at line 127 of file InventoryTransaction.php.
|
protected |
Definition at line 293 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::execute | ( | ) |
Executes the group of actions, returning whether the transaction executed successfully or not.
TransactionException |
Reimplemented in pocketmine\inventory\transaction\EnchantingTransaction.
Definition at line 304 of file InventoryTransaction.php.
|
protected |
SlotChangeAction[] | $possibleActions |
Definition at line 237 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::getActions | ( | ) |
Returns an unordered set of actions involved in this transaction.
WARNING: This system is explicitly designed NOT to care about ordering. Any order seen in this set has NO significance and should not be relied on.
Definition at line 97 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::getInventories | ( | ) |
Definition at line 85 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::getSource | ( | ) |
Definition at line 78 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::hasExecuted | ( | ) |
Definition at line 330 of file InventoryTransaction.php.
|
protected |
Item[] | $needItems | |
Item[] | $haveItems | @phpstan-param-out Item[] $needItems @phpstan-param-out Item[] $haveItems |
TransactionValidationException |
Definition at line 141 of file InventoryTransaction.php.
|
protected |
Iterates over SlotChangeActions in this transaction and compacts any which refer to the same slot in the same inventory so they can be correctly handled.
Under normal circumstances, the same slot would never be changed more than once in a single transaction. However, due to the way things like the crafting grid are "implemented" in MCPE 1.2 (a.k.a. hacked-in), we may get multiple slot changes referring to the same slot in a single transaction. These multiples are not even guaranteed to be in the correct order (slot splitting in the crafting grid for example, causes the actions to be sent in the wrong order), so this method also tries to chain them into order.
Definition at line 190 of file InventoryTransaction.php.
pocketmine\inventory\transaction\InventoryTransaction::validate | ( | ) |
Verifies that the transaction can execute.
TransactionValidationException |
Reimplemented in pocketmine\inventory\transaction\CraftingTransaction, and pocketmine\inventory\transaction\EnchantingTransaction.
Definition at line 275 of file InventoryTransaction.php.
|
protected |
Definition at line 64 of file InventoryTransaction.php.
|
protected |
Definition at line 58 of file InventoryTransaction.php.
|
protected |
Definition at line 61 of file InventoryTransaction.php.