public interface BlockState extends ImmutableDataHolder<BlockState>, DirectionRelativePropertyHolder, CatalogType
Location with
a particular BlockType and various ImmutableValues 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.| Modifier and Type | Interface and Description |
|---|---|
static interface |
BlockState.Builder
An
ImmutableDataBuilder for a BlockState. |
static class |
BlockState.MatcherBuilder
A builder for building
BlockState.StateMatchers. |
static class |
BlockState.StateMatcher
A
BlockState matcher that will match various block states
according to a pre-built list of BlockTraits and their
values, such that not all BlockTraits contained in a
BlockState must be matched. |
| Modifier and Type | Method and Description |
|---|---|
static BlockState.Builder |
builder()
Creates a new
BlockState.Builder for building BlockStates. |
BlockState |
cycleValue(Key<? extends BaseValue<? extends Cycleable<?>>> key)
Gets the associated
BlockState with the cycled
BaseValue. |
Optional<BlockTrait<?>> |
getTrait(String blockTrait)
Attempts to retrieve the
BlockTrait instance associated with
this BlockStates BlockType by string id. |
Map<BlockTrait<?>,?> |
getTraitMap()
Gets an immutable or unmodifiable
Map of the known BlockTraits
to their current values for this BlockState. |
Collection<BlockTrait<?>> |
getTraits()
|
<T extends Comparable<T>> |
getTraitValue(BlockTrait<T> blockTrait)
Gets the
Comparable value for the specific BlockTrait
such that if the BlockState does not support the
BlockTrait, Optional.empty() is returned. |
Collection<?> |
getTraitValues()
|
BlockType |
getType()
Gets the base type of block.
|
static BlockState.MatcherBuilder |
matcher(BlockType type)
Constructs a new
BlockState.MatcherBuilder to construct a BlockState.StateMatcher. |
BlockSnapshot |
snapshotFor(Location<World> location)
|
BlockState |
withExtendedProperties(Location<World> location)
Applies extended properties for the current @{link BlockType} if any to
the current
BlockState. |
Optional<BlockState> |
withTrait(BlockTrait<?> trait,
Object value)
Gets the
BlockState with the appropriate value for the given
BlockTrait. |
getManipulatorsgetContentVersion, toContainergetApplicableProperties, getPropertyget, getContainers, getOrCreate, merge, merge, supports, transform, with, with, with, with, withoutcopy, get, getKeys, getOrElse, getOrNull, getValue, getValues, require, supports, supportsgetPropertygetId, getNamestatic BlockState.Builder builder()
BlockState.Builder for building BlockStates.static BlockState.MatcherBuilder matcher(BlockType type)
BlockState.MatcherBuilder to construct a BlockState.StateMatcher.type - The block typeBlockType getType()
The type does not include block data such as the contents of inventories.
BlockState withExtendedProperties(Location<World> location)
BlockState. This usually is gathered from surrounding
BlockState's.
Note: This should only be called for live BlockState's at
a specific Location for accurate results.
Examples of some extended properties are:
location - The location used to search for extended propertiesBlockState cycleValue(Key<? extends BaseValue<? extends Cycleable<?>>> key)
BlockState with the cycled
BaseValue. Note that only Cycleable values can be
cycled. To change a particular Key'ed Value, usage
of the ImmutableValueStore.with(Key, Object) is recommended.key - The key to cycleBlockSnapshot snapshotFor(Location<World> location)
BlockSnapshot with this current BlockState
at the desired Location. If the Location has the same
BlockState, and the BlockType can house a
TileEntity, the data from the tile entity may be included in the
returned BlockSnapshot.location - The location for the snapshot<T extends Comparable<T>> Optional<T> getTraitValue(BlockTrait<T> blockTrait)
Comparable value for the specific BlockTrait
such that if the BlockState does not support the
BlockTrait, Optional.empty() is returned.T - The generic type of block traitblockTrait - The block trait instanceOptional<BlockTrait<?>> getTrait(String blockTrait)
BlockTrait instance associated with
this BlockStates BlockType by string id. If there is no
BlockTrait available, Optional.empty() is returned.blockTrait - The block trait idOptional<BlockState> withTrait(BlockTrait<?> trait, Object value)
BlockState with the appropriate value for the given
BlockTrait. If the BlockTrait is not supported,
Optional.empty() is returned. If the object is not either
an instance contained in BlockTrait.getPossibleValues() or
an instance Object.toString(), Optional.empty() may be
returned.trait - The traitvalue - The valueCollection<BlockTrait<?>> getTraits()
Collection<?> getTraitValues()
Map<BlockTrait<?>,?> getTraitMap()
Map of the known BlockTraits
to their current values for this BlockState.