Interface BlockData
- All Known Subinterfaces:
Ageable, AnaloguePowerable, Bisected, Chest, Comparator, Directional, Door, FaceAttachable, Farmland, Hopper, Icicle, Levelled, Lightable, NoteBlock, Openable, Orientable, Piston, PistonHead, Powerable, RedstoneWire, Repeater, Rotatable, Slab, Snowable, Speleothem, Stairs, Switch, TechnicalPiston, Waterlogged
public interface BlockData
One state of a
BlockType: the block plus a value for each of its properties.
States are immutable and shared; with(BlockProperty, Object) and the with... methods
of the traits in fr.fidorial.world.block.data return another state.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault StringasString()Returns this state in command syntax, for instanceminecraft:oak_stairs[facing=north].<T> Tget(BlockProperty<T> property) Returns the value of a property in this state.default <T> TgetOrDefault(BlockProperty<T> property, T fallback) Returns the value of a property in this state, orfallbackif this block does not declare it.booleanhas(BlockProperty<?> property) Returnstrueif this block declares the property.default booleanisAir()Returnstruefor any kind of air.default booleanisFluid()Returnstruefor a block of fluid: water or lava, but not a waterlogged block.key()Returns the key of the block type of this state.intReturns the network identifier of this state.intordinal()Returns the ordinal of this state within its block type.type()Returns the block type of this state.List<PropertyValue<?>> values()Returns every property value of this state, in declaration order.<T> BlockDatawith(BlockProperty<T> property, T value) Returns the state of the same block with one property changed.
-
Method Details
-
type
BlockType type()Returns the block type of this state.- Returns:
- the block type of this state
- Since:
- 0.1.0
-
key
-
networkId
int networkId()Returns the network identifier of this state.- Returns:
- the network identifier of this state
- Since:
- 0.1.0
-
ordinal
int ordinal()Returns the ordinal of this state within its block type.- Returns:
- the ordinal of this state within its block type
- Since:
- 0.1.0
- See Also:
-
get
Returns the value of a property in this state.- Type Parameters:
T- the type of the values- Parameters:
property- the property, declared by this block- Returns:
- the value of a property in this state
- Throws:
IllegalArgumentException- if this block does not declare the property- Since:
- 0.1.0
-
has
Returnstrueif this block declares the property.- Parameters:
property- the property- Returns:
trueif this block declares the property- Since:
- 0.1.0
-
getOrDefault
Returns the value of a property in this state, orfallbackif this block does not declare it.- Type Parameters:
T- the type of the values- Parameters:
property- the propertyfallback- the value to return when the property is missing- Returns:
- the value of a property in this state, or
fallbackif this block does not declare it - Since:
- 0.1.0
-
with
Returns the state of the same block with one property changed.- Type Parameters:
T- the type of the values- Parameters:
property- the property, declared by this blockvalue- one of its values- Returns:
- the state of the same block with one property changed
- Throws:
IllegalArgumentException- if this block does not declare the property or the value- Since:
- 0.1.0
-
values
List<PropertyValue<?>> values()Returns every property value of this state, in declaration order.- Returns:
- every property value of this state, in declaration order
- Since:
- 0.1.0
-
isAir
default boolean isAir()Returnstruefor any kind of air.- Returns:
truefor any kind of air- Since:
- 0.1.0
-
isFluid
default boolean isFluid()Returnstruefor a block of fluid: water or lava, but not a waterlogged block.- Returns:
truefor a block of fluid: water or lava, but not a waterlogged block- Since:
- 0.1.0
-
asString
Returns this state in command syntax, for instanceminecraft:oak_stairs[facing=north].- Returns:
- this state in command syntax, for instance
minecraft:oak_stairs[facing=north] - Since:
- 0.1.0
-