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

Public Member Functions

 getState (string $state_string="")
 
 getStateFromArray (array $properties)
 

Static Public Member Functions

static get (string $name)
 
static all ()
 

Public Attributes

 $name
 
 $since_protocol_version
 
 $display_name
 
 $properties = []
 
 $states = []
 
 $legacy_id
 

Protected Member Functions

 __construct (string $name, int $since_protocol_version, $display_name)
 

Detailed Description

Since
0.5 Moved from Phpcraft to Phpcraft\World namespace

Constructor & Destructor Documentation

◆ __construct()

Phpcraft\World\Block::__construct ( string  $name,
int  $since_protocol_version,
  $display_name 
)
protected

Member Function Documentation

◆ all()

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

Returns an array containing every Block.

Returns
array<Block>

◆ get()

static Phpcraft\World\Block::get ( string  $name)
static

Returns a Block by its name or null if not found.

Parameters
string$name
Returns
Block|null

◆ getState()

Phpcraft\World\Block::getState ( string  $state_string = "")

Gets a BlockState using the given property string.

Parameters
string$state_stringA string in the format of "[facing=west][waterlogged=true]". Default values will be used for properties that are not given.
Returns
BlockState
Exceptions
InvalidArgumentExceptionIf an invalid state string, property name, or property value was given.

◆ getStateFromArray()

Phpcraft\World\Block::getStateFromArray ( array  $properties)

Gets a BlockState using the given associative string array.

Parameters
array<string,string>$properties Associative array containing the properties of the state. Default values will be used for properties that are not given.
Returns
BlockState|null
Exceptions
InvalidArgumentExceptionIf an invalid property name or value was given.

Member Data Documentation

◆ $display_name

string null Phpcraft\World\Block::$display_name

◆ $legacy_id

Phpcraft\World\Block::$legacy_id

◆ $name

string Phpcraft\World\Block::$name

◆ $properties

Phpcraft\World\Block::$properties = []

◆ $since_protocol_version

int Phpcraft\World\Block::$since_protocol_version

◆ $states

Phpcraft\World\Block::$states = []