Fixed impossible placing
This commit is contained in:
parent
af3f03b38e
commit
a7e912c9f4
2 changed files with 50 additions and 46 deletions
|
|
@ -1,32 +1,30 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
public class TSPlayer
|
public class TSPlayer
|
||||||
{
|
{
|
||||||
public uint tileThreshold;
|
public uint tileThreshold;
|
||||||
public Dictionary<TShock.Position, Tile> tilesDestroyed = new Dictionary<TShock.Position, Tile>();
|
public Dictionary<TShock.Position, Tile> tilesDestroyed = new Dictionary<TShock.Position, Tile>();
|
||||||
public bool syncHP;
|
public bool syncHP;
|
||||||
public bool syncMP;
|
public bool syncMP;
|
||||||
public Group group;
|
public Group group;
|
||||||
public int lavaCount = 0;
|
private int player;
|
||||||
public int waterCount = 0;
|
|
||||||
private int player;
|
public TSPlayer(int ply)
|
||||||
|
{
|
||||||
public TSPlayer(int ply)
|
player = ply;
|
||||||
{
|
}
|
||||||
player = ply;
|
|
||||||
}
|
public Player GetPlayer()
|
||||||
|
{
|
||||||
public Player GetPlayer()
|
return Main.player[player];
|
||||||
{
|
}
|
||||||
return Main.player[player];
|
|
||||||
}
|
public int GetPlayerID()
|
||||||
|
{
|
||||||
public int GetPlayerID()
|
return player;
|
||||||
{
|
}
|
||||||
return player;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -209,15 +209,15 @@ namespace TShockAPI
|
||||||
byte typetile = br.ReadByte();
|
byte typetile = br.ReadByte();
|
||||||
if (type == 1 || type == 3)
|
if (type == 1 || type == 3)
|
||||||
{
|
{
|
||||||
int plyX = Math.Abs((int) Main.player[e.Msg.whoAmI].position.X/16);
|
int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X / 16);
|
||||||
int plyY = Math.Abs((int) Main.player[e.Msg.whoAmI].position.Y/16);
|
int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y / 16);
|
||||||
int tileX = Math.Abs(x/16);
|
int tileX = Math.Abs(x / 16);
|
||||||
int tileY = Math.Abs(y/16);
|
int tileY = Math.Abs(y / 16);
|
||||||
|
|
||||||
if ((plyX - tileX > 6) || (plyY - tileY > 6))
|
if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6))
|
||||||
TShock.Ban(e.Msg.whoAmI, "Placing impossible to place blocks.");
|
TShock.Ban(e.Msg.whoAmI, "Placing impossible to place blocks.");
|
||||||
Tools.Broadcast(Main.player[e.Msg.whoAmI].name + " was banned for placing impossible to place blocks.");
|
Tools.Broadcast(Main.player[e.Msg.whoAmI].name + " was banned for placing impossible to place blocks.");
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
if (type == 0 || type == 1)
|
if (type == 0 || type == 1)
|
||||||
|
|
||||||
|
|
@ -420,33 +420,39 @@ namespace TShockAPI
|
||||||
byte liquid = br.ReadByte();
|
byte liquid = br.ReadByte();
|
||||||
bool lava = br.ReadBoolean();
|
bool lava = br.ReadBoolean();
|
||||||
|
|
||||||
int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X/16);
|
int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X / 16);
|
||||||
int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y/16);
|
int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y / 16);
|
||||||
int tileX = Math.Abs(x);
|
int tileX = Math.Abs(x);
|
||||||
int tileY = Math.Abs(y);
|
int tileY = Math.Abs(y);
|
||||||
|
|
||||||
|
int lavacount = 0;
|
||||||
|
int watercount = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 44; i++)
|
for (int i = 0; i < 44; i++)
|
||||||
{
|
{
|
||||||
if (Main.player[e.Msg.whoAmI].inventory[i].name == "Lava Bucket")
|
if (Main.player[e.Msg.whoAmI].inventory[i].name == "Lava Bucket")
|
||||||
TShock.players[e.Msg.whoAmI].lavaCount++;
|
lavacount++;
|
||||||
else if (Main.player[e.Msg.whoAmI].inventory[i].name == "Water Bucket")
|
else if (Main.player[e.Msg.whoAmI].inventory[i].name == "Water Bucket")
|
||||||
TShock.players[e.Msg.whoAmI].waterCount++;
|
watercount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lava && TShock.players[e.Msg.whoAmI].lavaCount <= 0)
|
if (lava && lavacount <= 0)
|
||||||
{
|
{
|
||||||
TShock.Ban(e.Msg.whoAmI, "Placing lava they didn't have.");
|
TShock.Ban(e.Msg.whoAmI, "Placing lava they didn't have.");
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
else if (!lava && TShock.players[e.Msg.whoAmI].waterCount <= 0)
|
else if (!lava && watercount <= 0)
|
||||||
{
|
{
|
||||||
TShock.Ban(e.Msg.whoAmI, "Placing water they didn't have.");
|
TShock.Ban(e.Msg.whoAmI, "Placing water they didn't have.");
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
if ((plyX - tileX > 6) || (plyY - tileY > 6))
|
if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6))
|
||||||
|
{
|
||||||
TShock.Ban(e.Msg.whoAmI, "Placing impossible to place liquid.");
|
TShock.Ban(e.Msg.whoAmI, "Placing impossible to place liquid.");
|
||||||
Tools.Broadcast(Main.player[e.Msg.whoAmI].name + " was banned for placing impossible to place liquid.");
|
Tools.Broadcast(Main.player[e.Msg.whoAmI].name +
|
||||||
|
" was banned for placing impossible to place liquid.");
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (ConfigurationManager.spawnProtect)
|
if (ConfigurationManager.spawnProtect)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue