mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
Fixed #81, removed POS optifine check code that won't work & fixed console messaging
This commit is contained in:
1 parent
8cf2702708
commit
b2701fa057
11 files changed
+33
-76
No files matched your search
@@ -1,26 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
public class MinecraftSmooth {
|
||||
|
||||
private float x = 0, y = 0, z = 0;
|
||||
|
||||
public float smooth(float toSmooth, float increment) {
|
||||
x += toSmooth;
|
||||
toSmooth = (x - y) * increment;
|
||||
z += (toSmooth - z) * 0.5f;
|
||||
|
||||
if (toSmooth > 0f && toSmooth > z || toSmooth < 0f && toSmooth < z) {
|
||||
toSmooth = z;
|
||||
}
|
||||
|
||||
y += toSmooth;
|
||||
return toSmooth;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,10 +33,11 @@ public class PacketListener {
|
||||
public static void listenMovementPackets() {
|
||||
AntiCheatReloaded.getProtocolManager()
|
||||
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
|
||||
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK }) {
|
||||
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
|
||||
// Run MorePackets check
|
||||
MorePacketsCheck.runCheck(player, event);
|
||||
|
||||
@@ -48,8 +48,6 @@ public class User {
|
||||
private Long[] messageTimes = new Long[2];
|
||||
private String[] commands = new String[2];
|
||||
private Long[] commandTimes = new Long[2];
|
||||
private MinecraftSmooth yawSmooth = new MinecraftSmooth(), pitchSmooth = new MinecraftSmooth();
|
||||
private boolean usingOptifine = false;
|
||||
|
||||
private boolean isWaitingOnLevelSync;
|
||||
private Timestamp levelSyncTimestamp;
|
||||
@@ -455,33 +453,6 @@ public class User {
|
||||
return Math.abs(this.ping - this.lastPing) > 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user is using optifine zoom to prevent false positives
|
||||
* @param yaw
|
||||
* @param pitch
|
||||
*/
|
||||
public void checkForOptifine(float yaw, float pitch) {
|
||||
float yawDelta = Math.abs(this.getPlayer().getLocation().getYaw() - yaw);
|
||||
float modifiedYaw = this.modifyValue(yawDelta);
|
||||
float pitchDelta = Math.abs(this.getPlayer().getLocation().getPitch() - pitch);
|
||||
float modifiedPitch = this.modifyValue(pitchDelta);
|
||||
float yawSmooth = this.yawSmooth.smooth(modifiedYaw, modifiedYaw * 0.05f);
|
||||
float pitchSmooth = this.pitchSmooth.smooth(modifiedPitch, modifiedPitch * 0.05f);
|
||||
if (Math.abs(yawSmooth - modifiedYaw) < 0.08f || Math.abs(pitchSmooth - modifiedPitch) < 0.04f) {
|
||||
this.usingOptifine = true;
|
||||
} else {
|
||||
this.usingOptifine = false;
|
||||
}
|
||||
}
|
||||
|
||||
private float modifyValue(float value) {
|
||||
return ((float) Math.cbrt((value / 0.15f) / 8f) - 0.2f) / .6f;
|
||||
}
|
||||
|
||||
public boolean isUsingOptifine() {
|
||||
return this.usingOptifine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User {name = " + getName() + ", level = " + level + "}";
|
||||
|
||||
@@ -219,6 +219,29 @@ public final class Utilities {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("SLAB");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a block is a bed
|
||||
*
|
||||
* @param block block to bed
|
||||
* @return true if bed
|
||||
*/
|
||||
public static boolean isBed(Block block) {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("BED");
|
||||
}
|
||||
|
||||
public static boolean isNearBed(Location location) {
|
||||
return isBed(location.getBlock())
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.WEST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a block is a stair
|
||||
|
||||
Reference in new issue
Block a user