mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
Replaced broken reach check, continued work on movement check update
This commit is contained in:
1 parent
636f94b408
commit
20635a2acb
15 files changed
+295
-203
No files matched your search
@@ -29,20 +29,37 @@ public class MovementManager {
|
||||
public int groundTicks = 0;
|
||||
// Ticks on ice
|
||||
public int iceTicks = 0;
|
||||
// Ticks on slime
|
||||
public int slimeTicks = 0;
|
||||
// Ticks in air before last grounded moment
|
||||
public int airTicksBeforeGrounded = 0;
|
||||
// Ticks influenced by ice
|
||||
public int iceInfluenceTicks = 0;
|
||||
// Ticks influenced by slime
|
||||
public int slimeInfluenceTicks = 0;
|
||||
// Ticks influenced by sign
|
||||
public int signInfluenceTicks = 0;
|
||||
// Last Y motion
|
||||
public double motionY;
|
||||
// If the player touched the ground again this tick
|
||||
public boolean touchedGroundThisTick = false;
|
||||
// Last recorded distance
|
||||
public Distance lastDistance = new Distance();
|
||||
// Movement acceleration
|
||||
public double acceleration;
|
||||
// Is the block above solid
|
||||
public boolean topSolid;
|
||||
// Is the block below solid
|
||||
public boolean bottomSolid;
|
||||
// If the current movement is up a slab or stair
|
||||
public boolean halfMovement;
|
||||
// Ticks counter for last halfMovement
|
||||
public int halfMovementHistoryCounter = 0;
|
||||
|
||||
public void handle(Player player, Location from, Location to, Distance distance) {
|
||||
boolean serverOnGround = !Utilities.cantStandAtExp(to) || Utilities.couldBeOnBoat(player);
|
||||
this.touchedGroundThisTick = false;
|
||||
this.halfMovement = false;
|
||||
if (!serverOnGround) {
|
||||
this.groundTicks = 0;
|
||||
this.airTicks++;
|
||||
@@ -53,21 +70,53 @@ public class MovementManager {
|
||||
this.airTicks = 0;
|
||||
this.groundTicks++;
|
||||
}
|
||||
|
||||
if (to.getBlock().getType().name().endsWith("SIGN") || to.getBlock().getType().name().endsWith("POST")
|
||||
|| from.getBlock().getType().name().endsWith("SIGN")
|
||||
|| from.getBlock().getType().name().endsWith("POST"))
|
||||
this.signInfluenceTicks = 3;
|
||||
else
|
||||
if (this.signInfluenceTicks > 0)
|
||||
this.signInfluenceTicks--;
|
||||
|
||||
if (Utilities.couldBeOnIce(to)) {
|
||||
this.iceTicks++;
|
||||
this.iceInfluenceTicks = 14;
|
||||
this.iceInfluenceTicks = 60;
|
||||
} else {
|
||||
this.iceTicks = 0;
|
||||
if (this.iceInfluenceTicks > 0)
|
||||
this.iceInfluenceTicks--;
|
||||
}
|
||||
|
||||
if (Utilities.couldBeOnSlime(to)) {
|
||||
this.slimeTicks++;
|
||||
this.slimeInfluenceTicks = 40;
|
||||
} else {
|
||||
this.slimeTicks = 0;
|
||||
if (this.slimeInfluenceTicks > 0)
|
||||
this.slimeInfluenceTicks--;
|
||||
}
|
||||
|
||||
double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
|
||||
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
|
||||
double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference()
|
||||
+ distance.getZDifference() * distance.getZDifference());
|
||||
this.acceleration = currentDistanceSq - lastDistanceSq;
|
||||
|
||||
this.motionY = to.getY() - from.getY();
|
||||
|
||||
Location top = to.clone().add(0, 2, 0);
|
||||
this.topSolid = top.getBlock().getType().isSolid();
|
||||
Location bottom = to.clone().add(0, -1, 0);
|
||||
this.bottomSolid = bottom.getBlock().getType().isSolid();
|
||||
|
||||
if ((this.motionY > 0.464D && this.motionY <= 0.5625D) && (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) {
|
||||
this.halfMovement = true;
|
||||
this.halfMovementHistoryCounter = 30;
|
||||
} else {
|
||||
if (this.halfMovementHistoryCounter > 0)
|
||||
this.halfMovementHistoryCounter--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public enum Permission {
|
||||
/* Check Nodes */
|
||||
CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
|
||||
CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
|
||||
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_LONGREACH, CHECK_UNICODE,
|
||||
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_UNICODE,
|
||||
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER, CHECK_AIMBOT,
|
||||
|
||||
/* System Nodes */
|
||||
|
||||
@@ -113,10 +113,6 @@ public final class Utilities {
|
||||
public static boolean canStand(Block block) {
|
||||
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||
}
|
||||
|
||||
public static boolean isSlime(Block block) {
|
||||
return block.getType() == Material.SLIME_BLOCK;
|
||||
}
|
||||
|
||||
public static boolean isNotNearSlime(Block block) {
|
||||
return !isSlime(block.getRelative(BlockFace.NORTH)) && !isSlime(block.getRelative(BlockFace.EAST))
|
||||
@@ -124,7 +120,7 @@ public final class Utilities {
|
||||
}
|
||||
|
||||
public static boolean couldBeOnBoat(Player player) {
|
||||
for (Entity entity : player.getNearbyEntities(0.25, 0.25, 0.25)) {
|
||||
for (Entity entity : player.getNearbyEntities(0.3, 0.3, 0.3)) {
|
||||
if (entity instanceof Boat)
|
||||
return true;
|
||||
}
|
||||
@@ -161,11 +157,76 @@ public final class Utilities {
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.WEST))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a player could be standing on a halfblock
|
||||
*
|
||||
* @param location the location to check
|
||||
* @return true if the player could be standing on a halfblock
|
||||
*/
|
||||
public static boolean couldBeOnHalfblock(Location location) {
|
||||
return isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D,
|
||||
location.getBlockZ())) || isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D,
|
||||
location.getBlockZ()));
|
||||
}
|
||||
|
||||
public static boolean isNearHalfblock(Location location) {
|
||||
return isHalfblock(location.getBlock())
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.WEST))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
public static boolean isHalfblock(Block block) {
|
||||
return isSlab(block) || isStair(block);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a player could be standing on slime
|
||||
*
|
||||
* @param location the location to check
|
||||
* @return true if the player could be standing on slime
|
||||
*/
|
||||
public static boolean couldBeOnSlime(Location location) {
|
||||
return isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
|
||||
location.getBlockZ())) || isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D,
|
||||
location.getBlockZ()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a block is a type of slime
|
||||
*
|
||||
* @param block block to check
|
||||
* @return true if block is a type of slime
|
||||
*/
|
||||
public static boolean isSlime(Block block) {
|
||||
Material type = block.getType();
|
||||
return type.equals(XMaterial.SLIME_BLOCK.parseMaterial());
|
||||
}
|
||||
|
||||
public static boolean isNearSlime(Location location) {
|
||||
return isSlime(location.getBlock())
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.WEST))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a player is fully submerged in water
|
||||
*
|
||||
@@ -411,7 +472,7 @@ public final class Utilities {
|
||||
* @return true if on vine
|
||||
*/
|
||||
public static boolean isOnVine(Player player) {
|
||||
return player.getLocation().getBlock().getType() == Material.VINE;
|
||||
return player.getLocation().getBlock().getType() == XMaterial.VINE.parseMaterial();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,7 +514,7 @@ public final class Utilities {
|
||||
* @return time in milliseconds to break
|
||||
*/
|
||||
public static long calcSurvivalFastBreak(ItemStack tool, Material block) {
|
||||
if (isInstantBreak(block) || (tool.getType() == Material.SHEARS && block.name().endsWith("LEAVES"))) {
|
||||
if (isInstantBreak(block) || (tool.getType() == XMaterial.SHEARS.parseMaterial() && block.name().endsWith("LEAVES"))) {
|
||||
return 0;
|
||||
}
|
||||
double bhardness = BlockHardness.getBlockHardness(block);
|
||||
@@ -668,7 +729,7 @@ public final class Utilities {
|
||||
if (!VersionUtil.isOfVersion("v1_15")) {
|
||||
return false;
|
||||
}
|
||||
return block.getType() == Material.HONEY_BLOCK;
|
||||
return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial();
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
Reference in new issue
Block a user