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
$blocks
private
array<string|int, array<string|int, array<string|int, Block>>>
$blocks
= []
$validators
private
array<string|int, Closure>
$validators
= []
Tags
$world
private
ChunkManager
$world
Methods
__construct()
public
__construct(ChunkManager $world) : mixed
Parameters
- $world : ChunkManager
Return values
mixed —addBlock()
Adds a block to the transaction at the given position.
public
addBlock(Vector3 $pos, Block $state) : $this
Parameters
Return values
$this —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
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
dummyValidator()
Dummy function demonstrating the required closure signature for validators.
public
dummyValidator(ChunkManager $world, int $x, int $y, int $z) : bool
Parameters
- $world : ChunkManager
- $x : int
- $y : int
- $z : int
Tags
Return values
bool —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 —fetchBlockAt()
public
fetchBlockAt(int $x, int $y, int $z) : Block
Parameters
- $x : int
- $y : int
- $z : int
Tags
Return values
Block —getBlocks()
public
getBlocks() : Generator|array<string|int, mixed>
Tags
Return values
Generator|array<string|int, mixed> —[int $x, int $y, int $z, Block $block]