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 aServerLocationwith a particularBlockTypeand variousValue.Immutables defining the information for the "block". Note that normally, there may exist only a single instance of a particularBlockStateas they are immutable, a particular instance may be cached for various uses.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceBlockState.BuilderAnDataHolderBuilder.Immutablefor 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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description StringasString()Gets a string representation of this block state, including the block type and the properties.static BlockState.Builderbuilder()Creates a newBlockState.Builderfor buildingBlockStates.FluidStatefluidState()Gets the associatedFluidStatefor this block state.static BlockStatefromString(String id)static StateMatcher.Builder<BlockState,BlockType>matcher(Supplier<? extends BlockType> type)Constructs a new builder to construct aStateMatcher.static StateMatcher.Builder<BlockState,BlockType>matcher(BlockType type)Constructs a new builder to construct aStateMatcher.default BlockStatemirror(Supplier<? extends Mirror> mirror)Gets the appropriateBlockStatefor the desiredMirror.BlockStatemirror(Mirror mirror)Gets the appropriateBlockStatefor the desiredMirror.default BlockStaterotate(Supplier<? extends Rotation> rotation)Gets the appropriateBlockStatefor the desiredRotation.BlockStaterotate(Rotation rotation)Gets the appropriateBlockStatefor the desiredRotation.BlockSnapshotsnapshotFor(ServerLocation location)BlockTypetype()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 Detail
-
builder
static BlockState.Builder builder()
Creates a newBlockState.Builderfor buildingBlockStates.- Returns:
- The builder
-
fromString
static BlockState fromString(String id)
-
matcher
static StateMatcher.Builder<BlockState,BlockType> matcher(Supplier<? extends BlockType> type)
Constructs a new builder to construct aStateMatcher.- Parameters:
type- The block type- Returns:
- The builder
-
matcher
static StateMatcher.Builder<BlockState,BlockType> matcher(BlockType type)
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
BlockSnapshot snapshotFor(ServerLocation location)
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
BlockState rotate(Rotation rotation)
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
default BlockState rotate(Supplier<? extends Rotation> rotation)
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
BlockState mirror(Mirror 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
default BlockState mirror(Supplier<? extends Mirror> 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.
-
-