PocketMine-MP 5.15.1 git-5ef247620a7c6301a849b54e5ef1009217729fc8
pocketmine\inventory\transaction\action\SlotChangeAction Class Reference
+ Inheritance diagram for pocketmine\inventory\transaction\action\SlotChangeAction:
+ Collaboration diagram for pocketmine\inventory\transaction\action\SlotChangeAction:

Public Member Functions

 __construct (protected Inventory $inventory, private int $inventorySlot, Item $sourceItem, Item $targetItem)
 
 execute (Player $source)
 
 getInventory ()
 
 getSlot ()
 
 getSourceItem ()
 
 getTargetItem ()
 
 onAddToTransaction (InventoryTransaction $transaction)
 
 onPreExecute (Player $source)
 
 validate (Player $source)
 

Detailed Description

Represents an action causing a change in an inventory slot.

Definition at line 35 of file SlotChangeAction.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\inventory\transaction\action\SlotChangeAction::__construct ( protected Inventory  $inventory,
private int  $inventorySlot,
Item  $sourceItem,
Item  $targetItem 
)

Definition at line 36 of file SlotChangeAction.php.

Member Function Documentation

◆ execute()

pocketmine\inventory\transaction\action\SlotChangeAction::execute ( Player  $source)

Sets the item into the target inventory.

Reimplemented from pocketmine\inventory\transaction\action\InventoryAction.

Definition at line 89 of file SlotChangeAction.php.

◆ getInventory()

pocketmine\inventory\transaction\action\SlotChangeAction::getInventory ( )

Returns the inventory involved in this action.

Definition at line 48 of file SlotChangeAction.php.

◆ getSlot()

pocketmine\inventory\transaction\action\SlotChangeAction::getSlot ( )

Returns the slot in the inventory which this action modified.

Definition at line 55 of file SlotChangeAction.php.

◆ getSourceItem()

pocketmine\inventory\transaction\action\InventoryAction::getSourceItem ( )
inherited

Returns the item that was present before the action took place.

Definition at line 43 of file InventoryAction.php.

◆ getTargetItem()

pocketmine\inventory\transaction\action\InventoryAction::getTargetItem ( )
inherited

Returns the item that the action attempted to replace the source item with.

Definition at line 50 of file InventoryAction.php.

◆ onAddToTransaction()

pocketmine\inventory\transaction\action\SlotChangeAction::onAddToTransaction ( InventoryTransaction  $transaction)

Adds this action's target inventory to the transaction's inventory list.

Reimplemented from pocketmine\inventory\transaction\action\InventoryAction.

Definition at line 82 of file SlotChangeAction.php.

◆ onPreExecute()

pocketmine\inventory\transaction\action\InventoryAction::onPreExecute ( Player  $source)
inherited

Called by inventory transactions before any actions are processed. If this returns false, the transaction will be cancelled.

Reimplemented in pocketmine\inventory\transaction\action\DropItemAction.

Definition at line 72 of file InventoryAction.php.

◆ validate()

pocketmine\inventory\transaction\action\SlotChangeAction::validate ( Player  $source)

Checks if the item in the inventory at the specified slot is the same as this action's source item.

Exceptions
TransactionValidationException

Reimplemented from pocketmine\inventory\transaction\action\InventoryAction.

Definition at line 64 of file SlotChangeAction.php.


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