Rotate directional data?

How do you rotate directional data? This doesn’t work for me:

            Optional<DirectionalData> optionalDirectionalData = blockLocation.get(DirectionalData.class);
            if (optionalDirectionalData.isPresent()) {
                DirectionalData data = optionalDirectionalData.get();
                Value<Direction> directionData = data.direction();
                directionData.set(Direction.getClosest(rotation.rotate(data.direction().get().asOffset())));
                data.set(directionData);
                blockLocation.offer(directionData);
            }

EDIT:
Quaterniond rotation = Quaterniond.fromAxesAnglesDeg(0, left ? 90 : 270, 0);

I also tried this but still nothing happens:
Optional optionalDirection = blockLocation.get(Keys.DIRECTION);
if (optionalDirection.isPresent()) {
Direction direction = optionalDirection.get();
blockLocation.offer(Keys.DIRECTION, getRotatedDirection(direction, left));
}

private Direction getRotatedDirection(Direction direction) {
switch (direction) {
case NORTH:
return Direction.EAST;
case EAST:
return Direction.SOUTH;
case SOUTH:
return Direction.WEST;
case WEST:
return Direction.NORTH;
default:
return direction;
}
}

private Direction getRotatedDirection(Direction direction, boolean left) {
return left ? getRotatedDirection(direction)
: getRotatedDirection(getRotatedDirection(getRotatedDirection(direction)));
}

Flat out doing this doesn’t work…
blockLocation.offer(Keys.DIRECTION, Direction.EAST);
I verified that it gets called too.

What block are you trying to rotate?

1 Like

I’m trying stairs in my test. Oh, and signs, as well.

I think offering the direction simply does not work…

        blockLocation.setBlock(
                blockLocation.getBlock().with(Keys.DIRECTION, Starship.getRotatedDirection(direction)).get(),
                Cause.of(NamedCause.owner(StarshipsPlugin.getInstance().getContainer())));

this works apparently