Skip to content

Commit

Permalink
incognito making me work on this
Browse files Browse the repository at this point in the history
  • Loading branch information
Tecnio committed Feb 17, 2024
1 parent 88f813e commit bbcff96
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 104 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/me/tecnio/ahm/check/impl/flight/FlightD.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public void handle(final PositionUpdate update) {

final boolean exempt = this.isExempt(ExemptType.VEHICLE, ExemptType.VELOCITY, ExemptType.PISTON,
ExemptType.CLIMBABLE, ExemptType.TELEPORT, ExemptType.BOAT, ExemptType.TELEPORTED_RECENTLY,
ExemptType.UNDER_BLOCK, ExemptType.WEB, ExemptType.FLIGHT, ExemptType.SLIME, ExemptType.CHUNK, ExemptType.LIQUID);
ExemptType.UNDER_BLOCK, ExemptType.WEB, ExemptType.FLIGHT, ExemptType.SLIME, ExemptType.CHUNK,
ExemptType.LIQUID, ExemptType.JOIN);

final boolean startedFalling = deltaY <= 0.2 && !ground;

Expand Down
199 changes: 98 additions & 101 deletions src/main/java/me/tecnio/ahm/data/tracker/impl/EmulationTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,112 +33,109 @@ public void handle(final GPacket packet) {
// Set the lowest offset
this.distance = Double.MAX_VALUE;

iteration:
{
iteration: {
// Loop through the combos
for (int f = -1; f < 2; f++) {
for (int s = -1; s < 2; s++) {
for (int sp = 0; sp < 2; sp++) {
for (int jp = 0; jp < 2; jp++) {
for (int vl = 0; vl < 2; vl++) {
for (int ui = 0; ui < 2; ui++) {
for (int hs = 0; hs < 2; hs++) {
for (int fm = 0; fm < 2; fm++) {
final boolean sprint = sp == 0;
final boolean jump = jp == 0;
final boolean using = ui == 0;
final boolean hitSlowdown = hs == 0;
final boolean fastMath = fm == 1;
final boolean ground = data.getPositionTracker().isLastOnGround();
final boolean sneaking = data.getActionTracker().isSneaking();
final boolean velocity = vl == 0;

if (f <= 0.0F && sprint && ground) continue;

float forward = f;
float strafe = s;

if (using) {
forward *= 0.2D;
strafe *= 0.2D;
}

if (sneaking) {
forward *= (float) 0.3D;
strafe *= (float) 0.3D;
}

forward *= 0.98F;
strafe *= 0.98F;

final Motion motion = new Motion(
data.getPositionTracker().getLastDeltaX(),
0.0D,
data.getPositionTracker().getLastDeltaZ());

if (data.getPositionTracker().isLastLastOnGround()) {
motion.getX().multiply(0.6F * 0.91F);
motion.getZ().multiply(0.6F * 0.91F);
} else {
motion.getX().multiply(0.91F);
motion.getZ().multiply(0.91F);
}

if (velocity) {
data.getVelocityTracker().getActions().forEach(action -> action.accept(motion));
}

if (hitSlowdown) {
motion.getX().multiply(0.6D);
motion.getZ().multiply(0.6D);

if (Math.abs(motion.getX().get()) < 0.005D) motion.getX().set(0.0D);
if (Math.abs(motion.getZ().get()) < 0.005D) motion.getZ().set(0.0D);

if (jump && sprint) {
final float radians = data.getRotationTracker().getYaw() * 0.017453292F;

motion.getX().subtract(sin(fastMath, radians) * 0.2F);
motion.getZ().add(cos(fastMath, radians) * 0.2F);
}

float friction = 0.91F;
if (data.getPositionTracker().isLastOnGround()) friction *= 0.6F;

final float moveSpeed = PlayerUtil.getAttributeSpeed(data, sprint);
final float moveFlyingFriction;

if (ground) {
final float moveSpeedMultiplier = 0.16277136F / (friction * friction * friction);

moveFlyingFriction = moveSpeed * moveSpeedMultiplier;
} else {
moveFlyingFriction = (float) (sprint
? ((double) 0.02F + (double) 0.02F * 0.3D)
: 0.02F);
}

final float[] moveFlying = this.moveFlying(forward, strafe, moveFlyingFriction, fastMath);

motion.getX().add(moveFlying[0]);
motion.getZ().add(moveFlying[1]);

final double distance = realMotion.distanceSquared(motion);

// Set the lowest distance outcome
if (distance < this.distance) {
this.distance = distance;
this.motion = motion.clone();

this.sprint = sprint;
this.jump = jump;
this.using = using;
this.hitSlowdown = hitSlowdown;
this.fastMath = fastMath;

if (distance < 1e-14) break iteration;
}
}
for (int ui = 0; ui < 2; ui++) {
for (int hs = 0; hs < 2; hs++) {
for (int fm = 0; fm < 2; fm++) {
final boolean sprint = sp == 0;
final boolean jump = jp == 0;
final boolean using = ui == 0;
final boolean hitSlowdown = hs == 0;
final boolean fastMath = fm == 1;
final boolean ground = data.getPositionTracker().isLastOnGround();
final boolean sneaking = data.getActionTracker().isSneaking();

if (f <= 0.0F && sprint && ground) continue;

float forward = f;
float strafe = s;

if (using) {
forward *= 0.2D;
strafe *= 0.2D;
}

if (sneaking) {
forward *= (float) 0.3D;
strafe *= (float) 0.3D;
}

forward *= 0.98F;
strafe *= 0.98F;

final Motion motion = new Motion(
data.getPositionTracker().getLastDeltaX(),
0.0D,
data.getPositionTracker().getLastDeltaZ()
);

if (data.getPositionTracker().isLastLastOnGround()) {
motion.getX().multiply(0.6F * 0.91F);
motion.getZ().multiply(0.6F * 0.91F);
} else {
motion.getX().multiply(0.91F);
motion.getZ().multiply(0.91F);
}

data.getVelocityTracker().getActions().forEach(action -> action.accept(motion));

if (hitSlowdown) {
motion.getX().multiply(0.6D);
motion.getZ().multiply(0.6D);
}

if (Math.abs(motion.getX().get()) < 0.005D) motion.getX().set(0.0D);
if (Math.abs(motion.getZ().get()) < 0.005D) motion.getZ().set(0.0D);

if (jump && sprint) {
final float radians = data.getRotationTracker().getYaw() * 0.017453292F;

motion.getX().subtract(sin(fastMath, radians) * 0.2F);
motion.getZ().add(cos(fastMath, radians) * 0.2F);
}

float friction = 0.91F;
if (data.getPositionTracker().isLastOnGround()) friction *= 0.6F;

final float moveSpeed = PlayerUtil.getAttributeSpeed(data, sprint);
final float moveFlyingFriction;

if (ground) {
final float moveSpeedMultiplier = 0.16277136F / (friction * friction * friction);

moveFlyingFriction = moveSpeed * moveSpeedMultiplier;
} else {
moveFlyingFriction = (float) (sprint
? ((double) 0.02F + (double) 0.02F * 0.3D)
: 0.02F);
}

final float[] moveFlying = this.moveFlying(forward, strafe, moveFlyingFriction, fastMath);

motion.getX().add(moveFlying[0]);
motion.getZ().add(moveFlying[1]);

motion.getY().set(0.0D);

final double distance = realMotion.distanceSquared(motion);

// Set the lowest distance outcome
if (distance < this.distance) {
this.distance = distance;
this.motion = motion.clone();

this.sprint = sprint;
this.jump = jump;
this.using = using;
this.hitSlowdown = hitSlowdown;
this.fastMath = fastMath;

if (distance < 1e-14) break iteration;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: AntiHaxerman
version: 4.0-RC-6
version: 4.0.0
main: me.tecnio.ahm.AHMPlugin
authors: [Tecnio, Incognito, aSwitch]
description: An open-sourced anti-cheat solution.
Expand Down

0 comments on commit bbcff96

Please sign in to comment.