-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
添加NoSlowA检查。 修复一些误判。 优化代码效率。 修复服务端TPS导致的误判。 已知误判: - **FlightA** 鞘翅、三叉戟。 - **BlinkA** 状态效果。 - **SpeedA** 状态效果、道具。客户端掉帧卡顿时。
- Loading branch information
Showing
6 changed files
with
91 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/top/infsky/timerecorder/anticheat/checks/NoSlowA.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package top.infsky.timerecorder.anticheat.checks; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import top.infsky.timerecorder.anticheat.Check; | ||
import top.infsky.timerecorder.anticheat.TRPlayer; | ||
import top.infsky.timerecorder.anticheat.utils.PlayerMove; | ||
|
||
import java.util.List; | ||
|
||
import static top.infsky.timerecorder.anticheat.TRPlayer.CONFIG; | ||
|
||
public class NoSlowA extends Check { | ||
public static final List<Double> SLOW_SPEED = List.of(2.56, 1.92, 1.6, 1.4, 1.36, 1.26, 1.18, 1.16); | ||
public short itemUseTick = 0; | ||
public short disableTick = 0; // 跳跃弱检测 | ||
public NoSlowA(@NotNull TRPlayer player) { | ||
super("NoSlowA", player); | ||
} | ||
|
||
@Override | ||
public void _onTick() { | ||
if (!player.fabricPlayer.isUsingItem() || !player.lastUsingItem) { | ||
itemUseTick = 0; | ||
return; // 当连续两个tick使用物品才检查 | ||
} | ||
if (player.jumping) { | ||
disableTick = 4; | ||
return; | ||
} | ||
if (disableTick > 0) { | ||
disableTick--; | ||
return; | ||
} | ||
|
||
final double secSpeed = PlayerMove.getXzSecSpeed(player.lastPos, player.currentPos); | ||
|
||
if (secSpeed > SLOW_SPEED.get(itemUseTick) * (1 + player.fabricPlayer.getSpeed()) + CONFIG().getThreshold()) { | ||
flag(); | ||
setback(player.lastPos); | ||
player.fabricPlayer.stopUsingItem(); | ||
badPacket(); | ||
} | ||
if (itemUseTick < SLOW_SPEED.size() - 1) itemUseTick++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/top/infsky/timerecorder/anticheat/utils/PlayerMove.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package top.infsky.timerecorder.anticheat.utils; | ||
|
||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.NotNull; | ||
import top.infsky.timerecorder.Utils; | ||
|
||
public class PlayerMove { | ||
public static double getXzTickSpeed(@NotNull Vec3 lastTick, @NotNull Vec3 currentTick) { | ||
Vec3 prefixLast = new Vec3(lastTick.x(), 0, lastTick.z()); | ||
Vec3 prefixCurrent = new Vec3(currentTick.x(), 0, currentTick.z()); | ||
return prefixCurrent.distanceTo(prefixLast); | ||
} | ||
|
||
public static double getXzSecSpeed(@NotNull Vec3 lastTick, @NotNull Vec3 currentTick) { | ||
assert Utils.getSERVER() != null; | ||
|
||
final double tickSpeed = getXzTickSpeed(lastTick, currentTick); | ||
final double tickTime = Utils.getSERVER().tickTimes[Utils.getSERVER().getTickCount() % 100] / 1000000.0; | ||
// LogUtils.alert("tickTime", "debug", String.valueOf(tickTime)); | ||
if (tickTime <= 50) | ||
return tickSpeed * 20; | ||
else | ||
return tickSpeed * 1000 / tickTime; | ||
} | ||
} |