[Solved]Teleporting a sleeping player.

Discussion in 'Plugin Development' started by Neodork, May 15, 2012.

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


    Hello there!

    I tried to teleport a sleeping player on several ways, he keeps teleporting next to the bed. I figured maybe some of you have already experienced this and care to share their knowledge with me... No errors are thrown, it just won't teleport to the right co-ordinates. Instead he teleports "sleeping" next to the bed while standing straight.

    Please feel free to share any information regarding this problem.

    Grtz Neodork.
  2. Offline


    Would using ecject do anything when a player is in the bed?

  3. Offline


    Checking this out.

    Edit: nope.. That's passenger related..
  4. Offline


    Did you creating bed-teleport plugin? Oh!!! I think it great idea, please don't forget to publish it at bukkit-dev, when it will done :)
  5. Offline


    Cancel the sleeping event, then teleport. Also note if the player is a passenger of a vehicle you CAN NOT teleport or you'll be glitches into blackness. Came across that while trying to teleport to the nether inside a minecart... Did not go over well.
  6. Offline


    Looking for that, maybe you can give me a example how to cancel it ?
  7. Offline


    Only thing I could find was the player enter bed event. Do you want them to teleport as soon as they enter the bed?

    Some psuedo

    Player player = event.getPlayer()
    Player.teleport(your location)
  8. Offline


    Yes, I know the event and it's like you say, I want them to be sleeping first.. Not teleport right away..
  9. Offline


    Teleport the vehicle and the player?
  10. Offline


    Try this: ((CraftPlayer) player).getHandle().a(true, false, false); It should make the player leave the bed. I have tried this and I am guessing a bit. Tell me if it works. ;)
    Neodork likes this.
  11. Offline

    Father Of Time

    Just throwing random ideas out, but have you though of setting their sleep tick to zero right before the teleport?


    Or if not, instead of using the enter bed event, why not use the leaving bed event? So the player gets in, they sleep for a bit, then when they naturally get out they will be teleported to their destination as appose to just simply stepping out to the side of the bed. Just make sure to put a scheduler delay for one game tick so that you do the teleport on the next game tick, not on the event itself; I say this because if you do it when the event occurs the player is still technically "sleeping" because the event occurs BEFORE he gets out of bed, not after. If you put the teleport on a 1 tick delay it will occur after the sleep wake event, meaning the player will be out of bed, standing and ready to teleport, but because it occurs 1 game tick later the timing is practically instant to the human eye.

    No idea if any of these suggestions will work, but figured I would provide you with a few alternative methods just in case. Good luck with your project!
    Neodork likes this.
  12. Offline


    I will try this. And check if I can get the player out of bed with it before I teleport them.

    And if it won't work I think this:

    is a quite nice idea. I can work something out with it.

    Edit: The first one work perfectly, thanks! And I can use the second one to make a new type of teleportation, a bedleave related one. +1 to both
  13. Offline

    Father Of Time

    I am happy to hear you resolved your issue, good luck with the remainder of your project! :D
Thread Status:
Not open for further replies.

Share This Page