mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 22:15:28 +00:00
Second day of Chest Visuals. Committing everything so far. WARNING: Blocks will be randomly spawning when you interact. This is debugging purposes.
This commit is contained in:
1 parent
6fa61cb254
commit
1b8d3c5e50
1 file changed
+240
-101
@@ -280,120 +280,259 @@ public class Backend
|
|||||||
|
|
||||||
String direction = Utilities.getCardinalDirection(player);
|
String direction = Utilities.getCardinalDirection(player);
|
||||||
|
|
||||||
|
/* TODO: Redo top/bottom/left/right block check, this one exposes an exploit */
|
||||||
|
|
||||||
|
/*// make sure user isn't just on top/bottom/left/right of block.
|
||||||
|
Location pl = new Location(block.getWorld(), px,py-1,pz);
|
||||||
|
Location pl2 = new Location(block.getWorld(), px,py+1,pz);
|
||||||
|
if(pl.getBlock().getType() == block.getType() && pl.distance(player.getLocation()) <= 1D || pl2.getBlock().getType() == block.getType())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
|
||||||
if(direction != null)
|
if(direction != null)
|
||||||
{
|
{
|
||||||
if(direction.equals("N") || direction.equals("NE"))
|
for(int g = 0; g < 2; g++)
|
||||||
{
|
{
|
||||||
if(x > 0)
|
py = py+g;
|
||||||
{
|
|
||||||
for(int a = 0; a < x + 1; a++)
|
|
||||||
{
|
|
||||||
Location coords = new Location(player.getWorld(), px-a,py,pz);
|
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
|
||||||
{
|
|
||||||
strikes++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(z > 0)
|
if(direction.equals("N") || direction.equals("NE"))
|
||||||
{
|
{
|
||||||
for(int a = 0; a < z + 1; a++)
|
if(x > 0)
|
||||||
{
|
{
|
||||||
Location coords = new Location(player.getWorld(), px,py,pz-a);
|
boolean ignoreothers = false;
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
for(int a = 0; a < x + 1; a++)
|
||||||
{
|
{
|
||||||
strikes++;
|
Location coords = new Location(player.getWorld(), px-a,py,pz);
|
||||||
}
|
if(coords.getBlock().getTypeId() == block.getTypeId() && coords.distance(block.getLocation()) < 3D)
|
||||||
}
|
{
|
||||||
}
|
ignoreothers = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(direction.equals("E") || direction.equals("SE"))
|
// Don't detect farther than we should be allowed to.
|
||||||
{
|
if(coords.getX() < block.getLocation().getX())
|
||||||
if(x > 0)
|
{
|
||||||
{
|
ignoreothers = true;
|
||||||
for(int a = 0; a < x + 1; a++)
|
player.sendBlockChange(coords, 66, (byte) 0);
|
||||||
{
|
}
|
||||||
Location coords = new Location(player.getWorld(), px+a,py,pz);
|
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
|
||||||
{
|
|
||||||
strikes++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(z > 0)
|
if(block.getLocation().distance(coords) > 5D)
|
||||||
{
|
{
|
||||||
for(int a = 0; a < z + 1; a++)
|
continue;
|
||||||
{
|
}
|
||||||
Location coords = new Location(player.getWorld(), px,py,pz-a);
|
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
|
||||||
{
|
|
||||||
strikes++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(direction.equals("S") || direction.equals("SW") || direction.equals("W"))
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
{
|
{
|
||||||
if(x > 0)
|
player.sendMessage("Block detected at -X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
{
|
player.sendBlockChange(coords, 46, (byte) 0);
|
||||||
for(int a = 0; a < x + 1; a++)
|
strikes++;
|
||||||
{
|
} else {
|
||||||
Location coords = new Location(player.getWorld(), px+a,py,pz);
|
player.sendBlockChange(coords, 56, (byte) 0);
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
}
|
||||||
{
|
}
|
||||||
strikes++;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(z > 0)
|
if(z > 0)
|
||||||
{
|
{
|
||||||
for(int a = 0; a < z + 1; a++)
|
boolean ignoreothers = false;
|
||||||
{
|
for(int a = 0; a < z + 1; a++)
|
||||||
Location coords = new Location(player.getWorld(), px,py,pz+a);
|
{
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
Location coords = new Location(player.getWorld(), px,py,pz-a);
|
||||||
{
|
if(coords.getBlock().getTypeId() == block.getTypeId() && coords.distance(block.getLocation()) < 3D)
|
||||||
strikes++;
|
{
|
||||||
}
|
ignoreothers = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(direction.equals("NW"))
|
if(block.getLocation().distance(coords) > 5D) {
|
||||||
{
|
continue;
|
||||||
if(x > 0)
|
}
|
||||||
{
|
|
||||||
for(int a = 0; a < x + 1; a++)
|
|
||||||
{
|
|
||||||
Location coords = new Location(player.getWorld(), px-a,py,pz);
|
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
|
||||||
{
|
|
||||||
strikes++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(z > 0)
|
// Don't detect farther than we should be allowed to.
|
||||||
{
|
if(coords.getZ() < block.getLocation().getZ())
|
||||||
for(int a = 0; a < z + 1; a++)
|
{
|
||||||
{
|
ignoreothers = true;
|
||||||
Location coords = new Location(player.getWorld(), px,py,pz+a);
|
player.sendBlockChange(coords, 66, (byte) 0);
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
}
|
||||||
{
|
|
||||||
strikes++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
|
{
|
||||||
|
player.sendMessage("Block detected at -Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
|
player.sendBlockChange(coords, 46, (byte) 0);
|
||||||
|
strikes++;
|
||||||
|
} else {
|
||||||
|
player.sendBlockChange(coords, 57, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction.equals("E") || direction.equals("SE"))
|
||||||
|
{
|
||||||
|
if(x > 0)
|
||||||
|
{
|
||||||
|
boolean ignoreothers = false;
|
||||||
|
for(int a = 0; a < x + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px+a,py,pz);
|
||||||
|
if(coords.getBlock().getTypeId() == block.getTypeId() && coords.distance(block.getLocation()) < 3D)
|
||||||
|
{
|
||||||
|
ignoreothers = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(block.getLocation().distance(coords) > 5D) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't detect farther than we should be allowed to.
|
||||||
|
if(coords.getX() < block.getLocation().getX())
|
||||||
|
{
|
||||||
|
ignoreothers = true;
|
||||||
|
player.sendBlockChange(coords, 66, (byte) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
|
{
|
||||||
|
player.sendMessage("Block detected at +X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
|
player.sendBlockChange(coords, 46, (byte) 0);
|
||||||
|
strikes++;
|
||||||
|
} else {
|
||||||
|
player.sendBlockChange(coords, 35, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(z > 0)
|
||||||
|
{
|
||||||
|
boolean ignoreothers = false;
|
||||||
|
for(int a = 0; a < z + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px,py,pz-a);
|
||||||
|
if(coords.getBlock().getTypeId() == block.getTypeId() && coords.distance(block.getLocation()) < 4D)
|
||||||
|
{
|
||||||
|
ignoreothers = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(block.getLocation().distance(coords) > 5D) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't detect farther than we should be allowed to.
|
||||||
|
if(coords.getZ() < block.getLocation().getZ())
|
||||||
|
{
|
||||||
|
ignoreothers = true;
|
||||||
|
player.sendBlockChange(coords, 66, (byte) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
|
{
|
||||||
|
player.sendMessage("Block detected at -Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
|
player.sendBlockChange(coords, 46, (byte) 0);
|
||||||
|
strikes++;
|
||||||
|
} else {
|
||||||
|
player.sendBlockChange(coords, 57, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction.equals("S") || direction.equals("SW") || direction.equals("W"))
|
||||||
|
{
|
||||||
|
if(x > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < x + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px+a,py,pz);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
player.sendMessage("Block detected at +X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
|
player.sendBlockChange(coords, 46, (byte) 0);
|
||||||
|
strikes++;
|
||||||
|
} else {
|
||||||
|
player.sendBlockChange(coords, 35, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(z > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < z + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px,py,pz+a);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
player.sendMessage("Block detected at +Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
|
player.sendBlockChange(coords, 46, (byte) 0);
|
||||||
|
strikes++;
|
||||||
|
} else {
|
||||||
|
player.sendBlockChange(coords, 1, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction.equals("NW"))
|
||||||
|
{
|
||||||
|
if(x > 0)
|
||||||
|
{
|
||||||
|
boolean ignoreothers = false;
|
||||||
|
for(int a = 0; a < x + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px-a,py,pz);
|
||||||
|
if(coords.getBlock().getTypeId() == block.getTypeId() && coords.distance(block.getLocation()) < 3D)
|
||||||
|
{
|
||||||
|
ignoreothers = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(block.getLocation().distance(coords) > 5D) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
|
{
|
||||||
|
player.sendMessage("Block detected at -X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
|
player.sendBlockChange(coords, 46, (byte) 0);
|
||||||
|
strikes++;
|
||||||
|
} else {
|
||||||
|
player.sendBlockChange(coords, 56, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(z > 0)
|
||||||
|
{
|
||||||
|
boolean ignoreothers = false;
|
||||||
|
for(int a = 0; a < z + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px,py,pz+a);
|
||||||
|
if(coords.getBlock().getTypeId() == block.getTypeId() && coords.distance(block.getLocation()) < 3D)
|
||||||
|
{
|
||||||
|
ignoreothers = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(block.getLocation().distance(coords) > 5D) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
|
{
|
||||||
|
player.sendMessage("Block detected at +Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
|
player.sendBlockChange(coords, 46, (byte) 0);
|
||||||
|
strikes++;
|
||||||
|
} else {
|
||||||
|
player.sendBlockChange(coords, 1, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strikes > 0;
|
player.sendMessage("Strikes: " + strikes + " Dir: " + direction);
|
||||||
|
player.sendMessage("X: " + x + " Y: " + y + " Z:" + z);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkWaterWalk(Player player, double x, double z)
|
public boolean checkWaterWalk(Player player, double x, double z)
|
||||||
|
|||||||
Reference in new issue
Block a user