diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 2dfb1736..dff860db 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -412,11 +412,18 @@ namespace TShockAPI public static void Teleport(int ply, int x, int y) { - Main.player[ply].position.X = x; - Main.player[ply].position.Y = y; - NetMessage.SendData(0x0d, -1, ply, "", ply); - NetMessage.SendData(0x0d, -1, -1, "", ply); - NetMessage.syncPlayers(); + int oldSpawnX = Main.spawnTileX; + int oldSpawnY = Main.spawnTileY; + Main.spawnTileX = x; + Main.spawnTileY = y; + //Send only that player the new spawn point data + NetMessage.SendData(7, ply, -1, "", 0, 0f, 0f, 0f); + //Force them to respawn + NetMessage.SendData(12, ply, -1, "", ply, 0.0f, 0.0f, 0.0f); + //Reset to old spawnpoint and send spawn data back to player + Main.spawnTileX = (int)oldSpawnX; + Main.spawnTileY = (int)oldSpawnY; + NetMessage.SendData(7, ply, -1, "", 0, 0f, 0f, 0f); } public static void Teleport(int ply, float x, float y)