Solved Make a player lay down

Discussion in 'Plugin Development' started by CaptainBern, Feb 14, 2013.

Thread Status:
Not open for further replies.
  1. Hello! I'm currently making a plugin and I need to make a player lay down like when he is in a bed, but without the bed. I know ill probably have to use nms code but i have no idea on how to start on this...thanks for reading my post!
  2. Offline


    My guess is that you would need to mess around with packets. I would suggest looking at the source of Comfort, as it does something similar to what you want to accomplish, and may point you in the right direction.
    CaptainBern likes this.
  3. yeah i know comfort but isnt that just used to make a player look like he is sitting down?anyway thanks for your help!
  4. Offline


    I was just suggesting taking a look at the source code to give you an idea of what to do. I imagine that making a player look like they're sitting down is similar to what you want to do code-wise.
  5. yes but comfort uses a packet that let you mount an item, but in the source code(the code u gave me) i found this:
    2. public void layDown(Player player, Block block) {
    3. player.setAllowFlight(true);
    4. player.setFlying(true);
    5. player.teleport(block.getLocation().add(0.5, 0.5, 0.5));
    7. EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
    8. Packet17EntityLocationAction packet = new Packet17EntityLocationAction(entityPlayer, 0, block.getX(), block.getY(), block.getZ());
    10. for(Player p : getServer().getOnlinePlayers())
    11. ((CraftPlayer)p).getHandle().netServerHandler.sendPacket(packet);
    13. Packet70Bed packet = new Packet70Bed(player.getEntityId(), 78);
    15. for(Player p : getServer().getOnlinePlayers())
    16. ((CraftPlayer)p).getHandle().netServerHandler.sendPacket(packet);
    18. comfortPlayers.put(player, block);
    19. }

    solved thanks to AngryNerd !

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 31, 2016
  6. Offline


    I should think that Craftbukkit also includes a packet to make a player appear as though they are sleeping.
Thread Status:
Not open for further replies.

Share This Page