Interface BlockState
public interface BlockState
A block state is a block and all its properties when placed in a world.
This implementation of block states is rather simple and abstract,
in order to remain as independent as possible from any actual implementation.
A block state is an immutable object that contains the identifier of the base block, as well as its properties and their values.
-
Method Summary
Modifier and TypeMethodDescriptiongetBlock()default intGets the properties of this state as a read only map.getProperty(String property) Gets the value of a given property of this state.booleanhasProperty(String property) Tests whether this state has a given property set.static BlockStateParses a serializedBlockStatefrom aString.withProperty(String property, boolean value) Gets a copy of this block state, with the given property applied.withProperty(String property, int value) Gets a copy of this block state, with the given property applied.withProperty(String property, String value) Gets a copy of this block state, with the given property applied.
-
Method Details
-
getBlock
Identifier getBlock()- Returns:
- the identifier of the base block of that state
-
getProperty
Gets the value of a given property of this state.- Parameters:
property- the name of the property to get- Returns:
- the property's value, or null if it doesn't have the given property
-
hasProperty
Tests whether this state has a given property set.- Parameters:
property- the property name- Returns:
trueif the state has the given property set,falseotherwise
-
withProperty
Gets a copy of this block state, with the given property applied.- Parameters:
property- the name of the property to add or changevalue- the value for the property- Returns:
- the resulting block state
-
withProperty
Gets a copy of this block state, with the given property applied.- Parameters:
property- the name of the property to add or changevalue- the value for the property- Returns:
- the resulting block state
-
withProperty
Gets a copy of this block state, with the given property applied.- Parameters:
property- the name of the property to add or changevalue- the value for the property- Returns:
- the resulting block state
-
getProperties
Map<String,BlockPropertyValue> getProperties()Gets the properties of this state as a read only map.- Returns:
- the map of properties names and values for this state
-
getPreviewColor
default int getPreviewColor()- Returns:
- a color that describes this state, to use when rendering a mpa, for example
-
parse
Parses a serializedBlockStatefrom aString.- Parameters:
string- a serializedBlockStateas it would be used in Minecraft commands- Returns:
- the parsed
BlockState - Throws:
IllegalArgumentException- if the supplied String is not a valid serialiedBlockState
-