Look the Forge's source code. In BedBlock, minecrafts uses PlayerEntity#displayClientMessage to display sleep result (which can be success or failure, so "You can only sleep at night"). Just give an ITextComponent (StringTextComponent or TranslationTextComponent in most cases) and set the second boolean to true to send an state text instead of sending it to the chat.
So:
PlayerEntity player = //Get player here
player.displayClientMessage(new StringTextComponent(""), true);
I havn't check that, but it should be somthing like that