NoClip system now uses Terraria's Collision class, much better so far. Last position reverting fixed. Fully tested, only 1% false positives.

This commit is contained in:
Zidonuke 2011-12-29 00:03:03 -05:00
parent 5600931237
commit 8523df9308
2 changed files with 2 additions and 25 deletions

View file

@ -764,15 +764,11 @@ namespace TShockAPI
return true;
}
if(!args.Player.Group.HasPermission(Permissions.ignorenoclipdetection) && TShock.CheckPlayerCollision((int)(pos.X / 16f), (int)(pos.Y / 16f)))
if (!args.Player.Group.HasPermission(Permissions.ignorenoclipdetection) && Collision.SolidCollision(pos, args.TPlayer.width, args.TPlayer.height))
{
int lastTileX = (int)(args.Player.LastNetPosition.X / 16f);
int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f);
if(args.Player.Teleport(lastTileX, lastTileY))
{
args.Player.SendMessage("You got stuck in a solid object, Sent to last good position.");
}
else
if (!args.Player.Teleport(lastTileX, lastTileY + 3))
{
args.Player.SendMessage("You got stuck in a solid object, Sent to spawn point.");
args.Player.Spawn();

View file

@ -1251,25 +1251,6 @@ namespace TShockAPI
return check;
}
public static bool CheckPlayerCollision(int x, int y)
{
if (x + 2 <= Main.maxTilesX && y <= Main.maxTilesY
&& x >= 1 && y >= 3)
{
for (int i = x - 1; i < x + 2; i++)
{
for (int h = y - 3; h < y; h++)
{
if (!Main.tile[i, h].active || !Main.tileSolid[Main.tile[i, h].type] || Main.tileSolidTop[Main.tile[i, h].type])
return false;
}
}
}
else
return false;
return true;
}
public void OnConfigRead(ConfigFile file)
{
NPC.defaultMaxSpawns = file.DefaultMaximumSpawns;