mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Visuals Check is now bulletproof. Will work on any block interaction. Also improved location checks for visuals.
This commit is contained in:
1 parent
bb7b43afdb
commit
659d73752c
2 files changed
+17
-16
No files matched your search
@@ -157,6 +157,7 @@ public class PlayerListener extends EventListener
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Block playerClick = player.getTargetBlock(null, 5);
|
||||
PlayerInventory inv = player.getInventory();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
@@ -181,9 +182,9 @@ public class PlayerListener extends EventListener
|
||||
Block block = event.getClickedBlock();
|
||||
if(block != null)
|
||||
{
|
||||
if(checkManager.willCheck(player, CheckType.VISUAL) && Utilities.isInteractable(block.getType()))
|
||||
if(checkManager.willCheck(player, CheckType.VISUAL))
|
||||
{
|
||||
if(backend.checkInteraction(player, block))
|
||||
if(backend.checkInteraction(player, block, playerClick))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to interact with an object that they couldn't see", player, CheckType.VISUAL); //boring description though.
|
||||
|
||||
@@ -58,6 +58,8 @@ public class Backend
|
||||
private static final int FASTPLACE_MAXVIOLATIONS = 2;
|
||||
private static final int FASTPLACE_MAXVIOLATIONS_CREATIVE = 3;
|
||||
private static final int FASTPLACE_MAXVIOLATIONTIME = 10000;
|
||||
|
||||
private static final double VISUALS_MAXOFFSET = 2;
|
||||
|
||||
private static final int BLOCK_PUNCH_MIN = 5;
|
||||
|
||||
@@ -272,23 +274,21 @@ public class Backend
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkInteraction(Player player, Block block)
|
||||
public boolean checkInteraction(Player player, Block targetBlock, Block playerClick)
|
||||
{
|
||||
int strikes = 0;
|
||||
|
||||
// First Line of Defense
|
||||
Block imple = player.getTargetBlock(null, 5);
|
||||
if(imple.getTypeId() != block.getTypeId())
|
||||
{
|
||||
strikes++;
|
||||
}
|
||||
double x = targetBlock.getX() - playerClick.getX() * ((targetBlock.getX() - playerClick.getX() * 1) < 0 ? -1 : 1);
|
||||
double y = targetBlock.getY() - playerClick.getY() * ((targetBlock.getY() - playerClick.getY() * 1) < 0 ? -1 : 1);
|
||||
double z = targetBlock.getZ() - playerClick.getZ() * ((targetBlock.getZ() - playerClick.getZ() * 1) < 0 ? -1 : 1);
|
||||
|
||||
player.sendMessage("X: " + x + " Y: " + y + " Z: " + z);
|
||||
|
||||
if (x >= VISUALS_MAXOFFSET) strikes++;
|
||||
if (y >= VISUALS_MAXOFFSET) strikes++;
|
||||
if (z >= VISUALS_MAXOFFSET) strikes++;
|
||||
|
||||
|
||||
// Second line of defense.
|
||||
if(!imple.getLocation().equals(block.getLocation()))
|
||||
{
|
||||
strikes++;
|
||||
}
|
||||
|
||||
return strikes > 0;
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ public class Backend
|
||||
{
|
||||
logEvent(healed, player, HEAL_MIN);
|
||||
}
|
||||
|
||||
|
||||
public boolean justHealed(Player player)
|
||||
{
|
||||
return healed.contains(player.getName());
|
||||
|
||||
Reference in new issue
Block a user