Protocol Lib - Bed packets

Discussion in 'Plugin Development' started by blaxout1213, Jun 22, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    Im using protocol lib (v3.4.0) to put players into the sleeping position. Putting them in works fine but how do i get them out? Hitting "Leave bed" Dosn't do anything.

    Any help?
  2. Offline


    wha about posting your code?
  3. Offline


    You'll need to send more packets to make them appear not sleeping. Serverside they are still not sleeping so when the player clicks leave bed im guessing the server just ignores it because serverside they aren't in a bed. So you may need to listen for the packet that is sent when the player clicks the button and then broadcast a packet to nearby players that takes the player out of the bed position.
  4. Offline



    Doesn't need to post code. I guess, blaxout1213 is just asking for a suggestion.
  5. Offline


    Go into bed mode:
    1. ProtocolManager protocolManager = plugin.protocolManager;
    2. PacketContainer useBed = protocolManager.createPacket(PacketType.Play.Server.BED);
    3. useBed.getIntegers()
    4. .write(0, player.getEntityId())
    5. .write(1, playerX)
    6. .write(2, playerY)
    7. .write(3, playerZ);
    8. try
    9. {
    10. protocolManager.broadcastServerPacket(useBed);
    11. }
    12. catch (Exception e) {
    13. throw new RuntimeException(
    14. "Cannot send packet " + useBed, e);
    15. }

    Get out: (I know im trying to send a packet the wrong way C<-S but what else am i supposed to do?)
    1. ProtocolManager protocolManager = plugin.protocolManager;
    2. PacketContainer leaveBed = protocolManager.createPacket(PacketType.Play.Client.ENTITY_ACTION);
    3. leaveBed.getIntegers()
    4. .write(0, p.getEntityId());
    5. leaveBed.getBytes()
    6. .write(0, (byte) 3);
    7. protocolManager.broadcastServerPacket(leaveBed);
  6. Offline


    read carefully name of this forum, i will copypaste it for you "Plugin Development".
    do you see anything about "suggestions"?

    look how player awaked by vanilla (at end of night) and do the same
  7. Offline


    but those involve sending packets the wrong way, and they error everytime i try that
  8. Offline


    BUMP I also need to make a player sleep in a right location
Thread Status:
Not open for further replies.

Share This Page