Skip to content

Commit

Permalink
allow configuring reach flag buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Oct 14, 2024
1 parent 9599b1c commit 1fe5112
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ public class Reach extends Check implements PacketCheck {

private boolean cancelImpossibleHits;
private double threshold;
private double cancelBuffer; // For the next 4 hits after using reach, we aggressively cancel reach

private double flagBufferMax = 1;
private double flagBufferIncrement = 1;
private double flagBufferDecay = 0.25;
private double flagBuffer; // For the next 4 hits after using reach, we aggressively cancel reach

public Reach(GrimPlayer player) {
super(player);
Expand Down Expand Up @@ -130,7 +134,7 @@ private boolean isKnownInvalid(PacketEntity reachEntity) {
if (player.compensatedEntities.getSelf().inVehicle()) return false;

// Filter out what we assume to be cheats
if (cancelBuffer != 0) {
if (flagBuffer > 0) {
return checkReach(reachEntity, new Vector3d(player.x, player.y, player.z), true) != null; // If they flagged
} else {
SimpleCollisionBox targetBox = reachEntity.getPossibleCollisionBoxes();
Expand Down Expand Up @@ -223,13 +227,13 @@ private String checkReach(PacketEntity reachEntity, Vector3d from, boolean isPre
// if the entity is not exempt and the entity is alive
if ((!blacklisted.contains(reachEntity.getType()) && reachEntity.isLivingEntity()) || reachEntity.getType() == EntityTypes.END_CRYSTAL) {
if (minDistance == Double.MAX_VALUE) {
cancelBuffer = 1;
flagBuffer = Math.min(flagBuffer + flagBufferIncrement, flagBufferMax);
return "Missed hitbox";
} else if (minDistance > player.compensatedEntities.getSelf().getAttributeValue(Attributes.PLAYER_ENTITY_INTERACTION_RANGE)) {
cancelBuffer = 1;
flagBuffer = Math.min(flagBuffer + flagBufferIncrement, flagBufferMax);
return String.format("%.5f", minDistance) + " blocks";
} else {
cancelBuffer = Math.max(0, cancelBuffer - 0.25);
flagBuffer = Math.max(0, flagBuffer - flagBufferDecay);
}
}

Expand All @@ -238,7 +242,15 @@ private String checkReach(PacketEntity reachEntity, Vector3d from, boolean isPre

@Override
public void onReload(ConfigManager config) {
this.cancelImpossibleHits = config.getBooleanElse("Reach.block-impossible-hits", true);
this.threshold = config.getDoubleElse("Reach.threshold", 0.0005);
this.cancelImpossibleHits = config.getBooleanElse(getConfigName() + ".block-impossible-hits", true);
this.threshold = config.getDoubleElse(getConfigName() + ".threshold", 0.0005);

this.flagBufferMax = config.getDoubleElse(getConfigName() + ".flag-buffer-max", 1);
this.flagBufferIncrement = config.getDoubleElse(getConfigName() + ".flag-buffer-increment", 1);
this.flagBufferDecay = config.getDoubleElse(getConfigName() + ".flag-buffer-decay", 0.25);

if (this.flagBufferMax == -1) {
this.flagBufferMax = Double.MAX_VALUE;
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/config/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ Reach:
# Bleibt diese Funktion deaktiviert, werden immer noch Cheater erwischt und es kommt nicht zu Fehlalarmen.
# Sofern es sich nicht um einen 1.8 PvP-Server handelt, wird dieses zusätzliche Paket nicht empfohlen.
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
allow-sprint-jumping-when-using-elytra: true
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ Reach:
# Leaving this disabled will still catch cheaters and will not cause false positives
# Unless you are a 1.8 PvP focused server, this additional packet is not recommended
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
# You can gain high speeds when sprint jumping with an elytra, this prevents the exploit when set to false
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ Reach:
# Dejar esto deshabilitado también encontrara a jugadores haciendo trampa y no causara falsos positivos.
# Excepto que seas un servidor 1.8 enfocado en el PvP, este paquete adicional no es recomendado.
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
allow-sprint-jumping-when-using-elytra: true
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ Reach:
# Laisser cette fonctionnalité désactivée permettra tout de même de détecter les tricheurs et n'entraînera pas de faux positifs.
# À moins d'être un serveur axé sur le PvP en 1.8, l'envoi de ce paquet supplémentaire n'est pas recommandé.
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
allow-sprint-jumping-when-using-elytra: true
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ Reach:
block-impossible-hits: true
# Abilita l'invio di pacchetti aggiuntivi per il rilevamento degli attacchi
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
# Abilita il salto in sprint con l'elytra
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ Reach:
# Als je dit uitgeschakeld laat, worden nog steeds valsspelers gepakt en zullen er geen valse positieven ontstaan
# Tenzij je een 1.8 PvP server bent, wordt dit extra pakket niet aangeraden
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
# Je kunt hoge snelheden krijgen als je sprint met een elytra, dit voorkomt de exploit als het op false staat
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ Reach:
# Deixando-o desabilitado, continuará detectando trapaceiros e não irá causar falsos positivos.
# A menos que estiver em um servidor focado em PvP, esse pacote adicional não é recomendado.
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
# Você pode ganhar altas velocidades se pular correndo com uma elytra, previne isso de ocorrer quando definido falso.
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ Reach:
# Если оставить эту функцию отключенной, читеры все равно будут отлавливаться и не будут вызывать ложных срабатываний.
# Если вы не являетесь PvP-сервером 1.8, этот дополнительный пакет не рекомендуется.
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
allow-sprint-jumping-when-using-elytra: true
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ Reach:
# 禁用此功能仍会捕获作弊者,不会导致误报
# 除非你是专注于 1.8 PvP 的服务器,否则不建议使用这个额外的数据包
enable-post-packet: false
flag-buffer-max: 1 # set to -1 to disable
flag-buffer-increment: 1
flag-buffer-decay: 0.25

exploit:
#是否允许玩家在使用鞘翅时候进行的疾跑跳跃
Expand Down

0 comments on commit 1fe5112

Please sign in to comment.