Flipping stairs upside down

So this might be a stupid question, but I’m kinda stuck here.

I know we have StairShapeData to change the shape of a stair and DirectionalData to change it’s direction, but how do I change if it’s upside down? I looked through the API and couldn’t find anything.
I’m probably missing it, but I don’t even know what exactly I’m looking for.

Imho the Data API is not very intuitive.
You get data with .get(Keys.DESIRED_KEY) and set them with .offer(Keys.DESIRED_KEY, value) or .offer(xDataInstance).
There are really a lot or confusing overloads to those functions, but you’ll probably only ever need these.

Okay but how do I do it specifically?
I have this code that gives me a north facing stair:

BlockState stair = BlockTypes.STONE_BRICK_STAIRS.getDefaultState();

DirectionalData directionalDataNorth = Sponge.getDataManager().getManipulatorBuilder(DirectionalData.class).get().create();
directionalDataNorth.set(Keys.DIRECTION, Direction.NORTH);
BlockState stairNorth = stair.with(directionalDataNorth.asImmutable()).get();

How do I now flip it upside down? As in, what key do I need and where do I apply it?
I haven’t found that anywhere in the documentation…

What @DosMike was getting at is you dont need to use the data manipulation directly. Instead you just need to do the Keys. As shown below

BlockState state;
state.offer(Keys.DIRECTION,  Direction.NORTH);

This does the same as your code but only shorter. As for flipping the stairs. When i get some time (probably next year) i can find out.

Or you can by just adding a command that tells you all the keys of the block your looking at. It should be obvious when you see the keys and the values.

You can get the keys and values of the block by doing the following.

BlockState state;
state.keys().stream().foreach(key -> {
    player.sendMessage(Text.of(key.getId() + " - " + state.get(key));
});
2 Likes

Ah yea found it, the key is Keys.PORTION_TYPE. Thanks ^^

Sidenote: BlockState#offer doesn’t exist, apparetly had to use BlockState#with (inherited from ImmutableValueStore ), so that gives me code like this:

BlockState stair = BlockTypes.STONE_BRICK_STAIRS.getDefaultState();

BlockState stairNorth = stair.with(Keys.DIRECTION, Direction.NORTH).get();
BlockState stairNorthUpsideDown = stairNorth.with(Keys.PORTION_TYPE, PortionTypes.TOP).get();
1 Like

Sorry. I knew it was offer or with. Glad i could help

Np, thanks again ^^

1 Like