Phpcraft
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Phpcraft\World\BlockState Class Reference

Public Member Functions

 __construct (Block &$block, int $state_i, array $properties, array $ids)
 
 getId (int $protocol_version)
 
 getLegacyMetadata ()
 
 __toString ()
 
 getStateString ()
 
 getCompatible (int $protocol_version)
 

Static Public Member Functions

static getById (int $id, int $protocol_version)
 
static all ()
 
static get (string $str)
 

Public Attributes

 $block
 
 $properties
 
 $ids
 

Detailed Description

Since
0.5 Moved from Phpcraft to Phpcraft\World namespace

Constructor & Destructor Documentation

◆ __construct()

Phpcraft\World\BlockState::__construct ( Block $block,
int  $state_i,
array  $properties,
array  $ids 
)

Member Function Documentation

◆ __toString()

Phpcraft\World\BlockState::__toString ( )

◆ all()

static Phpcraft\World\BlockState::all ( )
static

Returns an array containing every BlockState.

Returns
array<BlockState>

◆ get()

static Phpcraft\World\BlockState::get ( string  $str)
static

Returns a BlockState by its string representation, null if the block is not found, or throws an exception if an invalid state is given.

Parameters
string$strA BlockState string representation, e.g. "grass_block[snowy=true]"
Returns
BlockState|null

◆ getById()

static Phpcraft\World\BlockState::getById ( int  $id,
int  $protocol_version 
)
static

Returns a BlockState by its ID in the given protocol version or null if not found.

Parameters
int$id
int$protocol_version
Returns
BlockState|null

◆ getCompatible()

Phpcraft\World\BlockState::getCompatible ( int  $protocol_version)

Gets a replacement BlockState compatible with the given protocol_version, or $this if it's compatible.

Parameters
int$protocol_version
Returns
BlockState
Since
0.5

◆ getId()

Phpcraft\World\BlockState::getId ( int  $protocol_version)

Returns the ID of this BlockState for the given protocol version or null if not applicable.

Parameters
int$protocol_version
Returns
int|null

◆ getLegacyMetadata()

Phpcraft\World\BlockState::getLegacyMetadata ( )

◆ getStateString()

Phpcraft\World\BlockState::getStateString ( )

Member Data Documentation

◆ $block

Block Phpcraft\World\BlockState::$block

◆ $ids

array< int, int > Phpcraft\World\BlockState::$ids

◆ $properties

array< BlockProperty > Phpcraft\World\BlockState::$properties