PocketMine-MP 5.33.2 git-1133d49c924b4358c79d44eeb97dcbf56cb4d1eb
|
Public Member Functions | |
__construct (Player $source, CraftingManager $craftingManager, array $actions=[], ?CraftingRecipe $recipe=null, ?int $repetitions=null) | |
addAction (InventoryAction $action) | |
execute () | |
getActions () | |
getInventoryWindows () | |
getSource () | |
hasExecuted () | |
validate () | |
Static Public Member Functions | |
static | matchIngredients (array $providedItems, array $recipeIngredients, int $expectedIterations) |
Protected Member Functions | |
callExecuteEvent () | |
findResultItem (Item $needOrigin, array $possibleActions) | |
matchItems (array &$needItems, array &$haveItems) | |
matchOutputs (array $txItems, array $recipeItems) | |
squashDuplicateSlotChanges () | |
Protected Attributes | |
array | $actions = [] |
bool | $hasExecuted = false |
array | $inputs = [] |
array | $inventoryWindows = [] |
array | $outputs = [] |
CraftingRecipe | $recipe = null |
int | $repetitions = null |
This transaction type is specialized for crafting validation. It shares most of the same semantics of the base inventory transaction type, but the requirement for validity is slightly different.
It is expected that the actions in this transaction type will produce an unbalanced result, i.e. some inputs won't have corresponding outputs, and vice versa. The reason why is because the unmatched inputs are recipe inputs, and the unmatched outputs are recipe results.
Therefore, the validity requirement is that the imbalance of the transaction should match the expected inputs and outputs of a registered crafting recipe.
This transaction allows multiple repetitions of the same recipe to be crafted in a single batch. In the case of batch crafting, the number of unmatched inputs and outputs must be exactly divisible by the expected recipe ingredients and results, with no remainder. Any leftovers are expected to be emitted back to the crafting grid.
Definition at line 56 of file CraftingTransaction.php.
pocketmine\inventory\transaction\CraftingTransaction::__construct | ( | Player | $source, |
CraftingManager | $craftingManager, | ||
array | $actions = [], | ||
?CraftingRecipe | $recipe = null, | ||
?int | $repetitions = null ) |
Definition at line 73 of file CraftingTransaction.php.
|
inherited |
Definition at line 112 of file InventoryTransaction.php.
|
protected |
Reimplemented from pocketmine\inventory\transaction\InventoryTransaction.
Definition at line 291 of file CraftingTransaction.php.
|
inherited |
Executes the group of actions, returning whether the transaction executed successfully or not.
TransactionException |
Reimplemented in pocketmine\inventory\transaction\EnchantingTransaction.
Definition at line 295 of file InventoryTransaction.php.
|
protectedinherited |
SlotChangeAction[] | $possibleActions | @phpstan-param array<int, SlotChangeAction> $possibleActions |
Definition at line 228 of file InventoryTransaction.php.
|
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.
Definition at line 108 of file InventoryTransaction.php.
|
inherited |
Definition at line 92 of file InventoryTransaction.php.
|
inherited |
Definition at line 84 of file InventoryTransaction.php.
|
inherited |
Definition at line 319 of file InventoryTransaction.php.
|
static |
Item[] | $providedItems | |
RecipeIngredient[] | $recipeIngredients |
@phpstan-param list<Item> $providedItems @phpstan-param list<RecipeIngredient> $recipeIngredients
Definition at line 110 of file CraftingTransaction.php.
|
protectedinherited |
Item[] | $needItems | |
Item[] | $haveItems | @phpstan-param-out list<Item> $needItems @phpstan-param-out list<Item> $haveItems |
TransactionValidationException |
Definition at line 131 of file InventoryTransaction.php.
|
protected |
Item[] | $txItems | |
Item[] | $recipeItems |
@phpstan-param list<Item> $txItems @phpstan-param list<Item> $recipeItems
TransactionValidationException |
Definition at line 192 of file CraftingTransaction.php.
|
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.
pocketmine\inventory\transaction\CraftingTransaction::validate | ( | ) |
Verifies that the transaction can execute.
TransactionValidationException |
Reimplemented from pocketmine\inventory\transaction\InventoryTransaction.
Definition at line 257 of file CraftingTransaction.php.
|
protectedinherited |
Definition at line 70 of file InventoryTransaction.php.
|
protectedinherited |
Definition at line 58 of file InventoryTransaction.php.
|
protected |
Definition at line 64 of file CraftingTransaction.php.
|
protectedinherited |
Definition at line 64 of file InventoryTransaction.php.
|
protected |
Definition at line 69 of file CraftingTransaction.php.
|
protected |
Definition at line 57 of file CraftingTransaction.php.
|
protected |
Definition at line 58 of file CraftingTransaction.php.