Set bed at specified location

Hello. I need to create/set bed at specified location. Also I have direction data (in which bed should be rotated). I found this topic: https://forums.spongepowered.org/t/how-can-i-create-beds-programmatically/13692/2 but didn’t find the solution. Can anyone give a hint how to do it?

Location<World> location = getBedLocationSomewhere();
Direction dir = getBedDirectionSomewhere();

//set bed block at location?

EDIT: I am receiving this result: https://imgur.com/a/BbF2T, both blocks have ‘part: foot’ data (F3). I don’t know how to change it.

Thanks,
MrOnlineCoder

Have you tried looking at the metadata that is associated with the foot and the head of the bed? They may be both ‘part:foot’ but the metadata would help you differentiate between them.

1 Like

I think part: foot is the default value, I have set 2 blocks and they both have part:foot. The question is how to change this? Shouldn’t it be Keys something like Keys.BED_PART?