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 a ServerLocation with a particular BlockType and various Value.Immutables 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.
  • Method Details

    • builder

      static BlockState.Builder builder()
      Creates a new BlockState.Builder for building BlockStates.
      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 a StateMatcher.
      Parameters:
      type - The block type
      Returns:
      The builder
    • matcher

      Constructs a new builder to construct a StateMatcher.
      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 associated FluidState 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 new BlockSnapshot with this current BlockState at the desired ServerLocation. If the ServerLocation has the same BlockState, and the BlockType can house a BlockEntity, the data from the block entity may be included in the returned BlockSnapshot.
      Parameters:
      location - The location for the snapshot
      Returns:
      The newly created snapshot
    • rotate

      BlockState rotate(Rotation rotation)
      Gets the appropriate BlockState for the desired Rotation. 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 appropriate BlockState for the desired Rotation. 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 appropriate BlockState for the desired Mirror. 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 appropriate BlockState for the desired Mirror. 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
    • asString

      String asString()
      Gets a string representation of this block state, including the block type and the properties. Do not confuse with State.toString() which is implementation specific.
      Returns:
      A string representation of this block state.