PocketMine-MP 5.15.1 git-fb9a74e8799c71ed8292cfa53abe7a4c9204629d
pocketmine\world\BlockTransaction Class Reference
+ Collaboration diagram for pocketmine\world\BlockTransaction:

Public Member Functions

 __construct (private ChunkManager $world)
 
 addBlock (Vector3 $pos, Block $state)
 
 addBlockAt (int $x, int $y, int $z, Block $state)
 
 addValidator (\Closure $validator)
 
 apply ()
 
 dummyValidator (ChunkManager $world, int $x, int $y, int $z)
 
 fetchBlock (Vector3 $pos)
 
 fetchBlockAt (int $x, int $y, int $z)
 
 getBlocks ()
 

Detailed Description

Definition at line 30 of file BlockTransaction.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\world\BlockTransaction::__construct ( private ChunkManager  $world)

Definition at line 40 of file BlockTransaction.php.

Member Function Documentation

◆ addBlock()

pocketmine\world\BlockTransaction::addBlock ( Vector3  $pos,
Block  $state 
)

Adds a block to the transaction at the given position.

Returns
$this

Definition at line 51 of file BlockTransaction.php.

Referenced by pocketmine\block\Bed\place(), pocketmine\block\Door\place(), and pocketmine\block\DoublePlant\place().

+ Here is the caller graph for this function:

◆ addBlockAt()

pocketmine\world\BlockTransaction::addBlockAt ( int  $x,
int  $y,
int  $z,
Block  $state 
)

Adds a block to the batch at the given coordinates.

Returns
$this

Definition at line 60 of file BlockTransaction.php.

◆ addValidator()

pocketmine\world\BlockTransaction::addValidator ( \Closure  $validator)

Add a validation predicate which will be used to validate every block. The callable signature should be the same as the below dummy function.

See also
BlockTransaction::dummyValidator()

@phpstan-param \Closure(ChunkManager $world, int $x, int $y, int $z) : bool $validator

Definition at line 126 of file BlockTransaction.php.

◆ apply()

pocketmine\world\BlockTransaction::apply ( )

Validates and attempts to apply the transaction to the given world. If any part of the transaction fails to validate, no changes will be made to the world.

Returns
bool if the application was successful

Definition at line 86 of file BlockTransaction.php.

◆ dummyValidator()

pocketmine\world\BlockTransaction::dummyValidator ( ChunkManager  $world,
int  $x,
int  $y,
int  $z 
)

Dummy function demonstrating the required closure signature for validators.

See also
BlockTransaction::addValidator()

@dummy

Definition at line 137 of file BlockTransaction.php.

◆ fetchBlock()

pocketmine\world\BlockTransaction::fetchBlock ( Vector3  $pos)

Reads a block from the given world, masked by the blocks in this transaction. This can be useful if you want to add blocks to the transaction that depend on previous blocks should they exist.

Definition at line 69 of file BlockTransaction.php.

◆ fetchBlockAt()

pocketmine\world\BlockTransaction::fetchBlockAt ( int  $x,
int  $y,
int  $z 
)
See also
BlockTransaction::fetchBlock()

Definition at line 76 of file BlockTransaction.php.

◆ getBlocks()

pocketmine\world\BlockTransaction::getBlocks ( )
Returns
\Generator|mixed[] [int $x, int $y, int $z, Block $block] @phpstan-return \Generator<int, array{int, int, int, Block}, void, void>

Definition at line 109 of file BlockTransaction.php.


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