Skip to content

CraftingTransaction ​

class · pocketmine\inventory\transaction\CraftingTransaction · source

Extends InventoryTransaction

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.

Properties ​

$inputs protected ​

php
protected array $inputs

$outputs protected ​

php
protected array $outputs

$recipe protected ​

php
protected ?\pocketmine\crafting\CraftingRecipe $recipe

$repetitions protected ​

php
protected ?int $repetitions

Methods ​

__construct() ​

php
public function __construct(\pocketmine\player\Player $source, \pocketmine\crafting\CraftingManager $craftingManager, array $actions = [], ?\pocketmine\crafting\CraftingRecipe $recipe = null, ?int $repetitions = null)

callExecuteEvent() protected ​

php
protected function callExecuteEvent() : bool

matchIngredients() ​

php
public static function matchIngredients(array $providedItems, array $recipeIngredients, int $expectedIterations) : void

matchOutputs() protected ​

php
protected function matchOutputs(array $txItems, array $recipeItems) : int

validate() ​

php
public function validate() : void

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.