mirror of
https://github.com/funkemunky/KauriV3.git
synced 2026-06-06 16:12:18 +00:00
Fixing false positives
- Added wrapper for PacketPlayOutAbiltiies - Adding (unfinished) wrapper for PacketPlayOutPlayerInfo - Fixed abilities false positives; Fly, Speed, Hitbox. Done by using new Abilities tracking - Renamed Speed to Horizontal.
This commit is contained in:
@@ -57,7 +57,8 @@ public class FlyA extends Check {
|
||||
if(!getPlayer().getInfo().isGeneralCancel()
|
||||
&& getPlayer().getInfo().getBlockAbove().isPassed(1)
|
||||
&& !getPlayer().getInfo().isOnLadder()
|
||||
&& !(onGround && !fromGround)
|
||||
&& !getPlayer().getBlockInformation().inWeb
|
||||
&& !getPlayer().getBlockInformation().onHalfBlock
|
||||
&& getPlayer().getInfo().getVelocity().isPassed(1)
|
||||
&& !getPlayer().getBlockInformation().onSlime && deltaPredict > 0.016) {
|
||||
if(++buffer > 5) {
|
||||
|
||||
+9
-5
@@ -18,8 +18,8 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Deque;
|
||||
|
||||
@CheckData(name = "Speed", type = CheckType.MOVEMENT)
|
||||
public class Speed extends Check {
|
||||
@CheckData(name = "Horizontal", type = CheckType.MOVEMENT)
|
||||
public class Horizontal extends Check {
|
||||
private boolean lastLastClientGround;
|
||||
private float buffer;
|
||||
private Vector velocity;
|
||||
@@ -29,7 +29,7 @@ public class Speed extends Check {
|
||||
|
||||
public double strafe, forward;
|
||||
|
||||
public Speed(APlayer player) {
|
||||
public Horizontal(APlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,10 @@ public class Speed extends Check {
|
||||
|
||||
float forward = f, strafe = s;
|
||||
|
||||
if(sprinting && forward <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sneaking) {
|
||||
forward *= 0.3;
|
||||
strafe *= 0.3;
|
||||
@@ -221,8 +225,8 @@ public class Speed extends Check {
|
||||
|
||||
double pmotion = Math.hypot(pmotionx, pmotionz);
|
||||
|
||||
if (getPlayer().getMovement().getDeltaXZ() > pmotion && smallestDelta > 1E-4 && getPlayer().getMovement().getDeltaXZ() > 0.1) {
|
||||
if (++buffer > 3) {
|
||||
if (getPlayer().getMovement().getDeltaXZ() > pmotion && smallestDelta > 5E-13 && getPlayer().getMovement().getDeltaXZ() > 0.1) {
|
||||
if ((buffer+= smallestDelta > 5E-4 ? 1 : 0.5) > 3) {
|
||||
buffer = Math.min(3.5f, buffer); //Ensuring we don't have a run-away buffer
|
||||
flag("smallest=%s b=%.1f to=%s dxz=%.2f", smallestDelta, buffer, getPlayer().getMovement().getTo().getLoc(), getPlayer().getMovement().getDeltaXZ());
|
||||
}
|
||||
@@ -34,6 +34,16 @@ public class VelocityA extends Check {
|
||||
&& !getPlayer().getInfo().isGeneralCancel()) {
|
||||
double pct = getPlayer().getMovement().getDeltaY() / currentVelocity.getY() * 100;
|
||||
|
||||
if(currentVelocity.getY() < 0.005
|
||||
|| getPlayer().getBlockInformation().collidesHorizontally
|
||||
|| getPlayer().getInfo().getLastAbilities().isNotPassed(3)
|
||||
|| getPlayer().getBlockInformation().collidesVertically
|
||||
|| getPlayer().getInfo().getVelocity().isPassed(7)) {
|
||||
currentVelocity = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(pct < 99.999 || pct > 400) {
|
||||
if(++buffer > 15) {
|
||||
flag("pct=%.1f%% buffer=%.1f", pct, buffer);
|
||||
@@ -44,12 +54,6 @@ public class VelocityA extends Check {
|
||||
getPlayer().getMovement().getDeltaY(), currentVelocity.getY());
|
||||
|
||||
currentVelocity.setY((currentVelocity.getY() - 0.08) * 0.98);
|
||||
|
||||
if(currentVelocity.getY() < 0.005
|
||||
|| getPlayer().getBlockInformation().collidesHorizontally
|
||||
|| getPlayer().getBlockInformation().collidesVertically
|
||||
|| getPlayer().getInfo().getVelocity().isPassed(7))
|
||||
currentVelocity = null;
|
||||
} else if(currentVelocity != null) {
|
||||
debug("not null: " + currentVelocity.getY());
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.brighten.ac.check.impl.velocity;
|
||||
|
||||
import dev.brighten.ac.check.Action;
|
||||
import dev.brighten.ac.check.Check;
|
||||
import dev.brighten.ac.check.impl.speed.Speed;
|
||||
import dev.brighten.ac.check.impl.speed.Horizontal;
|
||||
import dev.brighten.ac.data.APlayer;
|
||||
import dev.brighten.ac.packet.wrapper.in.WPacketPlayInFlying;
|
||||
import dev.brighten.ac.packet.wrapper.in.WPacketPlayInUseEntity;
|
||||
@@ -128,7 +128,7 @@ public class VelocityB extends Check {
|
||||
|
||||
found = true;
|
||||
if(!velocity.isPresent()) {
|
||||
Speed speedCheck = (Speed) getPlayer().findCheck(Speed.class);
|
||||
Horizontal speedCheck = (Horizontal) getPlayer().findCheck(Horizontal.class);
|
||||
double s2 = speedCheck.strafe;
|
||||
double f2 = speedCheck.forward;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.brighten.ac.data.handlers;
|
||||
|
||||
import dev.brighten.ac.packet.wrapper.objects.PlayerCapabilities;
|
||||
import dev.brighten.ac.utils.KLocation;
|
||||
import dev.brighten.ac.utils.PastLocation;
|
||||
import dev.brighten.ac.utils.objects.evicting.EvictingList;
|
||||
@@ -12,6 +13,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -20,14 +22,15 @@ import java.util.Optional;
|
||||
@Setter
|
||||
public class GeneralInformation {
|
||||
private Optional<Block> blockOnTo, blockBelow;
|
||||
private Timer lastMove = new TickTimer(), vehicleSwitch = new TickTimer(),
|
||||
private Timer lastMove = new TickTimer(), vehicleSwitch = new TickTimer(), lastAbilities = new TickTimer(),
|
||||
lastSneak = new TickTimer(), velocity = new TickTimer(), lastCancel = new TickTimer(),
|
||||
lastElytra = new TickTimer(), blockAbove = new TickTimer(), lastPlace = new TickTimer();
|
||||
private LivingEntity target;
|
||||
private boolean serverGround, lastServerGround, nearGround, worldLoaded, generalCancel, inVehicle, creative,
|
||||
private boolean serverGround, lastServerGround, canFly, nearGround, worldLoaded, generalCancel, inVehicle, creative,
|
||||
sneaking, sprinting, gliding, riptiding, wasOnSlime, onLadder, doingVelocity;
|
||||
private List<Entity> nearbyEntities = Collections.emptyList();
|
||||
private PastLocation targetPastLocation = new PastLocation();
|
||||
private KLocation lastKnownGoodPosition;
|
||||
private List<Vector> velocityHistory = Collections.synchronizedList(new EvictingList<>(5));
|
||||
private List<PlayerCapabilities> possibleCapabilities = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -193,7 +193,13 @@ public class MovementHandler {
|
||||
}
|
||||
|
||||
player.getInfo().setCreative(player.getBukkitPlayer().getGameMode() == GameMode.CREATIVE
|
||||
|| player.getBukkitPlayer().getGameMode() == GameMode.SPECTATOR);
|
||||
|| player.getBukkitPlayer().getGameMode() == GameMode.SPECTATOR
|
||||
|| player.getInfo().getPossibleCapabilities().stream()
|
||||
.anyMatch(capability -> capability.canInstantlyBuild));
|
||||
|
||||
player.getInfo().setCanFly(player.getBukkitPlayer().getAllowFlight()
|
||||
|| player.getInfo().getPossibleCapabilities().stream()
|
||||
.anyMatch(capability -> capability.canFly));
|
||||
|
||||
boolean hasLevitation = ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_9)
|
||||
&& player.getPotionHandler().hasPotionEffect(XPotion.LEVITATION.getPotionEffectType());
|
||||
@@ -208,6 +214,7 @@ public class MovementHandler {
|
||||
player.getInfo().setGeneralCancel(player.getBukkitPlayer().getAllowFlight()
|
||||
|| moveTicks == 0
|
||||
|| excuseNextFlying
|
||||
|| player.getInfo().isCanFly()
|
||||
|| player.getInfo().isCreative()
|
||||
|| lastTeleport.isNotPassed(2)
|
||||
|| teleportsToConfirm > 0
|
||||
|
||||
@@ -88,6 +88,20 @@ public class PacketHandler {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SERVER_ABILITIES: {
|
||||
WPacketPlayOutAbilities packet = (WPacketPlayOutAbilities) packetObject;
|
||||
|
||||
player.getInfo().getLastAbilities().reset();
|
||||
|
||||
player.runInstantAction(ia -> {
|
||||
if(!ia.isEnd()) {
|
||||
player.getInfo().getPossibleCapabilities().add(packet.getCapabilities());
|
||||
} else if(player.getInfo().getPossibleCapabilities().size() > 1) {
|
||||
player.getInfo().getPossibleCapabilities().remove(0);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
case FLYING: {
|
||||
WPacketPlayInFlying packet = (WPacketPlayInFlying) packetObject;
|
||||
|
||||
|
||||
@@ -37,9 +37,15 @@ public interface PacketConverter {
|
||||
|
||||
WPacketPlayOutEntityVelocity processVelocity(Object object);
|
||||
|
||||
WPacketPlayOutAbilities processOutAbilities(Object object);
|
||||
|
||||
Object processOutAbilities(WPacketPlayOutAbilities packet);
|
||||
|
||||
Object processVelocity(WPacketPlayOutEntityVelocity packet);
|
||||
|
||||
WPacketPlayOutWorldParticles processParticles(Object object);
|
||||
|
||||
Object processParticles(WPacketPlayOutWorldParticles packet);
|
||||
|
||||
WPacketPlayOutPlayerInfo processInfo(Object object);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public enum PacketType {
|
||||
SERVER_ABILITIES("PacketPlayOutAbilities"),
|
||||
ENTITY_METADATA("PacketPlayOutEntityMetadata"),
|
||||
VELOCITY("PacketPlayOutEntityVelocity"),
|
||||
INFO("PacketPlayOutInfo"),
|
||||
ENTITY_DESTROY("PacketPlayOutEntityDestroy"),
|
||||
SCOREBOARD_DISPLAY_OBJECTIVE("PacketPlayOutScoreboardDisplayObjective"),
|
||||
SCOREBOARD_OBJECTIVE("PacketPlayOutScoreboardObjective"),
|
||||
@@ -126,6 +127,8 @@ public enum PacketType {
|
||||
return convert.processMultiBlockChange(object);
|
||||
case VELOCITY:
|
||||
return convert.processVelocity(object);
|
||||
case SERVER_ABILITIES:
|
||||
return convert.processOutAbilities(object);
|
||||
default:
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.brighten.ac.packet.wrapper.impl;
|
||||
import dev.brighten.ac.packet.wrapper.PacketConverter;
|
||||
import dev.brighten.ac.packet.wrapper.in.*;
|
||||
import dev.brighten.ac.packet.wrapper.objects.EnumParticle;
|
||||
import dev.brighten.ac.packet.wrapper.objects.PlayerCapabilities;
|
||||
import dev.brighten.ac.packet.wrapper.objects.WrappedEnumDirection;
|
||||
import dev.brighten.ac.packet.wrapper.out.*;
|
||||
import dev.brighten.ac.utils.math.IntVector;
|
||||
@@ -39,16 +40,27 @@ public class Processor_18 implements PacketConverter {
|
||||
.build();
|
||||
}
|
||||
|
||||
private static final WrappedClass classAbilities = new WrappedClass(PacketPlayInAbilities.class);
|
||||
private static final WrappedClass classAbilities = new WrappedClass(PacketPlayInAbilities.class),
|
||||
outClassAbilities = new WrappedClass(PacketPlayOutAbilities.class);
|
||||
private static final WrappedField fieldFlySpeed = classAbilities.getFieldByType(float.class, 0),
|
||||
fieldWalkSpeed = classAbilities.getFieldByType(float.class, 1);
|
||||
|
||||
private static final WrappedField outfieldFlySpeed = outClassAbilities.getFieldByType(float.class, 0),
|
||||
outfieldWalkSpeed = outClassAbilities.getFieldByType(float.class, 1);
|
||||
@Override
|
||||
public WPacketPlayInAbilities processAbilities(Object object) {
|
||||
PacketPlayInAbilities abilities = (PacketPlayInAbilities) object;
|
||||
|
||||
return WPacketPlayInAbilities.builder().allowedFlight(abilities.a()).flying(abilities.isFlying())
|
||||
.allowedFlight(abilities.c()).creativeMode(abilities.d()).flySpeed(fieldFlySpeed.get(abilities))
|
||||
.walkSpeed(fieldWalkSpeed.get(abilities)).build();
|
||||
return WPacketPlayInAbilities.builder()
|
||||
.capabilities(PlayerCapabilities.builder()
|
||||
.isInvulnerable(abilities.a())
|
||||
.isFlying(abilities.isFlying())
|
||||
.canFly(abilities.c())
|
||||
.canInstantlyBuild(abilities.d())
|
||||
.flySpeed(fieldFlySpeed.get(abilities))
|
||||
.walkSpeed(fieldWalkSpeed.get(abilities))
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,6 +308,35 @@ public class Processor_18 implements PacketConverter {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WPacketPlayOutAbilities processOutAbilities(Object object) {
|
||||
PacketPlayOutAbilities packet = (PacketPlayOutAbilities) object;
|
||||
return WPacketPlayOutAbilities.builder()
|
||||
.capabilities(PlayerCapabilities.builder()
|
||||
.isInvulnerable(packet.a())
|
||||
.isFlying(packet.b())
|
||||
.canFly(packet.c())
|
||||
.canInstantlyBuild(packet.d())
|
||||
.flySpeed(outfieldFlySpeed.get(packet))
|
||||
.walkSpeed(outfieldWalkSpeed.get(packet))
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object processOutAbilities(WPacketPlayOutAbilities packet) {
|
||||
PlayerAbilities abilities = new PlayerAbilities();
|
||||
|
||||
abilities.canFly = packet.getCapabilities().canFly;
|
||||
abilities.isFlying = packet.getCapabilities().isFlying;
|
||||
abilities.isInvulnerable = packet.getCapabilities().isInvulnerable;
|
||||
abilities.canInstantlyBuild = packet.getCapabilities().canInstantlyBuild;
|
||||
abilities.flySpeed = packet.getCapabilities().flySpeed;
|
||||
abilities.walkSpeed = packet.getCapabilities().walkSpeed;
|
||||
|
||||
return new PacketPlayOutAbilities(abilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object processVelocity(WPacketPlayOutEntityVelocity packet) {
|
||||
return new PacketPlayOutEntityVelocity(packet.getEntityId(), packet.getDeltaX(), packet.getDeltaY(), packet.getDeltaZ());
|
||||
@@ -334,6 +375,12 @@ public class Processor_18 implements PacketConverter {
|
||||
packet.getSpeed(), packet.getAmount(), packet.getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WPacketPlayOutPlayerInfo processInfo(Object object) {
|
||||
PacketPlayOutPlayerInfo packet = (PacketPlayOutPlayerInfo) object;
|
||||
return null;
|
||||
}
|
||||
|
||||
private PacketDataSerializer serialize(Packet packet) {
|
||||
PacketDataSerializer serial = new PacketDataSerializer(Unpooled.buffer());
|
||||
try {
|
||||
|
||||
@@ -2,14 +2,14 @@ package dev.brighten.ac.packet.wrapper.in;
|
||||
|
||||
import dev.brighten.ac.packet.wrapper.PacketType;
|
||||
import dev.brighten.ac.packet.wrapper.WPacket;
|
||||
import dev.brighten.ac.packet.wrapper.objects.PlayerCapabilities;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class WPacketPlayInAbilities implements WPacket {
|
||||
private boolean invulnerable, flying, allowedFlight, creativeMode;
|
||||
private float flySpeed, walkSpeed;
|
||||
private PlayerCapabilities capabilities;
|
||||
|
||||
@Override
|
||||
public PacketType getPacketType() {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.brighten.ac.packet.wrapper.objects;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
@Builder
|
||||
public class PlayerCapabilities {
|
||||
public boolean isInvulnerable;
|
||||
public boolean isFlying;
|
||||
public boolean canFly;
|
||||
public boolean canInstantlyBuild;
|
||||
public boolean mayBuild = true;
|
||||
public float flySpeed = 0.05F;
|
||||
public float walkSpeed = 0.1F;
|
||||
}
|
||||
Reference in New Issue
Block a user