package us.lincey.flddo.check.impl.hitbox;

import us.lincey.flddo.AuroraPlugin; import us.lincey.flddo.check.Check; import us.lincey.flddo.check.handler.PacketHandler; import us.lincey.flddo.data.PlayerData; import us.lincey.flddo.data.config.ConfigData; import us.lincey.flddo.network.wrapper.WrappedPacket; import us.lincey.flddo.network.wrapper.inbound.CPacketFlying; import us.lincey.flddo.network.wrapper.inbound.CPacketUseEntity; import us.lincey.flddo.util.buffer.Buffer; import us.lincey.flddo.util.collision.BoundingBox; import us.lincey.flddo.util.distance.DistanceUtil; import us.lincey.flddo.util.location.PlayerLocation; import us.lincey.flddo.util.silent.SilentUtil; import org.bukkit.util.Vector;

public class HitboxA extends Check implements PacketHandler { private final Buffer buffer = new Buffer(5.0); private DistanceUtil target; private final int ping;

public HitboxA(PlayerData data) { super(data, "Hitbox", "Hitbox"); this.ping = SilentUtil.getPing(data.getPlayer()); }

public void handle(WrappedPacket packet) { if (!ConfigData.bH || (ConfigData.ok && getData().getPlayer().hasPermission("aurora.bypass"))) return;

  if (packet instanceof CPacketUseEntity) {
     CPacketUseEntity wrapper = (CPacketUseEntity)packet;
     this.target = this.entityTracker.get(wrapper.getEntityId());
  } else if (packet instanceof CPacketFlying && this.target != null) {
     PlayerLocation from = this.positionTracker.getFrom();
     PlayerLocation to = this.positionTracker.getTo();

     BoundingBox boundingBox = this.target.getBox().copy();
     boundingBox.expand(0.10000000149011612, 0.10000000149011612, 0.10000000149011612);

     if (this.positionTracker.isOffsetMotion()) {
        boundingBox.expand(0.03, 0.03, 0.03);
     }

     Vector direction = new Vector(-Math.sin(Math.toRadians(to.getYaw())), 0.0, Math.cos(Math.toRadians(to.getYaw())));
     double inverseDirectionX = 1.0 / direction.getX();
     double inverseDirectionZ = 1.0 / direction.getZ();
     boolean inverseX = inverseDirectionX < 0.0;
     boolean inverseZ = inverseDirectionZ < 0.0;
     double minX = ((inverseX ? boundingBox.getMaxX() : boundingBox.getMinX()) - from.getX()) * inverseDirectionX;
     double maxX = ((inverseX ? boundingBox.getMinX() : boundingBox.getMaxX()) - from.getX()) * inverseDirectionX;
     double minZ = ((inverseZ ? boundingBox.getMaxZ() : boundingBox.getMinZ()) - from.getZ()) * inverseDirectionZ;
     double maxZ = ((inverseZ ? boundingBox.getMinZ() : boundingBox.getMaxZ()) - from.getZ()) * inverseDirectionZ;
     boolean intersects = maxZ > minX && minZ < maxX;
     double a = maxZ - minX;
     double b = minZ - maxX;

     if (ping <= AuroraPlugin.MaxPing) {
        if (!intersects) {
           if (this.buffer.add() > 2.0) {
              this.fail(String.format("Difference= %.4f : %.4f", a, b));
           }
        } else {
           this.buffer.reduce(0.01);
        }
     }

     this.target = null;
  }

} }

HitboxA Check: Detecting Player Hitbox Exploitation in Minecraft

原文地址: http://www.cveoy.top/t/topic/pMrb 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录