diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 38d16796..fc3f27a4 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -843,8 +843,8 @@ namespace TShockAPI { if (Main.player[i].active && (Main.player[i] != args.TPlayer)) { - TShock.Players[i].Teleport(args.Player.TileX, args.Player.TileY + 3); - TShock.Players[i].SendMessage(string.Format("You were teleported to {0}.", args.Player.Name)); + if (TShock.Players[i].Teleport(args.Player.TileX, args.Player.TileY + 3)) + TShock.Players[i].SendMessage(string.Format("You were teleported to {0}.", args.Player.Name)); } } return; diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 7f955144..472a1513 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -159,7 +159,11 @@ namespace TShockAPI //150 Should avoid all client crash errors //The error occurs when a tile trys to update which the client hasnt load yet, Clients only update tiles withen 150 blocks //Try 300 if it does not work (Higher number - Longer load times - Less chance of error) - SendTileSquare(tileX, tileY, 150); + if (!SendTileSquare(tileX, tileY, 150)) + { + SendMessage("Warning, teleport failed due to being too close to the edge of the map.", Color.Red); + return false; + } if (TPlayer.SpawnX > 0 && TPlayer.SpawnY > 0) { @@ -202,11 +206,12 @@ namespace TShockAPI SendData(PacketTypes.PlayerSpawn, "", Index, 0.0f, 0.0f, 0.0f); } - public virtual void SendTileSquare(int x, int y, int size = 10) + public virtual bool SendTileSquare(int x, int y, int size = 10) { if (x + size >= Main.maxTilesX || y + size >= Main.maxTilesX) - return; + return false; SendData(PacketTypes.TileSendSquare, "", size, (float)(x - (size / 2)), (float)(y - (size / 2)), 0f); + return true; } public virtual void GiveItem(int type, string name, int width, int height, int stack)