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: 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:, both blocks have ‘part: foot’ data (F3). I don’t know how to change it.



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.


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?