-
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.
添加拉回功能,允许反作弊阻止作弊行为。 修复FlightA的游泳误判。 修复FlightA的出水误判。 修复TP误判。 已知误判:跳跃提升、激流、鞘翅。
- Loading branch information
Showing
11 changed files
with
135 additions
and
40 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
48 changes: 39 additions & 9 deletions
48
src/main/java/top/infsky/timerecorder/anticheat/Check.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 |
---|---|---|
@@ -1,35 +1,65 @@ | ||
package top.infsky.timerecorder.anticheat; | ||
|
||
import lombok.Getter; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.NotNull; | ||
import top.infsky.timerecorder.config.AntiCheatConfig; | ||
import top.infsky.timerecorder.config.ModConfig; | ||
import top.infsky.timerecorder.data.PlayerData; | ||
import top.infsky.timerecorder.log.LogUtils; | ||
|
||
@Getter | ||
public abstract class Check { | ||
public String checkName; | ||
public PlayerData player; | ||
public PlayerData playerData; | ||
public final ServerPlayer player; | ||
public static AntiCheatConfig CONFIG() { return ModConfig.INSTANCE.getAntiCheat(); } | ||
|
||
public Check(String checkName, PlayerData player) { | ||
public Vec3 currentPos; | ||
public Vec3 lastPos; | ||
public Vec3 lastPos2; | ||
public Vec3 lastOnGroundPos; | ||
public Vec3 lastInWaterPos; | ||
|
||
public Check(String checkName, @NotNull PlayerData playerData) { | ||
assert playerData.player != null; | ||
this.checkName = checkName; | ||
this.player = player; | ||
this.playerData = playerData; | ||
this.player = (ServerPlayer) playerData.player; | ||
currentPos = player.position(); | ||
} | ||
|
||
public final void flag() { | ||
assert player.antiCheat != null; | ||
player.antiCheat.violations++; | ||
LogUtils.alert(player.getName(), checkName); | ||
playerData.antiCheat.violations++; | ||
LogUtils.alert(playerData.getName(), checkName, String.format("VL: %s", playerData.antiCheat.violations)); | ||
} | ||
|
||
public final void flag(String extraMsg) { | ||
assert player.antiCheat != null; | ||
player.antiCheat.violations++; | ||
LogUtils.alert(player.getName(), checkName, extraMsg); | ||
playerData.antiCheat.violations++; | ||
LogUtils.alert(playerData.getName(), checkName, extraMsg); | ||
} | ||
|
||
public final void setback(@NotNull Vec3 position) { | ||
if (!CONFIG().isAllowSetback()) return; | ||
player.teleportTo(position.x(), position.y(), position.z()); | ||
} | ||
|
||
public abstract void _onTick(); | ||
|
||
public abstract void _onTeleport(); | ||
|
||
public void update() { | ||
if (player == null) return; | ||
currentPos = player.position(); | ||
if (player.onGround()) { | ||
lastOnGroundPos = currentPos; | ||
} | ||
if (player.isInWater()) { | ||
lastInWaterPos = currentPos; | ||
} | ||
_onTick(); | ||
lastPos2 = lastPos; | ||
lastPos = currentPos; | ||
} | ||
} |
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
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
27 changes: 27 additions & 0 deletions
27
src/main/java/top/infsky/timerecorder/mixins/MixinTeleport.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,27 @@ | ||
package top.infsky.timerecorder.mixins; | ||
|
||
|
||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.server.network.ServerGamePacketListenerImpl; | ||
import net.minecraft.world.entity.RelativeMovement; | ||
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; | ||
import java.util.Set; | ||
|
||
@Mixin(ServerGamePacketListenerImpl.class) | ||
public abstract class MixinTeleport { | ||
@Shadow public abstract ServerPlayer getPlayer(); | ||
|
||
@Inject(method = "teleport(DDDFFLjava/util/Set;)V", at = @At(value = "HEAD")) | ||
public void teleport(double d, double e, double f, float g, float h, Set<RelativeMovement> set, CallbackInfo ci) { | ||
try { | ||
Objects.requireNonNull(Utils.getPlayer(this.getPlayer().getUUID())).antiCheat.onTeleport(); | ||
} 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