PocketMine-MP 5.33.2 git-919492bdcad8510eb6606439eb77e1c604f1d1ea
Loading...
Searching...
No Matches
pocketmine\inventory\transaction\EnchantingTransaction Class Reference
+ Inheritance diagram for pocketmine\inventory\transaction\EnchantingTransaction:
+ Collaboration diagram for pocketmine\inventory\transaction\EnchantingTransaction:

Public Member Functions

 __construct (Player $source, private readonly EnchantingOption $option, private readonly int $cost)
 
 addAction (InventoryAction $action)
 
 execute ()
 
 getActions ()
 
 getInventoryWindows ()
 
 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 $inventoryWindows = []
 

Detailed Description

Definition at line 36 of file EnchantingTransaction.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\inventory\transaction\EnchantingTransaction::__construct ( Player $source,
private readonly EnchantingOption $option,
private readonly int $cost )

Definition at line 41 of file EnchantingTransaction.php.

Member Function Documentation

◆ addAction()

pocketmine\inventory\transaction\InventoryTransaction::addAction ( InventoryAction $action)
inherited

Definition at line 112 of file InventoryTransaction.php.

◆ callExecuteEvent()

pocketmine\inventory\transaction\EnchantingTransaction::callExecuteEvent ( )
protected

◆ execute()

pocketmine\inventory\transaction\EnchantingTransaction::execute ( )

Executes the group of actions, returning whether the transaction executed successfully or not.

Exceptions
TransactionException

Reimplemented from pocketmine\inventory\transaction\InventoryTransaction.

Definition at line 114 of file EnchantingTransaction.php.

◆ findResultItem()

pocketmine\inventory\transaction\InventoryTransaction::findResultItem ( Item $needOrigin,
array $possibleActions )
protectedinherited
Parameters
SlotChangeAction[]$possibleActions@phpstan-param array<int, SlotChangeAction> $possibleActions

Definition at line 228 of file InventoryTransaction.php.

◆ getActions()

pocketmine\inventory\transaction\InventoryTransaction::getActions ( )
inherited

Returns a set of actions involved in this transaction.

Note: This system is designed to care only about item balances. While you can usually assume that the actions are provided in the correct order, it will still successfully complete transactions whose actions are provided in the "wrong" order, as long as the transaction balances. For example, you may see that an action setting a slot to a particular item may appear before the action that removes that item from its original slot. While unintuitive, this is still valid.

Returns
InventoryAction[] @phpstan-return array<int, InventoryAction>

Definition at line 108 of file InventoryTransaction.php.

◆ getInventoryWindows()

pocketmine\inventory\transaction\InventoryTransaction::getInventoryWindows ( )
inherited
Returns
InventoryWindow[] @phpstan-return array<int, InventoryWindow>

Definition at line 92 of file InventoryTransaction.php.

◆ getSource()

pocketmine\inventory\transaction\InventoryTransaction::getSource ( )
inherited

Definition at line 84 of file InventoryTransaction.php.

◆ hasExecuted()

pocketmine\inventory\transaction\InventoryTransaction::hasExecuted ( )
inherited

Definition at line 319 of file InventoryTransaction.php.

◆ matchItems()

pocketmine\inventory\transaction\InventoryTransaction::matchItems ( array & $needItems,
array & $haveItems )
protectedinherited
Parameters
Item[]$needItems
Item[]$haveItems@phpstan-param-out list<Item> $needItems @phpstan-param-out list<Item> $haveItems
Exceptions
TransactionValidationException

Definition at line 131 of file InventoryTransaction.php.

◆ squashDuplicateSlotChanges()

pocketmine\inventory\transaction\InventoryTransaction::squashDuplicateSlotChanges ( )
protectedinherited

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 182 of file InventoryTransaction.php.

◆ validate()

pocketmine\inventory\transaction\EnchantingTransaction::validate ( )

Verifies that the transaction can execute.

Exceptions
TransactionValidationException

Reimplemented from pocketmine\inventory\transaction\InventoryTransaction.

Definition at line 75 of file EnchantingTransaction.php.

Member Data Documentation

◆ $actions

array pocketmine\inventory\transaction\InventoryTransaction::$actions = []
protectedinherited

Definition at line 70 of file InventoryTransaction.php.

◆ $hasExecuted

bool pocketmine\inventory\transaction\InventoryTransaction::$hasExecuted = false
protectedinherited

Definition at line 58 of file InventoryTransaction.php.

◆ $inventoryWindows

array pocketmine\inventory\transaction\InventoryTransaction::$inventoryWindows = []
protectedinherited

Definition at line 64 of file InventoryTransaction.php.


The documentation for this class was generated from the following file: