From 74035d5c1ef08279340cf38ed2540203fabe51c8 Mon Sep 17 00:00:00 2001 From: k0rd Date: Mon, 30 Jan 2012 04:05:55 -0500 Subject: [PATCH] sand, silt, pearlsand, and ebonsand shouldn't trigger noclip detection --- TShockAPI/GetDataHandlers.cs | 44 ++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 9935c96c..279ab251 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -412,7 +412,47 @@ namespace TShockAPI PlayerUpdate.Invoke(null, args); return args.Handled; } - + public static bool TSCheckNoclip(Vector2 Position, int Width, int Height) + { + int num = (int)(Position.X / 16f) - 1; + int num2 = (int)((Position.X + (float)Width) / 16f) + 2; + int num3 = (int)(Position.Y / 16f) - 1; + int num4 = (int)((Position.Y + (float)Height) / 16f) + 2; + if (num < 0) + { + num = 0; + } + if (num2 > Main.maxTilesX) + { + num2 = Main.maxTilesX; + } + if (num3 < 0) + { + num3 = 0; + } + if (num4 > Main.maxTilesY) + { + num4 = Main.maxTilesY; + } + for (int i = num; i < num2; i++) + { + for (int j = num3; j < num4; j++) + { + if (Main.tile[i, j] != null && Main.tile[i, j].active && Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type] &&(((int)Main.tile[i,j].type !=53) && ((int)Main.tile[i,j].type !=112) && ((int)Main.tile[i,j].type !=116) && ((int)Main.tile[i,j].type !=123))) + { + Vector2 vector; + vector.X = (float)(i * 16); + vector.Y = (float)(j * 16); + if (Position.X + (float)Width > vector.X && Position.X < vector.X + 16f && Position.Y + (float)Height > vector.Y && Position.Y < vector.Y + 16f) + { + return true; + } + } + } + } + return false; + } + /// /// For use in a SendTileSquare event /// @@ -1801,7 +1841,7 @@ namespace TShockAPI } if (!args.Player.Group.HasPermission(Permissions.ignorenoclipdetection) && - Collision.SolidCollision(pos, args.TPlayer.width, args.TPlayer.height) && !TShock.Config.IgnoreNoClip) + TSCheckNoclip(pos, args.TPlayer.width, args.TPlayer.height) && !TShock.Config.IgnoreNoClip) { int lastTileX = (int) (args.Player.LastNetPosition.X/16f); int lastTileY = (int) (args.Player.LastNetPosition.Y/16f);