How to set facing direction of blocks?


How can I set the direction of a block at a given location?

In another thread I’ve read that the direction can be set via the DirectionalData interface.

If I have

  1. instance of<World> and
  2. org.spongepowered.api.util.Direction,

how can I set the direction of 1 to 2?

Using the code below or differently?

private fun setDirection(
        direction: Direction) {
    loc.offer(Keys.DIRECTION, direction)

Here’s the Bukkit analog of what I’m trying to achieve:

protected void setFacingDirection(final BlockFace face, final Block block) {
    final BlockState state = block.getState();
    final MaterialData materialData = state.getData();
    if (materialData instanceof Directional) {
        final Directional directional = (Directional) materialData;


Dmitri Pisarenko

Which BlockType are you trying to set the data on? (e.g. stairs)
I know the Keys.DIRECTION works for stairs because this works for my project

BlockTypes.STONE_BRICK_STAIRS.getDefaultState().with(Keys.DIRECTION, Direction.NORTH).get()

Have you checked the block at the location supports() the key?

1 Like