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 aServerLocation
with a particularBlockType
and variousValue.Immutable
s defining the information for the "block". Note that normally, there may exist only a single instance of a particularBlockState
as they are immutable, a particular instance may be cached for various uses.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
BlockState.Builder
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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static BlockState.Builder
builder()
Creates a newBlockState.Builder
for buildingBlockState
s.FluidState
fluidState()
Gets the associatedFluidState
for this block state.static BlockState
fromString(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 BlockState
mirror(Supplier<? extends Mirror> mirror)
Gets the appropriateBlockState
for the desiredMirror
.BlockState
mirror(Mirror mirror)
Gets the appropriateBlockState
for the desiredMirror
.default BlockState
rotate(Supplier<? extends Rotation> rotation)
Gets the appropriateBlockState
for the desiredRotation
.BlockState
rotate(Rotation rotation)
Gets the appropriateBlockState
for the desiredRotation
.BlockSnapshot
snapshotFor(ServerLocation location)
BlockType
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 Detail
-
builder
static BlockState.Builder builder()
Creates a newBlockState.Builder
for buildingBlockState
s.- 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 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
BlockSnapshot snapshotFor(ServerLocation location)
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
BlockState rotate(Rotation rotation)
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
default BlockState rotate(Supplier<? extends Rotation> rotation)
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
BlockState mirror(Mirror 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
default BlockState mirror(Supplier<? extends Mirror> 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
-
-