HitboxA Check - Anti-Cheat for Minecraft Servers
package us.lincey.flddo.check.impl.hitbox; \nimport us.lincey.flddo.AuroraPlugin; \nimport us.lincey.flddo.check.Check; \nimport us.lincey.flddo.check.handler.PacketHandler; \nimport us.lincey.flddo.data.PlayerData; \nimport us.lincey.flddo.data.config.ConfigData; \nimport us.lincey.flddo.network.wrapper.WrappedPacket; \nimport us.lincey.flddo.network.wrapper.inbound.CPacketFlying; \nimport us.lincey.flddo.network.wrapper.inbound.CPacketUseEntity; \nimport us.lincey.flddo.util.buffer.Buffer; \nimport us.lincey.flddo.util.collision.BoundingBox; \nimport us.lincey.flddo.util.distance.DistanceUtil; \nimport us.lincey.flddo.util.location.PlayerLocation; \nimport us.lincey.flddo.util.silent.SilentUtil; \nimport org.bukkit.util.Vector; \npublic class HitboxA extends Check implements PacketHandler { \n private final Buffer buffer = new Buffer(5.0); \n private DistanceUtil target; \n private final int ping = SilentUtil.getPing(getData().getPlayer()); \n public HitboxA(PlayerData data) { \n super(data, "Hitbox", "Hitbox"); \n } \n public void handle(WrappedPacket packet) { \n if (!ConfigData.bH) return; \n if (ConfigData.ok && getData().getPlayer().hasPermission("aurora.bypass")) return; \n if (packet instanceof CPacketUseEntity) { \n CPacketUseEntity wrapper = (CPacketUseEntity)packet; \n this.target = this.entityTracker.get(wrapper.getEntityId()); \n } else if (packet instanceof CPacketFlying && this.target != null) { \n PlayerLocation from = this.positionTracker.getFrom(); \n PlayerLocation to = this.positionTracker.getTo(); \n BoundingBox boundingBox = this.target.getBox().copy(); \n boundingBox.expand(0.10000000149011612, 0.10000000149011612, 0.10000000149011612); \n if (this.positionTracker.isOffsetMotion()) { \n boundingBox.expand(0.03, 0.03, 0.03); \n } \n Vector direction = new Vector(-Math.sin(Math.toRadians(to.getYaw())), 0.0, Math.cos(Math.toRadians(to.getYaw()))); \n double inverseDirectionX = 1.0 / direction.getX(); \n double inverseDirectionZ = 1.0 / direction.getZ(); \n boolean inverseX = inverseDirectionX < 0.0; \n boolean inverseZ = inverseDirectionZ < 0.0; \n double minX = ((inverseX ? boundingBox.getMaxX() : boundingBox.getMinX()) - from.getX()) * inverseDirectionX; \n double maxX = ((inverseX ? boundingBox.getMinX() : boundingBox.getMaxX()) - from.getX()) * inverseDirectionX; \n double minZ = ((inverseZ ? boundingBox.getMaxZ() : boundingBox.getMinZ()) - from.getZ()) * inverseDirectionZ; \n double maxZ = ((inverseZ ? boundingBox.getMinZ() : boundingBox.getMaxZ()) - from.getZ()) * inverseDirectionZ; \n boolean intersects = maxZ > minX && minZ < maxX; \n double a = maxZ - minX; \n double b = minZ - maxX; \n if (ping > AuroraPlugin.MaxPing) { \n return; \n } \n if (!intersects) { \n if (this.buffer.add() > 2.0) { \n this.fail(String.format("Difference= %.4f : %.4f", a, b)); \n } \n } else { \n this.buffer.reduce(0.01); \n } \n this.target = null; \n } \n } \
原文地址: http://www.cveoy.top/t/topic/pMq5 著作权归作者所有。请勿转载和采集!