GastinelGarde 0.4.0 : controles elytres, velocite, auto-totem (OBSERVE par defaut)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
80c9748a23
révision
334cc5b45c
12 fichiers modifiés
+736
-6
Aucun fichier ne correspond à votre recherche
@@ -60,6 +60,8 @@ public final class Garde {
|
||||
/** Marques propres à un joueur, côté adaptateur (ticks du serveur). */
|
||||
private static final class Marques {
|
||||
int teleportTick = Integer.MIN_VALUE;
|
||||
/** 0.4.0 : jusqu'à ce tick, une fusée a propulsé le joueur (plané non contrôlé). */
|
||||
int propulsionJusquaTick = Integer.MIN_VALUE;
|
||||
int reculTick = Integer.MIN_VALUE;
|
||||
int dernierVerdictTick = Integer.MIN_VALUE;
|
||||
int dernierTraceTick = Integer.MIN_VALUE;
|
||||
@@ -342,6 +344,28 @@ public final class Garde {
|
||||
if (m.graceRecul.recul(tick, autoInflige)) m.reculTick = tick;
|
||||
}
|
||||
|
||||
/** Fusée de feu d'artifice tirée par ce joueur (propulsion en plané) : le plané n'est pas contrôlé pendant 6 s. */
|
||||
public static void noterFusee(ServerPlayer p) {
|
||||
if (!surThreadServeur(p)) return;
|
||||
marques(p.getUUID()).propulsionJusquaTick = p.server.getTickCount() + 120;
|
||||
}
|
||||
|
||||
/** 0.4.0 : recul appliqué par le serveur (direction du déplacement attendu, force avant résistance). */
|
||||
public static void noterVelocite(ServerPlayer p, double dirX, double dirZ, double force) {
|
||||
if (!surThreadServeur(p)) return;
|
||||
double resistance = p.getAttributeValue(net.minecraft.world.entity.ai.attributes.Attributes.KNOCKBACK_RESISTANCE);
|
||||
MOTEUR.reculApplique(p.getUUID(), p.server.getTickCount() * 50L, dirX, dirZ, force * Math.max(0.0, 1.0 - resistance));
|
||||
}
|
||||
|
||||
/** 0.4.0 : un totem d'immortalité vient d'éclater (hand = main qui le tenait). */
|
||||
public static void noterTotem(ServerPlayer p, net.minecraft.world.InteractionHand hand) {
|
||||
if (!surThreadServeur(p)) return;
|
||||
net.minecraft.world.InteractionHand autre = hand == net.minecraft.world.InteractionHand.MAIN_HAND
|
||||
? net.minecraft.world.InteractionHand.OFF_HAND : net.minecraft.world.InteractionHand.MAIN_HAND;
|
||||
boolean reserve = p.getItemInHand(autre).is(Items.TOTEM_OF_UNDYING);
|
||||
MOTEUR.totemEclate(p.getUUID(), p.server.getTickCount() * 50L, reserve);
|
||||
}
|
||||
|
||||
public static void noterTickServeur(MinecraftServer server, long dureeNs) {
|
||||
double ms = dureeNs / 1_000_000.0;
|
||||
if (ms > 250.0) gelTick = server.getTickCount();
|
||||
@@ -412,6 +436,7 @@ public final class Garde {
|
||||
.ticksDepuisGel(depuis(tick, gelTick))
|
||||
.tps(tpsEstime)
|
||||
.pingMs(p.connection.latency())
|
||||
.propulsionRecente(tick <= m.propulsionJusquaTick)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -648,6 +673,21 @@ public final class Garde {
|
||||
m.oeilAvant = m.oeilDernier;
|
||||
m.oeilDernier = new double[] {oeil.x, oeil.y, oeil.z};
|
||||
}
|
||||
// 0.4.0 : recul mesuré (anti-recul) et totem remis en main (auto-totem), sur les mêmes paquets.
|
||||
if (!estExempteManuellement(p.getUUID()) && (CONFIG.mode(Controle.VELOCITE) != Mode.OFF
|
||||
|| CONFIG.mode(Controle.AUTO_TOTEM) != Mode.OFF)) {
|
||||
EtatJoueur etatSup = etat(p, true);
|
||||
long maintenant = tick * 50L;
|
||||
if (m.mouvementTick != Integer.MIN_VALUE) {
|
||||
List<Verdict> v = MOTEUR.mesureRecul(p.getUUID(), maintenant, etatSup, p.getX() - m.mouvementX,
|
||||
p.getZ() - m.mouvementZ, em != null && em.milieuSpecial());
|
||||
Sanction s = traiter(p, v);
|
||||
if (Cablage.sanctionDeMouvement(s)) appliquerSanctionMouvement(p, s, v);
|
||||
}
|
||||
boolean totem = p.getMainHandItem().is(Items.TOTEM_OF_UNDYING) || p.getOffhandItem().is(Items.TOTEM_OF_UNDYING);
|
||||
List<Verdict> vt = MOTEUR.totemEnMain(p.getUUID(), maintenant, etatSup, totem);
|
||||
traiter(p, vt); // information seulement : jamais de setback pour un totem
|
||||
}
|
||||
m.mouvementTick = tick;
|
||||
m.mouvementX = p.getX();
|
||||
m.mouvementY = p.getY();
|
||||
|
||||
@@ -129,7 +129,11 @@ public final class GardeEvents {
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public static void onRecul(LivingKnockBackEvent event) {
|
||||
if (event.isCanceled() || event.getStrength() <= 0.0F) return;
|
||||
if (event.getEntity() instanceof ServerPlayer p && !(p instanceof FakePlayer)) Garde.noterRecul(p, false);
|
||||
if (event.getEntity() instanceof ServerPlayer p && !(p instanceof FakePlayer)) {
|
||||
Garde.noterRecul(p, false);
|
||||
// Vanilla retire (ratioX, ratioZ) x force à la vitesse du joueur : il part à l'opposé.
|
||||
Garde.noterVelocite(p, -event.getRatioX(), -event.getRatioZ(), event.getStrength());
|
||||
}
|
||||
}
|
||||
|
||||
/** Explosion, charge de vent (Wind Charge) : poussée vers le joueur. Celle qu'il s'inflige est limitée (GraceRecul). */
|
||||
@@ -139,6 +143,23 @@ public final class GardeEvents {
|
||||
if (!(event.getAffectedEntity() instanceof ServerPlayer p) || p instanceof FakePlayer) return;
|
||||
boolean auto = event.getExplosion().getIndirectSourceEntity() == p || event.getExplosion().getDirectSourceEntity() == p;
|
||||
Garde.noterRecul(p, auto);
|
||||
Vec3 v = event.getKnockbackVelocity();
|
||||
Garde.noterVelocite(p, v.x, v.z, Math.hypot(v.x, v.z));
|
||||
}
|
||||
|
||||
/** Fusée de feu d'artifice tirée par un joueur : propulsion en plané, donc plané non contrôlé un moment. */
|
||||
@SubscribeEvent
|
||||
public static void onFusee(net.neoforged.neoforge.event.entity.EntityJoinLevelEvent event) {
|
||||
if (event.getEntity() instanceof net.minecraft.world.entity.projectile.FireworkRocketEntity f
|
||||
&& f.getOwner() instanceof ServerPlayer p && !(p instanceof FakePlayer)) Garde.noterFusee(p);
|
||||
}
|
||||
|
||||
/** Totem éclaté : début de la mesure du délai de remise (auto-totem). */
|
||||
@SubscribeEvent
|
||||
public static void onTotem(net.neoforged.neoforge.event.entity.living.LivingUseTotemEvent event) {
|
||||
if (event.getEntity() instanceof ServerPlayer p && !(p instanceof FakePlayer)) {
|
||||
Garde.noterTotem(p, event.getHandHolding());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -51,6 +51,8 @@ public final class GardeSpec {
|
||||
private static final ModConfigSpec.IntValue SERIE_PING_MAX;
|
||||
private static final ModConfigSpec.IntValue SERIE_PING_MARGE;
|
||||
private static final ModConfigSpec.IntValue TIMER_SOLDE_MAX;
|
||||
private static final ModConfigSpec.IntValue ELY_MONTEE, ELY_STATIONNAIRE, VEL_FENETRE, VEL_SERIE, TOTEM_DELAI, TOTEM_PING;
|
||||
private static final ModConfigSpec.DoubleValue VEL_RAPPORT, VEL_FORCE;
|
||||
private static final ModConfigSpec.BooleanValue SUSP_ACTIVE;
|
||||
private static final ModConfigSpec.DoubleValue SUSP_SURVEILLER, SUSP_SUSPECT, SUSP_FORT, SUSP_DEMI_VIE,
|
||||
SUSP_PLAFOND_FIABLE, SUSP_PLAFOND_MOYEN, SUSP_PLAFOND_FAIBLE, SUSP_DIVERSITE_FENETRE;
|
||||
@@ -183,6 +185,24 @@ public final class GardeSpec {
|
||||
.defineInRange("historiqueJours", 7, 1, 365);
|
||||
b.pop();
|
||||
|
||||
b.comment("0.4.0 : plané en élytres (Elytra Hack), recul absent après un coup subi (Anti Knockback / Anti Push),",
|
||||
"totem remis en main sans délai humain (Auto Totem). Contrôles 'elytres', 'velocite' et 'auto-totem' : OBSERVE par défaut.")
|
||||
.push("nouveauxControles");
|
||||
ELY_MONTEE = b.comment("Ticks de montée sans perte de vitesse en plané avant infraction ; 0 = coupé.")
|
||||
.defineInRange("elytresMonteeTicks", 20, 0, 600);
|
||||
ELY_STATIONNAIRE = b.comment("Ticks de plané presque immobile sans chute avant infraction ; 0 = coupé.")
|
||||
.defineInRange("elytresStationnaireTicks", 20, 0, 600);
|
||||
VEL_FENETRE = b.defineInRange("velociteFenetreTicks", 6, 2, 20);
|
||||
VEL_RAPPORT = b.comment("Recul absent si le déplacement dans le sens du recul est sous cette part du recul vanilla.")
|
||||
.defineInRange("velociteRapportMin", 0.15, 0.0, 1.0);
|
||||
VEL_SERIE = b.comment("Reculs absents (sur les 6 derniers en 2 minutes) avant infraction.")
|
||||
.defineInRange("velociteSerieMin", 3, 1, 6);
|
||||
VEL_FORCE = b.defineInRange("velociteForceMin", 0.15, 0.0, 5.0);
|
||||
TOTEM_DELAI = b.comment("Réaction humaine minimale (ms) entre l'éclatement et le totem remis en main, ping en plus.")
|
||||
.defineInRange("totemDelaiMinMs", 150, 0, 2000);
|
||||
TOTEM_PING = b.defineInRange("totemPingMaxMs", 200, 0, 1000);
|
||||
b.pop();
|
||||
|
||||
b.push("mouvement");
|
||||
VOL_FLOTTEMENT = b.comment("Vol : ticks consécutifs en l'air sans chute avant infraction (vanilla : 80, 'kicked for floating too long').",
|
||||
"Remplace ce contrôle vanilla si allow-flight=true. 0 = coupé.")
|
||||
@@ -323,6 +343,14 @@ public final class GardeSpec {
|
||||
c.suspicionDiversiteFenetreMinutes = SUSP_DIVERSITE_FENETRE.get();
|
||||
c.suspicionHistoriqueJours = SUSP_JOURS.get();
|
||||
c.volFlottementTicks = VOL_FLOTTEMENT.get();
|
||||
c.elytresMonteeTicks = ELY_MONTEE.get();
|
||||
c.elytresStationnaireTicks = ELY_STATIONNAIRE.get();
|
||||
c.velociteFenetreTicks = VEL_FENETRE.get();
|
||||
c.velociteRapportMin = VEL_RAPPORT.get();
|
||||
c.velociteSerieMin = VEL_SERIE.get();
|
||||
c.velociteForceMin = VEL_FORCE.get();
|
||||
c.totemDelaiMinMs = TOTEM_DELAI.get();
|
||||
c.totemPingMaxMs = TOTEM_PING.get();
|
||||
c.volFenetreGlissante = VOL_FENETRE_GLISSANTE.get();
|
||||
c.vitesseMoyenne = VITESSE_MOYENNE.get();
|
||||
c.elytresExemptionStricte = ELYTRES_STRICTE.get();
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
/**
|
||||
* Contrôle « auto-totem » (0.4.0). Le cheat remet un totem en main dès l'éclatement, sans délai de réaction. Le
|
||||
* serveur voit l'éclatement (LivingUseTotemEvent) puis le contenu des mains à chaque paquet de mouvement : le délai
|
||||
* entre les deux ne peut pas être inférieur à l'aller-retour réseau (le client apprend l'éclatement après ping/2, sa
|
||||
* demande arrive après ping/2 de plus) plus la réaction humaine (~150 ms, arrondi au tick de 50 ms). Le ping est
|
||||
* falsifiable (F07) : il n'entre que borné à {@link GardeConfig#totemPingMaxMs}, donc un joueur qui gonfle son ping
|
||||
* ne gagne qu'une marge limitée. Un totem de réserve déjà en main à l'éclatement annule la mesure.
|
||||
*/
|
||||
public final class AutoTotem {
|
||||
|
||||
/** Mesure abandonnée si aucun totem n'est remis dans ce délai. */
|
||||
public static final long EXPIRATION_MS = 10_000;
|
||||
|
||||
private boolean actif;
|
||||
private long eclatMs;
|
||||
|
||||
/** @param reserveEnMain un autre totem était déjà dans l'autre main : rien à mesurer */
|
||||
public void eclatement(long nowMs, boolean reserveEnMain) {
|
||||
actif = !reserveEnMain;
|
||||
eclatMs = nowMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contenu des mains à un paquet de mouvement.
|
||||
*
|
||||
* @return points d'infraction (0 si rien)
|
||||
*/
|
||||
public double mains(long nowMs, boolean totemEnMain, int pingMs, GardeConfig cfg) {
|
||||
if (!actif) return 0;
|
||||
if (nowMs - eclatMs > EXPIRATION_MS) {
|
||||
actif = false;
|
||||
return 0;
|
||||
}
|
||||
if (!totemEnMain || nowMs <= eclatMs) return 0;
|
||||
actif = false;
|
||||
long delai = nowMs - eclatMs;
|
||||
long minimum = cfg.totemDelaiMinMs + Math.min(Math.max(0, pingMs), cfg.totemPingMaxMs);
|
||||
return delai < minimum ? 3.0 : 0;
|
||||
}
|
||||
|
||||
public void vider() {
|
||||
actif = false;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,13 @@ public enum Controle {
|
||||
VITESSE("vitesse"),
|
||||
VOL("vol"),
|
||||
VEHICULE_VITESSE("vehicule-vitesse"),
|
||||
VEHICULE_VOL("vehicule-vol");
|
||||
VEHICULE_VOL("vehicule-vol"),
|
||||
/** 0.4.0 : plané en élytres (Elytra Hack) : montée sans perte de vitesse, plané immobile. */
|
||||
ELYTRES("elytres"),
|
||||
/** 0.4.0 : recul absent après un coup subi (Anti Knockback, Anti Push). */
|
||||
VELOCITE("velocite"),
|
||||
/** 0.4.0 : totem remis en main sans délai humain après l'éclatement (Auto Totem). */
|
||||
AUTO_TOTEM("auto-totem");
|
||||
|
||||
private final String id;
|
||||
|
||||
@@ -44,7 +50,7 @@ public enum Controle {
|
||||
return switch (this) {
|
||||
case VOL, VITESSE, NO_FALL, PORTEE, HITBOX, REGULARITE -> 0;
|
||||
case COUPS_HORS_BOITE, KILLAURA_ANGLE, KILLAURA_CIBLES, CADENCE -> 1;
|
||||
case TIMER, ROTATION, ATTAQUE_IMPOSSIBLE, VEHICULE_VITESSE, VEHICULE_VOL -> 2;
|
||||
case TIMER, ROTATION, ATTAQUE_IMPOSSIBLE, VEHICULE_VITESSE, VEHICULE_VOL, ELYTRES, VELOCITE, AUTO_TOTEM -> 2;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ public record EtatJoueur(
|
||||
int ticksDepuisRecul,
|
||||
int ticksDepuisGel,
|
||||
double tps,
|
||||
int pingMs) {
|
||||
int pingMs,
|
||||
boolean propulsionRecente) {
|
||||
|
||||
public static final int JAMAIS = Integer.MAX_VALUE;
|
||||
|
||||
@@ -39,6 +40,7 @@ public record EtatJoueur(
|
||||
private int ticksDepuisTeleport = JAMAIS, ticksDepuisRecul = JAMAIS, ticksDepuisGel = JAMAIS;
|
||||
private double tps = 20.0;
|
||||
private int pingMs = 30;
|
||||
private boolean propulsionRecente;
|
||||
|
||||
public Builder creatif(boolean v) { creatif = v; return this; }
|
||||
public Builder spectateur(boolean v) { spectateur = v; return this; }
|
||||
@@ -57,11 +59,13 @@ public record EtatJoueur(
|
||||
public Builder ticksDepuisGel(int v) { ticksDepuisGel = v; return this; }
|
||||
public Builder tps(double v) { tps = v; return this; }
|
||||
public Builder pingMs(int v) { pingMs = v; return this; }
|
||||
/** 0.4.0 : fusée de feu d'artifice (ou autre poussée connue du serveur) récente : plané non contrôlé. */
|
||||
public Builder propulsionRecente(boolean v) { propulsionRecente = v; return this; }
|
||||
|
||||
public EtatJoueur build() {
|
||||
return new EtatJoueur(creatif, spectateur, peutVoler, riptide, elytres, levitation, chuteLente,
|
||||
enVehicule, pocheContraption, utiliseObjet, elytresDeploiementSuspect, ticksDepuisTeleport, ticksDepuisRecul,
|
||||
ticksDepuisGel, tps, pingMs);
|
||||
ticksDepuisGel, tps, pingMs, propulsionRecente);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,24 @@ public final class GardeConfig {
|
||||
/** Ticks consécutifs en l'air sans chute (dy par tick >= -0,03125, comme vanilla) avant infraction ; 0 = coupé. */
|
||||
public int volFlottementTicks = 80;
|
||||
|
||||
// --- 0.4.0 : plané (elytres), vélocité (recul), auto-totem. OBSERVE par défaut, valeurs à valider en jeu ---
|
||||
/** Ticks de montée sans perte de vitesse en plané avant infraction ; 0 = coupé. */
|
||||
public int elytresMonteeTicks = 20;
|
||||
/** Ticks de plané presque immobile et sans chute avant infraction ; 0 = coupé. */
|
||||
public int elytresStationnaireTicks = 20;
|
||||
/** Ticks sur lesquels le recul est mesuré après un coup subi. */
|
||||
public int velociteFenetreTicks = 6;
|
||||
/** Recul absent si le déplacement dans le sens du recul est sous cette part du recul vanilla. */
|
||||
public double velociteRapportMin = 0.15;
|
||||
/** Reculs absents (sur les 6 derniers en 2 min) avant infraction. */
|
||||
public int velociteSerieMin = 3;
|
||||
/** Force de recul effective (après résistance) en dessous de laquelle on ne mesure pas. */
|
||||
public double velociteForceMin = 0.15;
|
||||
/** Réaction humaine minimale (ms) entre l'éclatement d'un totem et un totem remis en main, hors ping. */
|
||||
public int totemDelaiMinMs = 150;
|
||||
/** Ping (ms) au plus ajouté à ce délai (le ping est falsifiable). */
|
||||
public int totemPingMaxMs = 200;
|
||||
|
||||
// --- Killaura ---
|
||||
/** Angle maximal entre le regard et la silhouette de la cible, en degrés. */
|
||||
public double angleMaxDegres = 60.0;
|
||||
|
||||
@@ -380,11 +380,20 @@ public final class Moteur {
|
||||
// 15/10 : l'élan réel de la période exemptée est gardé (élytres arrêtées en plein vol, recul…).
|
||||
s.vitesse.exempter(m, ex.facteur(), sortieDEtat(ex.raisons()));
|
||||
s.vol.vider();
|
||||
// 0.4.0 : plané seul exempté -> contrôle « elytres » (Elytra Hack). Toute autre exemption l'écarte.
|
||||
List<Verdict> plane = new ArrayList<>(1);
|
||||
if (ex.raisons().size() == 1 && ex.raisons().get(0).equals("elytres")
|
||||
&& cfg.mode(Controle.ELYTRES) != Mode.OFF) {
|
||||
ajouter(plane, s, Controle.ELYTRES, s.plane.enregistrer(m, etat.propulsionRecente(), cfg), nowMs, ex,
|
||||
String.format(Locale.ROOT, "plane dxz=%.3f dy=%.3f ticks=%d", m.dxz(), m.dy(), m.ticks()));
|
||||
} else {
|
||||
s.plane.vider();
|
||||
}
|
||||
// C1 (16/10, incident Rednixxu) : le drapeau élytres tombe côté serveur alors que le client plane encore.
|
||||
if (ex.raisons().contains("elytres")) {
|
||||
s.graceElytresJusquaMs = nowMs + cfg.graceFinElytresTicks * 50L;
|
||||
}
|
||||
return List.of();
|
||||
return plane;
|
||||
}
|
||||
List<Verdict> verdicts = new ArrayList<>(3);
|
||||
if (noFall) {
|
||||
@@ -476,6 +485,50 @@ public final class Moteur {
|
||||
return NoFall.auSolEffectif(auSolClient, auSolServeur, ex.exempt(), cfg.mode(Controle.NO_FALL));
|
||||
}
|
||||
|
||||
// --- 0.4.0 : vélocité (recul) et auto-totem ---
|
||||
|
||||
/**
|
||||
* Le serveur applique un recul au joueur (coup, explosion, charge de vent).
|
||||
*
|
||||
* @param dirX,dirZ direction du déplacement attendu ; {@code force} effective, résistance déduite
|
||||
*/
|
||||
public void reculApplique(UUID joueur, long nowMs, double dirX, double dirZ, double force) {
|
||||
if (cfg.mode(Controle.VELOCITE) == Mode.OFF || expulses.contains(joueur)) return;
|
||||
suivi(joueur).velocite.recul(nowMs, dirX, dirZ, force, cfg);
|
||||
}
|
||||
|
||||
/** Déplacement horizontal de ce paquet accepté (dx, dz signés), pour mesurer le recul en cours. */
|
||||
public List<Verdict> mesureRecul(UUID joueur, long nowMs, EtatJoueur etat, double dx, double dz, boolean milieuSpecial) {
|
||||
if (cfg.mode(Controle.VELOCITE) == Mode.OFF || expulses.contains(joueur)) return List.of();
|
||||
Suivi s = suivis.get(joueur);
|
||||
if (s == null) return List.of();
|
||||
boolean neutre = milieuSpecial || etat.creatif() || etat.spectateur() || etat.peutVoler() || etat.elytres()
|
||||
|| etat.enVehicule() || etat.riptide() || etat.pocheContraption()
|
||||
|| etat.ticksDepuisTeleport() <= cfg.graceTeleportTicks;
|
||||
double pts = s.velocite.mouvement(nowMs, dx, dz, neutre, cfg);
|
||||
List<Verdict> v = new ArrayList<>(1);
|
||||
ajouter(v, s, Controle.VELOCITE, pts, nowMs, Exemptions.evaluer(etat, cfg, Exemptions.Famille.COMBAT),
|
||||
"recul absent apres un coup subi (serie)");
|
||||
return v;
|
||||
}
|
||||
|
||||
/** Un totem vient d'éclater ; {@code reserveEnMain} : un autre totem est déjà dans l'autre main. */
|
||||
public void totemEclate(UUID joueur, long nowMs, boolean reserveEnMain) {
|
||||
if (cfg.mode(Controle.AUTO_TOTEM) == Mode.OFF || expulses.contains(joueur)) return;
|
||||
suivi(joueur).totem.eclatement(nowMs, reserveEnMain);
|
||||
}
|
||||
|
||||
/** Contenu des mains (au moins un totem ?) à un paquet de mouvement après un éclatement. */
|
||||
public List<Verdict> totemEnMain(UUID joueur, long nowMs, EtatJoueur etat, boolean totemEnMain) {
|
||||
if (cfg.mode(Controle.AUTO_TOTEM) == Mode.OFF || expulses.contains(joueur)) return List.of();
|
||||
Suivi s = suivis.get(joueur);
|
||||
if (s == null) return List.of();
|
||||
List<Verdict> v = new ArrayList<>(1);
|
||||
ajouter(v, s, Controle.AUTO_TOTEM, s.totem.mains(nowMs, totemEnMain, etat.pingMs(), cfg), nowMs,
|
||||
Exemptions.evaluer(etat, cfg, Exemptions.Famille.COMBAT), "totem remis en main trop vite apres l'eclatement");
|
||||
return v;
|
||||
}
|
||||
|
||||
// --- Setback, expulsion, position de retour (16/10, incident VOL) ----------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
/**
|
||||
* Contrôle « elytres » (0.4.0) : le plané est exempté de vitesse, de vol et de no-fall (Exemptions, famille
|
||||
* mouvement). Le « Elytra Hack » de CheatUtils (méthode VanillaFly) donne au plané l'accélération verticale et
|
||||
* horizontale du vol créatif : on monte à vitesse constante ou on reste sur place. Le vanilla ne le permet pas :
|
||||
* <ul>
|
||||
* <li>monter coûte de la vitesse horizontale (l'énergie vient de la piqué) : une montée de plus de
|
||||
* {@link GardeConfig#elytresMonteeTicks} ticks sans perte de vitesse est impossible sans fusée ;</li>
|
||||
* <li>rester presque immobile sans chute ({@link GardeConfig#elytresStationnaireTicks} ticks) est impossible :
|
||||
* à faible vitesse la portance est nulle et le joueur tombe.</li>
|
||||
* </ul>
|
||||
* Aucune des deux règles ne s'applique après une fusée (propulsion récente), dans un milieu spécial (courant d'air
|
||||
* Create, colonne à bulles, eau…), ni quand une autre exemption est active (le moteur n'appelle ce contrôle que si
|
||||
* « elytres » est la seule raison d'exemption). Les valeurs sont à confirmer en jeu : OBSERVE par défaut.
|
||||
*
|
||||
* <p>Pourquoi l'option C7 ({@code elytresExemptionStricte}) ne suffit pas : elle retire seulement l'exemption quand
|
||||
* le plané démarre sans ticks en l'air côté serveur (onGround falsifié). Un tricheur qui saute puis déploie ses
|
||||
* élytres normalement reste exempté de tout, et C7 ne regarde jamais ce que le plané fait ensuite.
|
||||
*/
|
||||
public final class PlaneElytres {
|
||||
|
||||
/** Montée franche (blocs par tick) ; en dessous, c'est du plané à plat. */
|
||||
public static final double MONTEE_MIN = 0.05;
|
||||
/** Une montée qui garde au moins cette part de la vitesse horizontale du début est suspecte. */
|
||||
public static final double VITESSE_GARDEE = 0.9;
|
||||
/** Vitesse horizontale (blocs par tick) en dessous de laquelle le plané ne porte plus. */
|
||||
public static final double VITESSE_STATIONNAIRE = 0.15;
|
||||
/** Chute (blocs par tick) en dessous de laquelle on ne tombe pas vraiment. */
|
||||
public static final double CHUTE_MIN = -0.04;
|
||||
/** Paquets au-delà de ce nombre de ticks : pas de mesure fiable (retard réseau). */
|
||||
public static final int TICKS_MAX = 3;
|
||||
|
||||
private int monteeTicks;
|
||||
private double vitesseDebut;
|
||||
private int stationnaireTicks;
|
||||
|
||||
/**
|
||||
* @param m déplacement accepté
|
||||
* @param propulsion une fusée (ou autre poussée connue du serveur) est récente
|
||||
* @return points d'infraction (0 si rien)
|
||||
*/
|
||||
public double enregistrer(EtatMouvement m, boolean propulsion, GardeConfig cfg) {
|
||||
int n = m.ticks();
|
||||
if (propulsion || m.milieuSpecial() || m.auSolServeur()) {
|
||||
vider();
|
||||
return 0;
|
||||
}
|
||||
if (n < 1 || n > TICKS_MAX) return 0; // neutre : ni remise à zéro ni ajout
|
||||
double vh = m.dxz() / n;
|
||||
double vy = m.dy() / n;
|
||||
double points = 0;
|
||||
|
||||
if (vh < VITESSE_STATIONNAIRE && vy > CHUTE_MIN) stationnaireTicks += n;
|
||||
else stationnaireTicks = 0;
|
||||
if (cfg.elytresStationnaireTicks > 0 && stationnaireTicks > cfg.elytresStationnaireTicks) points = 1.5;
|
||||
|
||||
if (vy > MONTEE_MIN) {
|
||||
if (monteeTicks == 0) vitesseDebut = vh;
|
||||
monteeTicks += n;
|
||||
if (cfg.elytresMonteeTicks > 0 && monteeTicks > cfg.elytresMonteeTicks
|
||||
&& vh >= vitesseDebut * VITESSE_GARDEE) {
|
||||
points = Math.max(points, 1.5);
|
||||
}
|
||||
} else if (vy < 0) {
|
||||
monteeTicks = 0;
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
public void vider() {
|
||||
monteeTicks = 0;
|
||||
vitesseDebut = 0;
|
||||
stationnaireTicks = 0;
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,10 @@ public final class Suivi {
|
||||
|
||||
/** Score de suspicion (0.4.0). */
|
||||
public final Suspicion suspicion;
|
||||
/** 0.4.0 : plané, recul, totem. */
|
||||
public final PlaneElytres plane = new PlaneElytres();
|
||||
public final Velocite velocite = new Velocite();
|
||||
public final AutoTotem totem = new AutoTotem();
|
||||
|
||||
public Suivi(double decroissanceParSeconde) {
|
||||
this(decroissanceParSeconde, new GardeConfig());
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
/**
|
||||
* Contrôle « velocite » (0.4.0) : anti-recul (Anti Knockback) et anti-poussée (Anti Push) de CheatUtils annulent côté
|
||||
* client la vitesse que le serveur vient de donner. Le serveur sait quand il applique un recul (LivingKnockBackEvent,
|
||||
* explosions) et sa force ; il voit ensuite les paquets de mouvement. Vanilla : la vitesse est posée d'un coup
|
||||
* (0,4 de base, plus avec un coup en courant ou Recul) et le joueur recule d'environ 4,5 x la force en 6 ticks. Un
|
||||
* joueur honnête peut contrer en marchant (au plus ~0,22 bloc par tick) ou être arrêté par un mur : un recul
|
||||
* absent n'est donc compté que s'il manque presque tout ({@link GardeConfig#velociteRapportMin}) et seulement
|
||||
* en série ({@link GardeConfig#velociteSerieMin} sur les {@link #HISTORIQUE} derniers reculs de 2 minutes).
|
||||
*
|
||||
* <p>Un second recul pendant la fenêtre, un changement de milieu (eau, véhicule, vol…) ou toute exemption annule la
|
||||
* mesure en cours. Ni sanction ni VL à partir d'un recul isolé.
|
||||
*/
|
||||
public final class Velocite {
|
||||
|
||||
/** Recul vanilla : distance parcourue en 6 ticks / force (frottement 0,91 en l'air : somme des 6 termes ~ 4,8). */
|
||||
public static final double DISTANCE_PAR_FORCE = 4.5;
|
||||
public static final int HISTORIQUE = 6;
|
||||
public static final long VALIDITE_MS = 120_000;
|
||||
|
||||
private boolean actif;
|
||||
private boolean ambigu;
|
||||
private long debutMs;
|
||||
private double dirX, dirZ, force, parcouru;
|
||||
/** {instant (ms), 1 si le recul est absent}. */
|
||||
private final ArrayDeque<long[]> resultats = new ArrayDeque<>();
|
||||
|
||||
/**
|
||||
* Le serveur vient d'appliquer un recul.
|
||||
*
|
||||
* @param dirX,dirZ direction du déplacement attendu (vecteur unitaire horizontal)
|
||||
* @param force force effective (après résistance au recul)
|
||||
*/
|
||||
public void recul(long nowMs, double dirX, double dirZ, double force, GardeConfig cfg) {
|
||||
if (force < cfg.velociteForceMin) return;
|
||||
double norme = Math.hypot(dirX, dirZ);
|
||||
if (norme < 1e-6) return;
|
||||
if (actif) {
|
||||
ambigu = true; // deuxième recul dans la fenêtre : la mesure ne veut plus rien dire
|
||||
return;
|
||||
}
|
||||
actif = true;
|
||||
ambigu = false;
|
||||
debutMs = nowMs;
|
||||
this.dirX = dirX / norme;
|
||||
this.dirZ = dirZ / norme;
|
||||
this.force = force;
|
||||
parcouru = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Un paquet de mouvement accepté.
|
||||
*
|
||||
* @param neutre exemption ou milieu qui rend la mesure invalide : la mesure en cours est abandonnée
|
||||
* @return points d'infraction (0 si rien)
|
||||
*/
|
||||
public double mouvement(long nowMs, double dx, double dz, boolean neutre, GardeConfig cfg) {
|
||||
if (!actif) return 0;
|
||||
if (neutre) {
|
||||
actif = false;
|
||||
return 0;
|
||||
}
|
||||
parcouru += dx * dirX + dz * dirZ;
|
||||
if (nowMs - debutMs < cfg.velociteFenetreTicks * 50L) return 0;
|
||||
actif = false;
|
||||
if (ambigu) return 0;
|
||||
boolean absent = parcouru < cfg.velociteRapportMin * DISTANCE_PAR_FORCE * force;
|
||||
resultats.addLast(new long[] {nowMs, absent ? 1 : 0});
|
||||
while (resultats.size() > HISTORIQUE || (!resultats.isEmpty() && nowMs - resultats.peekFirst()[0] > VALIDITE_MS)) {
|
||||
resultats.removeFirst();
|
||||
}
|
||||
if (!absent) return 0;
|
||||
int n = 0;
|
||||
for (long[] r : resultats) n += (int) r[1];
|
||||
return n >= cfg.velociteSerieMin ? 2.0 : 0;
|
||||
}
|
||||
|
||||
public void vider() {
|
||||
actif = false;
|
||||
resultats.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** 0.4.0 : contrôles elytres (Elytra Hack), velocite (Anti Knockback / Anti Push), auto-totem, et bateau. */
|
||||
class NouveauxControlesTest {
|
||||
|
||||
private GardeConfig cfg;
|
||||
private Moteur moteur;
|
||||
private final UUID j = UUID.randomUUID();
|
||||
private long now;
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
cfg = new GardeConfig();
|
||||
moteur = new Moteur(cfg);
|
||||
now = 1_000_000;
|
||||
}
|
||||
|
||||
@Test
|
||||
void modesParDefautTousEnObserve() {
|
||||
for (Controle c : List.of(Controle.ELYTRES, Controle.VELOCITE, Controle.AUTO_TOTEM)) {
|
||||
assertEquals(Mode.OBSERVE, cfg.mode(c), c.id());
|
||||
assertEquals(2, c.fiabilite(), c.id() + " : sujet aux faux positifs, plafond 15 dans le score");
|
||||
}
|
||||
}
|
||||
|
||||
// --- Elytres ---
|
||||
|
||||
private double plane(EtatJoueur etat, double dxz, double dy, int ticks) {
|
||||
now += 50L * ticks;
|
||||
EtatMouvement m = new EtatMouvement(dxz, dy, ticks, false, false, false, false, false, 0, 0, false, false);
|
||||
return moteur.mouvement(j, now, etat, m).stream().filter(v -> v.controle() == Controle.ELYTRES)
|
||||
.mapToDouble(Verdict::points).sum();
|
||||
}
|
||||
|
||||
private static EtatJoueur enPlane() {
|
||||
return EtatJoueur.builder().elytres(true).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
void elytresMonteeSansPerteDeVitesseEstVue_VanillaFly() {
|
||||
double total = 0;
|
||||
for (int i = 0; i < 40; i++) total += plane(enPlane(), 1.0, 0.4, 1); // monte à vitesse constante
|
||||
assertTrue(total > 0);
|
||||
assertEquals(Mode.OBSERVE, moteur.config().mode(Controle.ELYTRES));
|
||||
}
|
||||
|
||||
@Test
|
||||
void elytresPlaneImmobileEstVu() {
|
||||
double total = 0;
|
||||
for (int i = 0; i < 40; i++) total += plane(enPlane(), 0.02, 0.0, 1);
|
||||
assertTrue(total > 0, "immobile en plané sans chuter : impossible en vanilla");
|
||||
}
|
||||
|
||||
@Test
|
||||
void elytresVraiPlaneEtMonteeAvecPerteDeVitesseSontNormaux() {
|
||||
double total = 0;
|
||||
double v = 2.0;
|
||||
for (int i = 0; i < 25; i++) { // piqué puis cabré : la vitesse se transforme en altitude
|
||||
total += plane(enPlane(), v, -0.5, 1);
|
||||
v *= 0.99;
|
||||
}
|
||||
for (int i = 0; i < 30; i++) {
|
||||
total += plane(enPlane(), v, 0.35, 1);
|
||||
v *= 0.93; // la montée coûte de la vitesse
|
||||
}
|
||||
for (int i = 0; i < 40; i++) total += plane(enPlane(), 1.0, -0.2, 1); // plané descendant
|
||||
assertEquals(0, total);
|
||||
}
|
||||
|
||||
@Test
|
||||
void elytresApresUneFuseeRienNeCompte() {
|
||||
EtatJoueur fusee = EtatJoueur.builder().elytres(true).propulsionRecente(true).build();
|
||||
double total = 0;
|
||||
for (int i = 0; i < 60; i++) total += plane(fusee, 1.2, 0.4, 1);
|
||||
assertEquals(0, total);
|
||||
// la fusée finie, la montée n'est plus expliquée : le compteur repart de zéro (20 ticks)
|
||||
for (int i = 0; i < 15; i++) assertEquals(0, plane(enPlane(), 1.2, 0.4, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void elytresAutreExemptionOuMilieuSpecialEcarteLeControle() {
|
||||
EtatJoueur recul = EtatJoueur.builder().elytres(true).ticksDepuisRecul(0).build();
|
||||
double total = 0;
|
||||
for (int i = 0; i < 60; i++) total += plane(recul, 1.0, 0.4, 1);
|
||||
assertEquals(0, total, "plané + recul : plusieurs raisons, contrôle écarté");
|
||||
for (int i = 0; i < 60; i++) {
|
||||
now += 50;
|
||||
EtatMouvement milieu = new EtatMouvement(1.0, 0.4, 1, false, false, false, false, false, 0, 0, true, false);
|
||||
assertTrue(moteur.mouvement(j, now, enPlane(), milieu).isEmpty(), "courant d'air / bulles / eau");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void elytresPaquetsADeuxTicksEtRafalesNeSontPasMesures() {
|
||||
double total = 0;
|
||||
for (int i = 0; i < 40; i++) total += plane(enPlane(), 1.0, 0.4, 0); // 0 tick : neutre
|
||||
assertEquals(0, total);
|
||||
for (int i = 0; i < 40; i++) total += plane(enPlane(), 3.0, 0.8, 5); // trous : neutre aussi
|
||||
assertEquals(0, total);
|
||||
}
|
||||
|
||||
@Test
|
||||
void elytresDesactiveParLeMode() {
|
||||
cfg.mode(Controle.ELYTRES, Mode.OFF);
|
||||
double total = 0;
|
||||
for (int i = 0; i < 60; i++) total += plane(enPlane(), 1.0, 0.4, 1);
|
||||
assertEquals(0, total);
|
||||
}
|
||||
|
||||
@Test
|
||||
void elytresNeSanctionnePasEnObserve() {
|
||||
for (int i = 0; i < 200; i++) {
|
||||
now += 50;
|
||||
EtatMouvement m = new EtatMouvement(1.0, 0.4, 1, false, false, false, false, false, 0, 0, false, false);
|
||||
for (Verdict v : moteur.mouvement(j, now, enPlane(), m)) {
|
||||
assertTrue(v.applicable().ordinal() <= Sanction.ALERTE.ordinal(), v.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Velocite ---
|
||||
|
||||
/** Recul de force 0,4 vers +x ; le joueur se déplace de dx par tick pendant n ticks. */
|
||||
private double recul(double force, double dxParTick, int n, EtatJoueur etat, boolean milieu) {
|
||||
now += 50;
|
||||
moteur.suivi(j);
|
||||
moteur.reculApplique(j, now, 1, 0, force);
|
||||
double pts = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
now += 50;
|
||||
pts += moteur.mesureRecul(j, now, etat, dxParTick, 0, milieu).stream().mapToDouble(Verdict::points).sum();
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
|
||||
@Test
|
||||
void velociteReculVanillaNEstJamaisUneInfraction() {
|
||||
for (int k = 0; k < 10; k++) {
|
||||
// 0,4 de force : 0,4 puis 0,364... environ 1,8 bloc en 6 ticks
|
||||
assertEquals(0, recul(0.4, 0.3, 7, EtatJoueur.normal(), false));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void velociteAntiKnockbackEstVuEnSerieSeulement() {
|
||||
assertEquals(0, recul(0.4, 0.0, 7, EtatJoueur.normal(), false), "1er recul absent : pas de série");
|
||||
assertEquals(0, recul(0.4, 0.0, 7, EtatJoueur.normal(), false), "2e : pas encore");
|
||||
assertTrue(recul(0.4, 0.0, 7, EtatJoueur.normal(), false) > 0, "3e recul absent sur 3 : infraction");
|
||||
}
|
||||
|
||||
@Test
|
||||
void velociteUnMurOuUnContreIsoleNeSuffitPas() {
|
||||
assertEquals(0, recul(0.4, 0.0, 7, EtatJoueur.normal(), false)); // contre un mur
|
||||
assertEquals(0, recul(0.4, 0.3, 7, EtatJoueur.normal(), false)); // recul normal
|
||||
assertEquals(0, recul(0.4, 0.0, 7, EtatJoueur.normal(), false)); // contre un mur encore
|
||||
assertEquals(0, recul(0.4, 0.3, 7, EtatJoueur.normal(), false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void velociteTraceReelleDElytresHonnetesSansInfractionElytres() throws Exception {
|
||||
// trace du 15/10 : plané honnête (fusées comprises, non marquées dans la trace : on ne vérifie que la montée)
|
||||
List<String> lignes = java.nio.file.Files.readAllLines(java.nio.file.Path.of(
|
||||
NouveauxControlesTest.class.getResource("/traces/elytres-2026-10-15.jsonl").toURI()));
|
||||
Rejeu.Resume r = Rejeu.rejouer(lignes, new GardeConfig());
|
||||
System.out.println("ELYTRES-HONNETE infractions=" + r.infractions() + " exemples=" + r.exemples());
|
||||
assertTrue(r.mouvements() > 500);
|
||||
}
|
||||
|
||||
@Test
|
||||
void velociteJoueurQuiContreEnMarchantEnArriereReculeEncore() {
|
||||
// marche à 0,22 bloc par tick dans le sens opposé : recul net 0,4 + ... > 15 % du recul attendu
|
||||
for (int k = 0; k < 6; k++) assertEquals(0, recul(0.9, 0.25, 7, EtatJoueur.normal(), false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void velociteExemptionsEtMilieux() {
|
||||
List<EtatJoueur> etats = List.of(
|
||||
EtatJoueur.builder().creatif(true).build(),
|
||||
EtatJoueur.builder().spectateur(true).build(),
|
||||
EtatJoueur.builder().peutVoler(true).build(),
|
||||
EtatJoueur.builder().elytres(true).build(),
|
||||
EtatJoueur.builder().enVehicule(true).build(),
|
||||
EtatJoueur.builder().riptide(true).build(),
|
||||
EtatJoueur.builder().pocheContraption(true).build(),
|
||||
EtatJoueur.builder().ticksDepuisTeleport(0).build());
|
||||
for (EtatJoueur e : etats) {
|
||||
for (int k = 0; k < 6; k++) assertEquals(0, recul(0.4, 0.0, 7, e, false), e.toString());
|
||||
}
|
||||
for (int k = 0; k < 6; k++) assertEquals(0, recul(0.4, 0.0, 7, EtatJoueur.normal(), true), "eau, échelle…");
|
||||
}
|
||||
|
||||
@Test
|
||||
void velociteDeuxReculsDansLaFenetreOuForceNegligeableAnnulentLaMesure() {
|
||||
for (int k = 0; k < 5; k++) {
|
||||
now += 50;
|
||||
moteur.reculApplique(j, now, 1, 0, 0.4);
|
||||
moteur.reculApplique(j, now + 50, 1, 0, 0.4); // second coup pendant la fenêtre
|
||||
for (int i = 0; i < 7; i++) {
|
||||
now += 50;
|
||||
assertTrue(moteur.mesureRecul(j, now, EtatJoueur.normal(), 0, 0, false).isEmpty());
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < 5; k++) assertEquals(0, recul(0.05, 0.0, 7, EtatJoueur.normal(), false), "force < 0,15");
|
||||
}
|
||||
|
||||
@Test
|
||||
void velociteAnciennesMesuresExpirent() {
|
||||
recul(0.4, 0.0, 7, EtatJoueur.normal(), false);
|
||||
recul(0.4, 0.0, 7, EtatJoueur.normal(), false);
|
||||
now += Velocite.VALIDITE_MS + 1000;
|
||||
assertEquals(0, recul(0.4, 0.0, 7, EtatJoueur.normal(), false), "les deux premiers ont plus de 2 minutes");
|
||||
}
|
||||
|
||||
// --- Auto-totem ---
|
||||
|
||||
private double totem(long delaiMs, int ping, boolean reserve) {
|
||||
Moteur m = new Moteur(cfg);
|
||||
UUID id = UUID.randomUUID();
|
||||
m.suivi(id);
|
||||
long t = 5_000_000;
|
||||
m.totemEclate(id, t, reserve);
|
||||
EtatJoueur e = EtatJoueur.builder().pingMs(ping).build();
|
||||
double pts = 0;
|
||||
for (long d = 50; d <= delaiMs + 200; d += 50) {
|
||||
boolean enMain = d >= delaiMs;
|
||||
pts += m.totemEnMain(id, t + d, e, enMain).stream().mapToDouble(Verdict::points).sum();
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoTotemRemisInstantanementEstVu() {
|
||||
assertTrue(totem(50, 30, false) > 0);
|
||||
assertTrue(totem(100, 30, false) > 0, "100 ms < 150 + 30");
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoTotemDelaiHumainNormal() {
|
||||
assertEquals(0, totem(300, 30, false));
|
||||
assertEquals(0, totem(250, 50, false));
|
||||
assertEquals(0, totem(2000, 30, false), "totem remis bien plus tard");
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoTotemLePingNEntreQueBorne() {
|
||||
assertEquals(0, totem(250, 100, false), "250 >= 150 + 100");
|
||||
// ping annoncé de 5 s : seulement 200 ms de marge au plus (150 + 200 = 350)
|
||||
assertTrue(totem(300, 5000, false) > 0);
|
||||
assertEquals(0, totem(400, 5000, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoTotemTotemDeReserveEnMainAnnuleLaMesure() {
|
||||
assertEquals(0, totem(50, 30, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoTotemAucunTotemRemisOuTropTardNeCompteRien() {
|
||||
Moteur m = new Moteur(cfg);
|
||||
UUID id = UUID.randomUUID();
|
||||
m.suivi(id);
|
||||
m.totemEclate(id, 1000, false);
|
||||
EtatJoueur e = EtatJoueur.normal();
|
||||
assertTrue(m.totemEnMain(id, 1050, e, false).isEmpty());
|
||||
assertTrue(m.totemEnMain(id, 1000 + AutoTotem.EXPIRATION_MS + 50, e, true).isEmpty(), "mesure expirée");
|
||||
// un totem ramassé bien après, sans nouvel éclatement : rien
|
||||
assertTrue(m.totemEnMain(id, 1000 + AutoTotem.EXPIRATION_MS + 100, e, true).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoTotemMemeTickQueLEclatementNeCompteRien() {
|
||||
Moteur m = new Moteur(cfg);
|
||||
UUID id = UUID.randomUUID();
|
||||
m.suivi(id);
|
||||
m.totemEclate(id, 1000, false);
|
||||
assertTrue(m.totemEnMain(id, 1000, EtatJoueur.normal(), true).isEmpty(), "totem encore compté dans la main");
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoTotemOffEtObserve() {
|
||||
cfg.mode(Controle.AUTO_TOTEM, Mode.OFF);
|
||||
assertEquals(0, totem(50, 30, false));
|
||||
}
|
||||
|
||||
// --- Bateau (Boat Hack : friction 0,99) ---
|
||||
|
||||
private static EtatVehicule bateau(double dxz, boolean glace) {
|
||||
return new EtatVehicule(EtatVehicule.Type.BATEAU, dxz, 0, 1, false, true, glace, 0, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void bateauVanillaSurEauNEstJamaisVu() {
|
||||
VehiculeMouvement v = new VehiculeMouvement();
|
||||
double pts = 0;
|
||||
for (int i = 0; i < 400; i++) pts += v.vitesse(bateau(0.40, false), 1.0, 1.5);
|
||||
assertEquals(0, pts);
|
||||
}
|
||||
|
||||
@Test
|
||||
void bateauSurGlaceBleueVanillaNEstJamaisVu() {
|
||||
VehiculeMouvement v = new VehiculeMouvement();
|
||||
double pts = 0;
|
||||
for (int i = 0; i < 400; i++) pts += v.vitesse(bateau(3.6, true), 1.0, 1.5);
|
||||
assertEquals(0, pts);
|
||||
}
|
||||
|
||||
@Test
|
||||
void bateauFriction099EstVuEnQuelquesTicks() {
|
||||
VehiculeMouvement v = new VehiculeMouvement();
|
||||
int premier = -1;
|
||||
for (int i = 0; i < 60 && premier < 0; i++) {
|
||||
// boat hack : l'eau garde 99 % de la vitesse, l'accélération 0,04 par tick s'accumule vers 4 blocs par tick
|
||||
double dxz = Math.min(4.0, 0.4 + 0.04 * i / 0.01 * 0.1);
|
||||
if (v.vitesse(bateau(dxz, false), 1.0, 1.5) > 0) premier = i;
|
||||
}
|
||||
assertTrue(premier >= 0 && premier < 40, "premier point au tick " + premier);
|
||||
}
|
||||
|
||||
@Test
|
||||
void bateauLegerementTropRapideSeVoitAuBoutDeQuelquesSecondes() {
|
||||
// 0,479 bloc/tick (valeur du journal du 23/10) : 0,03 au-dessus de la borne de 0,45, il faut du temps
|
||||
VehiculeMouvement v = new VehiculeMouvement();
|
||||
double pts = 0;
|
||||
for (int i = 0; i < 20; i++) pts += v.vitesse(bateau(0.479, false), 1.0, 1.5);
|
||||
assertEquals(0, pts, "20 ticks à 0,479 : 0,6 bloc d'excès cumulé, sous le seuil de 1,5");
|
||||
for (int i = 0; i < 100; i++) pts += v.vitesse(bateau(0.479, false), 1.0, 1.5);
|
||||
assertTrue(pts > 0, "soutenu 6 s, cela compte");
|
||||
}
|
||||
|
||||
@Test
|
||||
void controlesNouveauxPrisEnCompteParLeScoreDeSuspicion() {
|
||||
// auto-totem seul ne rend jamais suspect (plafond 15) ; les trois ensemble restent sous 50
|
||||
Suspicion s = new Suspicion(cfg);
|
||||
s.noter(Controle.AUTO_TOTEM, 99, false, 0);
|
||||
s.noter(Controle.VELOCITE, 99, false, 0);
|
||||
s.noter(Controle.ELYTRES, 99, false, 0);
|
||||
assertEquals(45, s.score(0), 1e-9);
|
||||
assertFalse(s.niveau(0) == Suspicion.Niveau.SUSPECT);
|
||||
}
|
||||
}
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur