use of net.glowstone.block.entity.state.GlowBed in project Glowstone by GlowstoneMC.
the class BlockBed method afterPlace.
@Override
public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding, GlowBlockState oldState) {
Material type = block.getType();
if (!MaterialTags.BEDS.isTagged(type)) {
return;
}
GlowBed bed = (GlowBed) block.getState();
bed.setColor(DyeColor.getByWoolData(holding.getData().getData()));
bed.update(true);
BlockFace direction = ((Bed) bed.getData()).getFacing();
GlowBlock headBlock = block.getRelative(direction);
headBlock.setType(type);
GlowBed headBlockState = (GlowBed) headBlock.getState();
headBlockState.setColor(DyeColor.getByWoolData(holding.getData().getData()));
MaterialData data = headBlockState.getData();
((Bed) data).setHeadOfBed(true);
((Bed) data).setFacingDirection(direction);
headBlockState.setData(data);
headBlockState.update(true);
}