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:
parent
5600931237
commit
8523df9308
2 changed files with 2 additions and 25 deletions
|
|
@ -764,15 +764,11 @@ namespace TShockAPI
|
||||||
return true;
|
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 lastTileX = (int)(args.Player.LastNetPosition.X / 16f);
|
||||||
int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f);
|
int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f);
|
||||||
if(args.Player.Teleport(lastTileX, lastTileY))
|
if (!args.Player.Teleport(lastTileX, lastTileY + 3))
|
||||||
{
|
|
||||||
args.Player.SendMessage("You got stuck in a solid object, Sent to last good position.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
args.Player.SendMessage("You got stuck in a solid object, Sent to spawn point.");
|
args.Player.SendMessage("You got stuck in a solid object, Sent to spawn point.");
|
||||||
args.Player.Spawn();
|
args.Player.Spawn();
|
||||||
|
|
|
||||||
|
|
@ -1251,25 +1251,6 @@ namespace TShockAPI
|
||||||
return check;
|
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)
|
public void OnConfigRead(ConfigFile file)
|
||||||
{
|
{
|
||||||
NPC.defaultMaxSpawns = file.DefaultMaximumSpawns;
|
NPC.defaultMaxSpawns = file.DefaultMaximumSpawns;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue