From eb88dc89249f9190aa40e864eebc84db5bbe7a2b Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sat, 20 Aug 2011 17:33:58 +0800 Subject: [PATCH] Basic noclip detection (high chance of false positives, only text warning atm) --- TShockAPI/TShock.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 6693aaa9..e4ae03f5 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -383,6 +383,8 @@ namespace TShockAPI player.TilesDestroyed.Clear(); } } + if (CheckPlayerCollision(player.TileX, player.TileY)) + player.SendMessage("You are currently nocliping!", Color.Red); } } } @@ -806,6 +808,19 @@ namespace TShockAPI (player.TPlayer.statLife > 400); } + public static bool CheckPlayerCollision(int x, int y) + { + for (int i = x; i < x + 2; i++) + { + for (int h = y; h < y + 4; h++) + { + if (!Main.tile[i, h].active || Main.tile[i, h].type == 2) + return false; + } + } + return true; + } + public void OnConfigRead(ConfigFile file) { NPC.defaultMaxSpawns = file.DefaultMaximumSpawns;