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.
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
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.
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 playerEnterBedEvent{ Player player = event.getPlayer() Event.setCanelled(true) Player.teleport(your location) }
Yes, I know the event and it's like you say, I want them to be sleeping first.. Not teleport right away..
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.
Just throwing random ideas out, but have you though of setting their sleep tick to zero right before the teleport? org.bukkit.entity.HumanEntity.getSleepTicks() 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!
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