-
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.
添加HighJumpA检查。 添加SpeedB检查。 修复一个误判。 修复一个崩溃bug。 已知误判: - **FlightA** 鞘翅、三叉戟。 - **BlinkA** 状态效果。 - **SpeedA** 状态效果、道具。服务器以下雨天启动。 - **AirJumpA** blink时意外触发。
- Loading branch information
Showing
11 changed files
with
150 additions
and
24 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
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
30 changes: 30 additions & 0 deletions
30
src/main/java/top/infsky/timerecorder/anticheat/checks/HighJumpA.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,30 @@ | ||
package top.infsky.timerecorder.anticheat.checks; | ||
|
||
import lombok.val; | ||
import net.minecraft.world.phys.Vec3; | ||
import top.infsky.timerecorder.anticheat.Check; | ||
import top.infsky.timerecorder.anticheat.TRPlayer; | ||
|
||
import static top.infsky.timerecorder.anticheat.TRPlayer.CONFIG; | ||
|
||
public class HighJumpA extends Check { | ||
public double highestY = Double.MIN_VALUE; | ||
public HighJumpA(TRPlayer player) { | ||
super("HighJumpA", player); | ||
} | ||
|
||
@Override | ||
public void _onTick() { | ||
if (player.isJumping()) { | ||
if (player.currentPos.y() > highestY) highestY = player.currentPos.y(); | ||
|
||
val groundPrefixPos = new Vec3(0, player.lastOnGroundPos.y(), 0); | ||
val airPrefixPos = new Vec3(0, highestY, 0); | ||
|
||
if (airPrefixPos.distanceTo(groundPrefixPos) > 1.25219 * (1 + player.fabricPlayer.getJumpBoostPower()) + CONFIG().getThreshold()) { | ||
flag(); | ||
setback(player.lastOnGroundPos); | ||
} | ||
} else highestY = Double.MIN_VALUE; | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/top/infsky/timerecorder/anticheat/checks/SpeedB.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,19 @@ | ||
package top.infsky.timerecorder.anticheat.checks; | ||
|
||
import top.infsky.timerecorder.anticheat.Check; | ||
import top.infsky.timerecorder.anticheat.TRPlayer; | ||
|
||
public class SpeedB extends Check { | ||
public SpeedB(TRPlayer player) { | ||
super("SpeedB", player); | ||
} | ||
|
||
@Override | ||
public void _onTick() { | ||
if (player.fabricPlayer.isSprinting() && player.fabricPlayer.getFoodData().getFoodLevel() <= 6) { | ||
flag(); | ||
badPacket(); | ||
player.fabricPlayer.setSprinting(false); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/top/infsky/timerecorder/anticheat/utils/TimeTaskManager.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,41 @@ | ||
package top.infsky.timerecorder.anticheat.utils; | ||
|
||
import org.jetbrains.annotations.Range; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Queue; | ||
import java.util.concurrent.LinkedBlockingQueue; | ||
|
||
public class TimeTaskManager { | ||
private final List<Queue<Runnable>> tasks; | ||
|
||
public TimeTaskManager() { | ||
this.tasks = new LinkedList<>(); | ||
} | ||
|
||
public void addTask(Runnable task) { | ||
addTask(task, 0); | ||
} | ||
|
||
public void addTask(Runnable task, @Range(from = 0, to = Integer.MIN_VALUE) int delay) { | ||
try { | ||
tasks.get(delay).add(task); | ||
} catch (IndexOutOfBoundsException e) { | ||
if (delay > tasks.size()) | ||
for (int i = tasks.size(); i <= delay; i++) { | ||
tasks.add(new LinkedBlockingQueue<>()); | ||
} | ||
tasks.add(delay, new LinkedBlockingQueue<>()); | ||
addTask(task, delay); | ||
} | ||
} | ||
|
||
public void onTick() { | ||
try { | ||
for (Runnable task : tasks.remove(0)) { | ||
task.run(); | ||
} | ||
} catch (IndexOutOfBoundsException ignored) {} | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/top/infsky/timerecorder/mixins/MixinPlayer.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,29 @@ | ||
package top.infsky.timerecorder.mixins; | ||
|
||
|
||
import com.mojang.authlib.GameProfile; | ||
import lombok.val; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import top.infsky.timerecorder.Utils; | ||
|
||
import java.util.Objects; | ||
|
||
@Mixin(Player.class) | ||
public class MixinPlayer { | ||
@Shadow @Final private GameProfile gameProfile; | ||
|
||
@Inject(method = "jumpFromGround", at = @At(value = "HEAD")) | ||
public void jumpFromGround(CallbackInfo ci) { | ||
try { | ||
val trPlayer = Objects.requireNonNull(Utils.getPlayer(this.gameProfile.getId())).antiCheat; | ||
|
||
trPlayer.manager.onJump(); | ||
} catch (NullPointerException ignored) {} | ||
} | ||
} |
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