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.Immutables 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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAnDataHolderBuilder.Immutablefor aBlockState.Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.MutableNested classes/interfaces inherited from interface org.spongepowered.api.data.DirectionRelativeDataHolder
DirectionRelativeDataHolder.Immutable<I extends DirectionRelativeDataHolder.Immutable<I>>, DirectionRelativeDataHolder.MutableNested 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.Builderbuilder()Creates a newBlockState.Builderfor buildingBlockStates.Gets the associatedFluidStatefor this block state.static BlockStatefromString(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 BlockStateGets the appropriateBlockStatefor the desiredMirror.Gets the appropriateBlockStatefor the desiredMirror.default BlockStateGets the appropriateBlockStatefor the desiredRotation.Gets the appropriateBlockStatefor 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, withoutMethods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainerMethods inherited from interface org.spongepowered.api.data.DirectionRelativeDataHolder
get, getDouble, getInt, getLongMethods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawDataMethods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Immutable
copy, withRawDataMethods 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.Builderfor buildingBlockStates.- 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 associatedFluidStatefor 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 newBlockSnapshotwith this currentBlockStateat the desiredServerLocation. If theServerLocationhas the sameBlockState, and theBlockTypecan 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 appropriateBlockStatefor 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 appropriateBlockStatefor 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 appropriateBlockStatefor 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 appropriateBlockStatefor 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.
-