Package org.spongepowered.api.block
Interface BlockState
- All Superinterfaces:
CopyableDataHolder
,DataHolder
,DataHolder.Immutable<BlockState>
,DataSerializable
,DirectionRelativeDataHolder
,DirectionRelativeDataHolder.Immutable<BlockState>
,SerializableDataHolder
,SerializableDataHolder.Immutable<BlockState>
,State<BlockState>
,ValueContainer
public interface BlockState
extends State<BlockState>, DirectionRelativeDataHolder.Immutable<BlockState>
Represents a particular "state" that can exist at a
ServerLocation
with
a particular BlockType
and various Value.Immutable
s defining
the information for the "block". Note that normally, there may exist only
a single instance of a particular BlockState
as they are immutable,
a particular instance may be cached for various uses.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
AnDataHolderBuilder.Immutable
for aBlockState
.Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DirectionRelativeDataHolder
DirectionRelativeDataHolder.Immutable<I extends DirectionRelativeDataHolder.Immutable<I>>, DirectionRelativeDataHolder.Mutable
Nested classes/interfaces inherited from interface org.spongepowered.api.data.SerializableDataHolder
SerializableDataHolder.Immutable<I extends SerializableDataHolder.Immutable<I>>, SerializableDataHolder.Mutable
-
Method Summary
Modifier and TypeMethodDescriptionasString()
Gets a string representation of this block state, including the block type and the properties.static BlockState.Builder
builder()
Creates a newBlockState.Builder
for buildingBlockState
s.Gets the associatedFluidState
for this block state.static BlockState
fromString
(String id) static StateMatcher.Builder
<BlockState, BlockType> Constructs a new builder to construct aStateMatcher
.static StateMatcher.Builder
<BlockState, BlockType> Constructs a new builder to construct aStateMatcher
.default BlockState
Gets the appropriateBlockState
for the desiredMirror
.Gets the appropriateBlockState
for the desiredMirror
.default BlockState
Gets the appropriateBlockState
for the desiredRotation
.Gets the appropriateBlockState
for the desiredRotation
.snapshotFor
(ServerLocation location) type()
Gets the base type of block.Methods inherited from interface org.spongepowered.api.data.DataHolder.Immutable
mergeWith, mergeWith, transform, transform, with, with, with, without, without, without
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
Methods inherited from interface org.spongepowered.api.data.DirectionRelativeDataHolder
get, getDouble, getInt, getLong
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawData
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Immutable
copy, withRawData
Methods inherited from interface org.spongepowered.api.state.State
cycleStateProperty, cycleStateProperty, cycleValue, cycleValue, findStateProperty, stateProperties, stateProperty, stateProperty, statePropertyMap, statePropertyValues, toString, withStateProperty, withStateProperty
-
Method Details
-
builder
Creates a newBlockState.Builder
for buildingBlockState
s.- Returns:
- The builder
-
fromString
-
matcher
Constructs a new builder to construct aStateMatcher
.- Parameters:
type
- The block type- Returns:
- The builder
-
matcher
Constructs a new builder to construct aStateMatcher
.- Parameters:
type
- The block type- Returns:
- The builder
-
type
BlockType type()Gets the base type of block.The type does not include block data such as the contents of inventories.
- Returns:
- The type of block
-
fluidState
FluidState fluidState()Gets the associatedFluidState
for this block state. Depending on whether this block state is considered "waterlogged" or not, and with which fluid.- Returns:
- The fluid state
-
snapshotFor
Creates a newBlockSnapshot
with this currentBlockState
at the desiredServerLocation
. If theServerLocation
has the sameBlockState
, and theBlockType
can house aBlockEntity
, the data from the block entity may be included in the returnedBlockSnapshot
.- Parameters:
location
- The location for the snapshot- Returns:
- The newly created snapshot
-
rotate
Gets the appropriateBlockState
for the desiredRotation
. It may return the same state, but some states may have extra logic associated with rotating on its axis, much like mirroring.- Parameters:
rotation
- The rotation- Returns:
- The rotated state if not this state
-
rotate
Gets the appropriateBlockState
for the desiredRotation
. It may return the same state, but some states may have extra logic associated with rotating on its axis, much like mirroring.- Parameters:
rotation
- The rotation- Returns:
- The rotated state if not this state
-
mirror
Gets the appropriateBlockState
for the desiredMirror
. It may return the same state, but some states may have extra logic associated with mirroring on its axis, much like rotation.- Parameters:
mirror
- The mirror- Returns:
- The mirrored state if not this state
-
mirror
Gets the appropriateBlockState
for the desiredMirror
. It may return the same state, but some states may have extra logic associated with mirroring on its axis, much like rotation.- Parameters:
mirror
- The mirror- Returns:
- The mirrored state if not this state
-
asString
String asString()Gets a string representation of this block state, including the block type and the properties. Do not confuse withState.toString()
which is implementation specific.- Returns:
- A string representation of this block state.
-