Documentation

BlockTransaction
in package

Table of Contents

$blocks  : array<string|int, array<string|int, array<string|int, Block>>>
$validators  : array<string|int, Closure>
$world  : ChunkManager
__construct()  : mixed
addBlock()  : $this
Adds a block to the transaction at the given position.
addBlockAt()  : $this
Adds a block to the batch at the given coordinates.
addValidator()  : void
Add a validation predicate which will be used to validate every block.
apply()  : bool
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.
dummyValidator()  : bool
Dummy function demonstrating the required closure signature for validators.
fetchBlock()  : Block
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.
fetchBlockAt()  : Block
getBlocks()  : Generator|array<string|int, mixed>

Properties

$validators

private array<string|int, Closure> $validators = []
Tags
phpstan-var

(\Closure(ChunkManager $world, int $x, int $y, int $z) : bool)[]

Methods

addBlockAt()

Adds a block to the batch at the given coordinates.

public addBlockAt(int $x, int $y, int $z, Block $state) : $this
Parameters
$x : int
$y : int
$z : int
$state : Block
Return values
$this

addValidator()

Add a validation predicate which will be used to validate every block.

public addValidator(Closure $validator) : void

The callable signature should be the same as the below dummy function.

Parameters
$validator : Closure
Tags
see
BlockTransaction::dummyValidator()
phpstan-param

\Closure(ChunkManager $world, int $x, int $y, int $z) : bool $validator

Return values
void

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.

public apply() : bool
Return values
bool

if the application was successful

fetchBlock()

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.

public fetchBlock(Vector3 $pos) : Block
Parameters
$pos : Vector3
Return values
Block

getBlocks()

public getBlocks() : Generator|array<string|int, mixed>
Tags
phpstan-return

\Generator<int, array{int, int, int, Block}, void, void>

Return values
Generator|array<string|int, mixed>

[int $x, int $y, int $z, Block $block]

Search results