BlockFactory
in package
Uses
SingletonTrait
Manages deserializing block types from their legacy blockIDs and metadata.
This is primarily needed for loading chunks from disk.
Table of Contents
- $blastResistance : SplFixedArray|array<string|int, float>
- $blocksDirectSkyLight : SplFixedArray|array<string|int, bool>
- $light : SplFixedArray|array<string|int, int>
- $lightFilter : SplFixedArray|array<string|int, int>
- $fullList : SplFixedArray|array<string|int, Block>
- $instance : self|null
- $mappedStateIds : SplFixedArray
- __construct() : mixed
- fromFullBlock() : Block
- get() : Block
- getAllKnownStates() : array<string|int, Block>
- getInstance() : self
- getMappedStateId() : int
- Returns the ID of the state mapped to the given state ID.
- isRegistered() : bool
- Returns whether a specified block state is already registered in the block factory.
- register() : void
- Maps a block type to its corresponding ID. This is necessary to ensure that the block is correctly loaded when reading from disk storage.
- remap() : void
- reset() : void
- setInstance() : void
- fillStaticArrays() : void
- make() : self
- registerAllMeta() : void
- Claims the whole metadata range (0-15) for all IDs associated with this block. Any unregistered states will be mapped to the default (provided) state.
- registerElements() : void
- registerMushroomBlocks() : void
- registerSlabWithDoubleHighBitsRemapping() : void
Properties
$blastResistance
public
SplFixedArray|array<string|int, float>
$blastResistance
Tags
$blocksDirectSkyLight
public
SplFixedArray|array<string|int, bool>
$blocksDirectSkyLight
Tags
$light
public
SplFixedArray|array<string|int, int>
$light
Tags
$lightFilter
public
SplFixedArray|array<string|int, int>
$lightFilter
Tags
$fullList
private
SplFixedArray|array<string|int, Block>
$fullList
Tags
$instance
private
static self|null
$instance
= null
$mappedStateIds
private
SplFixedArray
$mappedStateIds
Tags
Methods
__construct()
public
__construct() : mixed
Return values
mixed —fromFullBlock()
public
fromFullBlock(int $fullState) : Block
Parameters
- $fullState : int
Return values
Block —get()
public
get(int $id, int $meta) : Block
Parameters
- $id : int
- $meta : int
Tags
Return values
Block —getAllKnownStates()
public
getAllKnownStates() : array<string|int, Block>
Return values
array<string|int, Block> —getInstance()
public
static getInstance() : self
Return values
self —getMappedStateId()
Returns the ID of the state mapped to the given state ID.
public
getMappedStateId(int $fullState) : int
Used to correct invalid blockstates found in loaded chunks.
Parameters
- $fullState : int
Return values
int —isRegistered()
Returns whether a specified block state is already registered in the block factory.
public
isRegistered(int $id[, int $meta = 0 ]) : bool
Parameters
- $id : int
- $meta : int = 0
Return values
bool —register()
Maps a block type to its corresponding ID. This is necessary to ensure that the block is correctly loaded when reading from disk storage.
public
register(Block $block[, bool $override = false ]) : void
NOTE: If you are registering a new block type, you will need to add it to the creative inventory yourself - it will not automatically appear there.
Parameters
- $block : Block
- $override : bool = false
-
Whether to override existing registrations
Tags
Return values
void —remap()
public
remap(int $id, int $meta, Block $block) : void
Parameters
- $id : int
- $meta : int
- $block : Block
Return values
void —reset()
public
static reset() : void
Return values
void —setInstance()
public
static setInstance(self $instance) : void
Parameters
- $instance : self
Return values
void —fillStaticArrays()
private
fillStaticArrays(int $index, Block $block) : void
Parameters
- $index : int
- $block : Block
Return values
void —make()
private
static make() : self
Return values
self —registerAllMeta()
Claims the whole metadata range (0-15) for all IDs associated with this block. Any unregistered states will be mapped to the default (provided) state.
private
registerAllMeta(Block $default, Block ...$additional) : void
This should only be used when this block type has sole ownership of an ID. For IDs which contain multiple block types (variants), the regular register() method should be used instead.
Parameters
Return values
void —registerElements()
private
registerElements() : void
Return values
void —registerMushroomBlocks()
private
registerMushroomBlocks() : void
Return values
void —registerSlabWithDoubleHighBitsRemapping()
private
registerSlabWithDoubleHighBitsRemapping(Slab $block) : void
Parameters
- $block : Slab