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 Type
    Method
    Description
    default String
    Returns this state in command syntax, for instance minecraft:oak_stairs[facing=north].
    <T> T
    get(BlockProperty<T> property)
    Returns the value of a property in this state.
    default <T> T
    getOrDefault(BlockProperty<T> property, T fallback)
    Returns the value of a property in this state, or fallback if this block does not declare it.
    boolean
    has(BlockProperty<?> property)
    Returns true if this block declares the property.
    default boolean
    Returns true for any kind of air.
    default boolean
    Returns true for a block of fluid: water or lava, but not a waterlogged block.
    key()
    Returns the key of the block type of this state.
    int
    Returns the network identifier of this state.
    int
    Returns the ordinal of this state within its block type.
    Returns the block type of this state.
    Returns every property value of this state, in declaration order.
    with(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

      default TypedKey<BlockType> key()
      Returns the key of the block type of this state.
      Returns:
      the key of the block type of this state
      Since:
      0.1.0
    • 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

      <T> T get(BlockProperty<T> property)
      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

      boolean has(BlockProperty<?> property)
      Returns true if this block declares the property.
      Parameters:
      property - the property
      Returns:
      true if this block declares the property
      Since:
      0.1.0
    • getOrDefault

      default <T> T getOrDefault(BlockProperty<T> property, T fallback)
      Returns the value of a property in this state, or fallback if this block does not declare it.
      Type Parameters:
      T - the type of the values
      Parameters:
      property - the property
      fallback - the value to return when the property is missing
      Returns:
      the value of a property in this state, or fallback if this block does not declare it
      Since:
      0.1.0
    • with

      <T> BlockData with(BlockProperty<T> property, T value)
      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 block
      value - 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()
      Returns true for any kind of air.
      Returns:
      true for any kind of air
      Since:
      0.1.0
    • isFluid

      default boolean isFluid()
      Returns true for a block of fluid: water or lava, but not a waterlogged block.
      Returns:
      true for a block of fluid: water or lava, but not a waterlogged block
      Since:
      0.1.0
    • asString

      default String asString()
      Returns this state in command syntax, for instance minecraft:oak_stairs[facing=north].
      Returns:
      this state in command syntax, for instance minecraft:oak_stairs[facing=north]
      Since:
      0.1.0