Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/me/tecnio/antihaxerman/check/impl/movement/flight/FlightA.java
#	src/main/java/me/tecnio/antihaxerman/exempt/type/ExemptType.java
  • Loading branch information
Tecnio committed Apr 9, 2021
2 parents 7fbcafa + 36cdfe6 commit 1f0a960
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import me.tecnio.antihaxerman.data.PlayerData;
import me.tecnio.antihaxerman.exempt.type.ExemptType;
import me.tecnio.antihaxerman.packet.Packet;
import me.tecnio.antihaxerman.util.PlayerUtil;
import org.bukkit.potion.PotionEffectType;

@CheckInfo(name = "Flight", type = "A", description = "Flags flight's that don't obey gravity.")
public final class FlightA extends Check {
Expand All @@ -39,30 +37,28 @@ public void handle(final Packet packet) {
final int serverAirTicks = data.getPositionProcessor().getAirTicks();
final int clientAirTicks = data.getPositionProcessor().getClientAirTicks();

final int airTicksModifier = PlayerUtil.getPotionLevel(data.getPlayer(), PotionEffectType.JUMP);
final int airTicksLimit = 8 + airTicksModifier;

final double deltaY = data.getPositionProcessor().getDeltaY();
final double lastDeltaY = data.getPositionProcessor().getLastDeltaY();

final double predicted = (lastDeltaY - 0.08) * 0.9800000190734863;

final double fixedPredicted = isExempt(ExemptType.VELOCITY_ON_TICK) ? velocityY : Math.abs(predicted) < 0.005 ? -0.08 * 0.98F : predicted;
final double difference = Math.abs(deltaY - fixedPredicted);
double fixedPredicted = Math.abs(predicted) < 0.005 ? -0.08 * 0.9800000190734863 : predicted;
if (isExempt(ExemptType.VELOCITY_ON_TICK)) fixedPredicted = velocityY;

final double limit = 0.001;
final double difference = Math.abs(deltaY - fixedPredicted);
final double limit = 1.0E-8;

final boolean exempt = isExempt(ExemptType.PISTON, ExemptType.VEHICLE, ExemptType.TELEPORT,
ExemptType.LIQUID, ExemptType.BOAT, ExemptType.FLYING, ExemptType.WEB, ExemptType.JOINED,
ExemptType.SLIME, ExemptType.CLIMBABLE, ExemptType.CHUNK, ExemptType.VOID);
final boolean invalid = difference > limit && (serverAirTicks > airTicksLimit || clientAirTicks > airTicksLimit);
ExemptType.SLIME_ON_TICK, ExemptType.CLIMBABLE, ExemptType.CHUNK, ExemptType.VOID, ExemptType.UNDERBLOCK);
final boolean invalid = difference > limit && (serverAirTicks > 1 || clientAirTicks > 1);

if (invalid && !exempt) {
if (increaseBuffer() > 2) {
fail();
if (increaseBuffer() > 3) {
fail(String.format("pred: %.4f delta: %.4f vel: %s", fixedPredicted, deltaY, isExempt(ExemptType.VELOCITY_ON_TICK)));
}
} else {
decreaseBufferBy(0.1);
decreaseBufferBy(0.15);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public void handle(final Packet packet) {
if (!exempt) {
if (airTicks > 0) {
if (deltaXZ > airLimit) {
if (increaseBuffer() > 2) {
if (increaseBuffer() > 3) {
fail();
}
} else {
decreaseBufferBy(0.15);
}
} else {
if (deltaXZ > groundLimit) {
if (increaseBuffer() > 2) {
if (increaseBuffer() > 3) {
fail();
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public void handle(final Packet packet) {
final boolean invalid = !interactedCorrectly(blockLocation, location, direction);

if (invalid) {
fail();
if (increaseBuffer() > 1) {
fail();
}
} else {
resetBuffer();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public InteractC(final PlayerData data) {
@Override
public void handle(final Packet packet) {
if (packet.isBlockPlace()) {
wrapper = new WrappedPacketInBlockPlace(packet.getRawPacket());
if (data.getPlayer().getItemInHand().getType().isBlock()) {
wrapper = new WrappedPacketInBlockPlace(packet.getRawPacket());
}
} else if (packet.isFlying()) {
if (wrapper != null) {
final Vector eyeLocation = data.getPlayer().getEyeLocation().toVector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public enum ExemptType {

SLIME(data -> data.getPositionProcessor().getSinceSlimeTicks() < 20),

SLIME_ON_TICK(data -> data.getPositionProcessor().getSinceSlimeTicks() < 2),

DIGGING(data -> AntiHaxerman.INSTANCE.getTickManager().getTicks() - data.getActionProcessor().getLastDiggingTick() < 10),

BLOCK_BREAK(data -> AntiHaxerman.INSTANCE.getTickManager().getTicks() - data.getActionProcessor().getLastBreakTick() < 10),
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/me/tecnio/antihaxerman/packet/Packet.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ public boolean isVelocity() {
return isSending() && packetId == PacketType.Play.Server.ENTITY_VELOCITY;
}

public boolean isExplosion() {
return isSending() && packetId == PacketType.Play.Server.EXPLOSION;
}

public boolean isRelEntityMove() {
return isSending() && packetId == PacketType.Play.Server.REL_ENTITY_MOVE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package me.tecnio.antihaxerman.packet.processor;

import io.github.retrooper.packetevents.packetwrappers.play.out.entityvelocity.WrappedPacketOutEntityVelocity;
import io.github.retrooper.packetevents.packetwrappers.play.out.explosion.WrappedPacketOutExplosion;
import io.github.retrooper.packetevents.packetwrappers.play.out.keepalive.WrappedPacketOutKeepAlive;
import io.github.retrooper.packetevents.packetwrappers.play.out.position.WrappedPacketOutPosition;
import io.github.retrooper.packetevents.packetwrappers.play.out.transaction.WrappedPacketOutTransaction;
Expand All @@ -34,6 +35,10 @@ public void handle(final PlayerData data, final Packet packet) {
data.getVelocityProcessor().handle(wrapper.getVelocityX(), wrapper.getVelocityY(), wrapper.getVelocityZ());
}
}
if (packet.isExplosion()) {
final WrappedPacketOutExplosion wrapper = new WrappedPacketOutExplosion(packet.getRawPacket());
data.getVelocityProcessor().handle(wrapper.getPlayerMotionX(), wrapper.getPlayerMotionY(), wrapper.getPlayerMotionZ());
}
if (packet.isOutgoingTransaction()) {
final WrappedPacketOutTransaction wrapper = new WrappedPacketOutTransaction(packet.getRawPacket());

Expand Down

0 comments on commit 1f0a960

Please sign in to comment.