MoveEntityEvent crashes server when trying to teleport players

Tried using the nice way of setting coordinates to a new location and having the player’s location set to that location

Location teleportTo = new Location(world, -1015, 59, -1795);
player.setLocation(teleportTo);

And I’ve tried doing it the ugly way, with having the command manager execute the tp command to teleport the player to the coordinates

cmdManager.process(Sponge.getServer().getConsole(), “minecraft:tp " + playername + " -1015 59 -1795”);

But, every time I step on the block that is supposed to teleport me, the server crashes. So, I’m here because I have no idea why. Help?

Crash report part 1 (pastebin was crying that I exceeded maximum size of 512 kb so I had to paste it in pieces): Crash report part 1 - Pastebin.com

Crash report part 2: crash report part 2 - Pastebin.com

Crash report part 3: part 3 - Pastebin.com

4: 4 - Pastebin.com

5: 5 - Pastebin.com

^^ Sorry about that.

Thanks to anyone who takes the time to read and/or help!

You’re trying to update the player location using Player#setLocation (or a command but the result is the same) inside a MoveEntityEvent but this method calls another MoveEntityEvent and creates an infinite loop which crashes your server. You must use MoveEntityEvent#setToTransform instead of Player#setLocation. :slight_smile:

I love you. That works. Thanks! But, perhaps you could help me with one more thing. Teleporting me into the door makes me go from facing north to facing south (when I get teleported, I’m facing the opposite direction). Is there a way to fix that?

Do you want to preserve the player rotation or to specify a new one ?
The Transform object used in setToTransform supports rotations, take a look at the constructor arguments or this method : Transform#setRotation. This could help you.

I’ll take a look. Thanks for your help!