public interface BlockState extends ImmutableDataHolder<BlockState>, DirectionRelativePropertyHolder
Location
with
a particular BlockType
and various ImmutableValue
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.Modifier and Type | Method and Description |
---|---|
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 BlockState s BlockType by string id. |
Map<BlockTrait<?>,?> |
getTraitMap()
Gets an immutable or unmodifiable
Map of the known BlockTrait s
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()
Get the base type of block.
|
BlockSnapshot |
snapshotFor(Location<World> location)
|
Optional<BlockState> |
withTrait(BlockTrait<?> trait,
Object value)
Gets the
BlockState with the appropriate value for the given
BlockTrait . |
getManipulators
toContainer
getApplicableProperties, getProperty
get, getContainers, getOrCreate, merge, merge, supports, transform, with, with, with, with, without
copy, get, getKeys, getOrElse, getOrNull, getValue, getValues, supports, supports
getProperty
BlockType getType()
The type does not include block data such as the contents of inventories.
BlockState 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 BlockState
s 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 BlockTrait
s
to their current values for this BlockState
.