GastinelGarde : anti-crash entites (exploit minecart), contraptions, portee/hitbox, phase 2
- Anti-crash : plafond de vitesse projectiles/vehicules, suppression hors bordure, anti-empilement des minecarts (exploit Minecart Velocity du 16/10). - Detection des contraptions Create/Aeronautics et des vaisseaux Sable. - Controles portee et hitbox, angle killaura differe, no-fall/vitesse/vol. - ENFORCE disponible pour tous les controles, OBSERVE par defaut. - Config proposee, 180 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
d0c001d1e2
révision
b5e53a4d85
24 fichiers modifiés
+2076
-23
Aucun fichier ne correspond à votre recherche
@@ -19,4 +19,12 @@ class MixinsAppliquesTest {
|
||||
// Force le chargement complet (liaison) de la classe transformée.
|
||||
c.getDeclaredMethods();
|
||||
}
|
||||
|
||||
@Test
|
||||
void leMixinDesMinecartsSApplique() throws Exception {
|
||||
// MinecartPushMixin (16/10) : push(Entity) doit exister avec ce descripteur, sinon erreur ici.
|
||||
Class<?> c = Class.forName("net.minecraft.world.entity.vehicle.AbstractMinecart", false, getClass().getClassLoader());
|
||||
assertNotNull(c);
|
||||
c.getDeclaredMethods();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
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 com.gastinelgarde.core.AntiCrashEntites.Action;
|
||||
import com.gastinelgarde.core.AntiCrashEntites.Bordure;
|
||||
import com.gastinelgarde.core.AntiCrashEntites.Decision;
|
||||
import com.gastinelgarde.core.AntiCrashEntites.Motif;
|
||||
import com.gastinelgarde.core.AntiCrashEntites.Reglages;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Incident du 16/10/2026 : œuf à ~7e53 blocs/tick, génération de chunks à Z ≈ 2^31, serveur planté. */
|
||||
class AntiCrashEntitesTest {
|
||||
|
||||
private final Reglages r = new Reglages();
|
||||
private final Bordure b = Bordure.VANILLA;
|
||||
|
||||
private Decision eval(double x, double y, double z, double vx, double vy, double vz, boolean protege) {
|
||||
return AntiCrashEntites.evaluer(r, b, x, y, z, vx, vy, vz, protege);
|
||||
}
|
||||
|
||||
@Test
|
||||
void lesVitessesVanillaPassentSansRien() {
|
||||
assertEquals(Action.RIEN, eval(3483, 108, -2412, 0, 0, 1.5, false).action()); // œuf / perle
|
||||
assertEquals(Action.RIEN, eval(3483, 108, -2412, 0.4, -0.1, 3.15, false).action()); // flèche d'arbalète
|
||||
assertEquals(Action.RIEN, eval(0, 64, 0, 2.0, 0, 0, false).action()); // bateau glace bleue
|
||||
assertEquals(Action.RIEN, eval(0, 64, 0, 60, 20, 0, false).action()); // canon à TNT
|
||||
assertEquals(Action.RIEN, eval(0, 64, 0, 0, 0, 0, false).action());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lesOeufsDeLIncidentSontSupprimes() {
|
||||
// Valeurs relevées dans latest.log (AABB de Sable) : 2,03e6 puis 1,5e7, 3,7e9, 5,2e8, 7,1e53 blocs/tick.
|
||||
for (double vz : new double[] {2.03e6, 1.5e7, 3.67e9, 5.2e8, 7.1e53}) {
|
||||
Decision d = eval(3483, 108, -2412, 0, 0, vz, false);
|
||||
assertEquals(Action.SUPPRIMER, d.action(), "vz=" + vz);
|
||||
assertEquals(Motif.VITESSE_EXTREME, d.motif());
|
||||
}
|
||||
// La commande de reproduction : /summon egg ~ ~ ~ {Motion:[0d,0d,1.0e8d]}
|
||||
assertEquals(Action.SUPPRIMER, eval(0, 80, 0, 0, 0, 1.0e8, false).action());
|
||||
}
|
||||
|
||||
@Test
|
||||
void auDessusDuPlafondLaVitesseEstRameneeSansChangerDeDirection() {
|
||||
Decision d = eval(0, 64, 0, 300, 0, 400, false); // 500 b/t : entre 100 et 1 000
|
||||
assertEquals(Action.PLAFONNER, d.action());
|
||||
assertEquals(Motif.VITESSE_EXCESSIVE, d.motif());
|
||||
assertEquals(60, d.vx(), 1e-9);
|
||||
assertEquals(80, d.vz(), 1e-9);
|
||||
assertEquals(100, Math.sqrt(d.vx() * d.vx() + d.vy() * d.vy() + d.vz() * d.vz()), 1e-9);
|
||||
assertEquals(500, d.vitesse(), 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void nanEtInfiniSontSupprimes() {
|
||||
assertEquals(Motif.VITESSE_NON_FINIE, eval(0, 64, 0, Double.NaN, 0, 0, false).motif());
|
||||
assertEquals(Action.SUPPRIMER, eval(0, 64, 0, 0, Double.POSITIVE_INFINITY, 0, false).action());
|
||||
assertEquals(Action.SUPPRIMER, eval(0, 64, 0, 0, 0, Double.NEGATIVE_INFINITY, false).action());
|
||||
// Composantes finies dont la norme déborde (1e200² = infini).
|
||||
assertEquals(Motif.VITESSE_NON_FINIE, eval(0, 64, 0, 1e200, 1e200, 0, false).motif());
|
||||
assertEquals(Motif.POSITION_NON_FINIE, eval(Double.NaN, 64, 0, 0, 0, 0, false).motif());
|
||||
assertEquals(Action.SUPPRIMER, eval(0, Double.POSITIVE_INFINITY, 0, 0, 0, 0, false).action());
|
||||
}
|
||||
|
||||
@Test
|
||||
void horsBordureOuTrajectoireHorsBordureSupprimee() {
|
||||
// Le chunk qui a planté : (207, 134217720) → Z ≈ 2 147 483 520.
|
||||
assertEquals(Motif.HORS_BORDURE, eval(3312, 108, 2_147_483_520.0, 0, 0, 0, false).motif());
|
||||
assertEquals(Action.SUPPRIMER, eval(29_999_984 + 65, 64, 0, 0, 0, 0, false).action());
|
||||
assertEquals(Action.RIEN, eval(29_999_984 + 10, 64, 0, 0, 0, 0, false).action()); // dans la marge (et sous 30 000 000)
|
||||
assertEquals(Action.SUPPRIMER, eval(0, 25_000_000, 0, 0, 0, 0, false).action()); // limite verticale
|
||||
// Dans la bordure mais le rayon de ce tick sort de bordure + marge.
|
||||
Decision d = eval(29_999_950, 64, 0, 99, 0, 0, false);
|
||||
assertEquals(Motif.TRAJECTOIRE_HORS_BORDURE, d.motif());
|
||||
assertEquals(Action.SUPPRIMER, d.action());
|
||||
// Après plafonnement aussi : 500 b/t ramené à 100, depuis 29 999 950 → 30 000 050 > bordure + 64.
|
||||
assertEquals(Motif.TRAJECTOIRE_HORS_BORDURE, eval(29_999_950, 64, 0, 500, 0, 0, false).motif());
|
||||
}
|
||||
|
||||
@Test
|
||||
void bordureReduiteEtMargeConfigurable() {
|
||||
Bordure petite = new Bordure(-5000, -5000, 5000, 5000);
|
||||
assertEquals(Action.SUPPRIMER, AntiCrashEntites.evaluer(r, petite, 5100, 64, 0, 0, 0, 0, false).action());
|
||||
r.margeBordure = 200;
|
||||
assertEquals(Action.RIEN, AntiCrashEntites.evaluer(r, petite, 5100, 64, 0, 0, 0, 0, false).action());
|
||||
// Pas de bordure fournie : seules les limites absolues comptent.
|
||||
assertTrue(AntiCrashEntites.dansLimites(null, 0, 29_999_999, 0, 0));
|
||||
assertFalse(AntiCrashEntites.dansLimites(null, 0, 30_000_001, 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void entiteProtegeeJamaisSupprimeeSeulementArretee() {
|
||||
// Contraption Create, entité sur un vaisseau Sable, minecart qui porte un joueur.
|
||||
Decision d = eval(0, 64, 0, 0, 0, 1.0e8, true);
|
||||
assertEquals(Action.ARRETER, d.action());
|
||||
assertEquals(0, d.vz(), 0);
|
||||
assertEquals(Action.ARRETER, eval(0, 64, 2.0e9, 0, 0, 0, true).action());
|
||||
assertEquals(Action.ARRETER, eval(0, 64, 0, Double.NaN, 0, 0, true).action());
|
||||
// Simplement trop rapide : plafonnée comme les autres (pas arrêtée).
|
||||
assertEquals(Action.PLAFONNER, eval(0, 64, 0, 0, 0, 150, true).action());
|
||||
// Un train Create à pleine vitesse (~1-2 b/t) : rien.
|
||||
assertEquals(Action.RIEN, eval(1000, 70, 1000, 1.6, 0, 0.5, true).action());
|
||||
}
|
||||
|
||||
@Test
|
||||
void minecartRapidePuisProjectileLanceDepuisLui() {
|
||||
// Minecart à 1e8 b/t (Motion forcée) : supprimé avant de bouger ; avec un joueur dedans : arrêté.
|
||||
assertEquals(Action.SUPPRIMER, eval(0, 64, 0, 1.0e8, 0, 0, false).action());
|
||||
assertEquals(Action.ARRETER, eval(0, 64, 0, 1.0e8, 0, 0, true).action());
|
||||
// L'œuf hérite de la vitesse connue du lanceur (Projectile.shootFromRotation) : 1,5 + 2e6.
|
||||
assertEquals(Action.SUPPRIMER, eval(0, 65, 0, 2.0e6 + 1.5, 0, 0, false).action());
|
||||
// Héritage modéré (minecart vanilla 0,4 b/t, ou même 8 b/t sur rails modés) : rien.
|
||||
assertEquals(Action.RIEN, eval(0, 65, 0, 8 + 1.5, 0, 0, false).action());
|
||||
}
|
||||
|
||||
@Test
|
||||
void desactivableEtReglable() {
|
||||
r.actif = false;
|
||||
assertEquals(Action.RIEN, eval(0, 64, 0, 0, 0, 1.0e53, false).action());
|
||||
assertEquals(Action.RIEN, AntiCrashEntites.evaluer(null, b, 0, 64, 0, 0, 0, 1.0e53, false).action());
|
||||
r.actif = true;
|
||||
r.vitesseMax = 10;
|
||||
r.facteurSuppression = 1; // tout dépassement supprime
|
||||
assertEquals(Action.SUPPRIMER, eval(0, 64, 0, 11, 0, 0, false).action());
|
||||
assertEquals(Action.RIEN, eval(0, 64, 0, 10, 0, 0, false).action());
|
||||
}
|
||||
|
||||
@Test
|
||||
void limiteurDAlertes() {
|
||||
AntiCrashEntites.LimiteurAlertes l = new AntiCrashEntites.LimiteurAlertes(5, 10_000);
|
||||
for (int i = 0; i < 5; i++) assertTrue(l.autoriser(1000));
|
||||
assertFalse(l.autoriser(1000));
|
||||
assertFalse(l.autoriser(9000));
|
||||
assertEquals(2, l.masqueesDepuis());
|
||||
assertEquals(0, l.masqueesDepuis());
|
||||
assertTrue(l.autoriser(11_000)); // nouvelle fenêtre
|
||||
}
|
||||
|
||||
// --- Empilement de minecarts (précision de Théo, 16/10) ----------------------------------------------------
|
||||
|
||||
/** Poussées vanilla (AbstractMinecart.push, cas non motorisé) dans une pile de n minecarts alignés sur l'axe X. */
|
||||
private static double[] tickPile(double[] v, double plafond) {
|
||||
int n = v.length;
|
||||
for (int a = 0; a < n; a++) {
|
||||
for (int b = 0; b < n; b++) {
|
||||
if (a == b) continue;
|
||||
double d0 = (b > a ? 1 : -1) * 0.05; // direction normalisée × 0,1 × 0,5 (écart ≥ 1)
|
||||
double moy = (v[a] + v[b]) / 2.0;
|
||||
v[a] = v[a] * 0.2 + (moy - d0);
|
||||
v[b] = v[b] * 0.2 + (moy + d0);
|
||||
if (plafond > 0) {
|
||||
double[] pa = AntiCrashEntites.plafonner(v[a], 0, 0, plafond);
|
||||
if (pa != null) v[a] = pa[0];
|
||||
double[] pb = AntiCrashEntites.plafonner(v[b], 0, 0, plafond);
|
||||
if (pb != null) v[b] = pb[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@Test
|
||||
void laPileDeMinecartsDivergeSansParadeEtResteBorneeAvec() {
|
||||
double[] libre = new double[10];
|
||||
libre[0] = 0.1;
|
||||
double max = 0;
|
||||
for (int t = 0; t < 40; t++) {
|
||||
tickPile(libre, 0);
|
||||
for (double x : libre) max = Math.max(max, Math.abs(x));
|
||||
}
|
||||
assertTrue(max > 1e6 || !Double.isFinite(max), "croissance attendue, max=" + max);
|
||||
|
||||
double[] borne = new double[10];
|
||||
borne[0] = 0.1;
|
||||
for (int t = 0; t < 40; t++) tickPile(borne, r.vitesseMaxMinecart);
|
||||
for (double x : borne) assertTrue(Math.abs(x) <= r.vitesseMaxMinecart + 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void plafondMinecartEtPlafondProjectile() {
|
||||
// Minecart à 50 b/t : ramené à 3 (plafond propre), un bateau au même 50 b/t passe (plafond 100).
|
||||
Decision m = AntiCrashEntites.evaluer(r, b, 0, 64, 0, 50, 0, 0, false, r.vitesseMaxMinecart);
|
||||
assertEquals(Action.PLAFONNER, m.action());
|
||||
assertEquals(3.0, m.vx(), 1e-9);
|
||||
assertEquals(Action.RIEN, eval(0, 64, 0, 50, 0, 0, false).action());
|
||||
// Minecart à pleine vitesse vanilla (2,0 au plus après moveAlongTrack) : rien.
|
||||
assertEquals(Action.RIEN, AntiCrashEntites.evaluer(r, b, 0, 64, 0, 2.0, 0, 0, false, r.vitesseMaxMinecart).action());
|
||||
// Minecart avec un joueur à 1e9 : arrêté, jamais supprimé.
|
||||
assertEquals(Action.ARRETER, AntiCrashEntites.evaluer(r, b, 0, 64, 0, 1e9, 0, 0, true, r.vitesseMaxMinecart).action());
|
||||
// Œuf lancé depuis un minecart : vitesse propre 1,5 + héritée ; au-delà de 100 ramené à 100, au-delà de 1 000 supprimé.
|
||||
assertEquals(Action.PLAFONNER, eval(0, 65, 0, 1.5 + 400, 0, 0, false).action());
|
||||
assertEquals(Action.SUPPRIMER, eval(0, 65, 0, 1.5 + 2.1e9, 0, 0, false).action());
|
||||
// Le plafond propre ne peut pas dépasser vitesseMax.
|
||||
r.vitesseMaxMinecart = 500;
|
||||
assertEquals(100.0, AntiCrashEntites.evaluer(r, b, 0, 64, 0, 300, 0, 0, false, r.vitesseMaxMinecart).vx(), 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void plafonnerVecteurEtEmpilement() {
|
||||
assertEquals(null, AntiCrashEntites.plafonner(1, 1, 1, 3));
|
||||
double[] p = AntiCrashEntites.plafonner(0, 30, 40, 5);
|
||||
assertEquals(3.0, p[1], 1e-9);
|
||||
assertEquals(4.0, p[2], 1e-9);
|
||||
assertEquals(0.0, AntiCrashEntites.plafonner(Double.NaN, 0, 0, 3)[0], 0);
|
||||
assertEquals(0.0, AntiCrashEntites.plafonner(1e200, 1e200, 0, 3)[0], 0);
|
||||
assertFalse(AntiCrashEntites.empilementExcessif(4, r));
|
||||
assertTrue(AntiCrashEntites.empilementExcessif(5, r));
|
||||
assertTrue(AntiCrashEntites.empilementExcessif(15, r));
|
||||
r.empilementMax = 0; // désactivé
|
||||
assertFalse(AntiCrashEntites.empilementExcessif(15, r));
|
||||
r.empilementMax = 4;
|
||||
r.actif = false;
|
||||
assertFalse(AntiCrashEntites.empilementExcessif(15, r));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
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;
|
||||
|
||||
/** 15/10/2026 : classes de contraption, portée / hitbox, contrôles 6 à 8 en observation seulement. */
|
||||
class Garde1015Test {
|
||||
|
||||
private GardeConfig cfg;
|
||||
private Moteur moteur;
|
||||
private final UUID joueur = UUID.randomUUID();
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
cfg = new GardeConfig();
|
||||
moteur = new Moteur(cfg);
|
||||
}
|
||||
|
||||
// --- Contraptions (chaînes de classes relevées par javap dans les jars du serveur) ----------------------
|
||||
|
||||
private static final List<String> DEFAUT = DetectionContraption.motifs(DetectionContraption.MOTIFS_DEFAUT);
|
||||
private static final String ABSTRAITE = "com.simibubi.create.content.contraptions.AbstractContraptionEntity";
|
||||
|
||||
@Test
|
||||
void contraptionsCreateEtAeronauticsReconnues() {
|
||||
assertTrue(DetectionContraption.correspond(List.of(
|
||||
"dev.eriksonn.aeronautics.content.blocks.propeller.bearing.contraption.PropellerBearingContraptionEntity",
|
||||
"com.simibubi.create.content.contraptions.ControlledContraptionEntity", ABSTRAITE), DEFAUT));
|
||||
assertTrue(DetectionContraption.correspond(List.of(
|
||||
"dev.ryanhcode.offroad.content.entities.BoreheadContraptionEntity",
|
||||
"com.simibubi.create.content.contraptions.ControlledContraptionEntity", ABSTRAITE), DEFAUT));
|
||||
// Les trains : hors du paquet « contraptions », manqués par l'ancien réglage par préfixe.
|
||||
assertTrue(DetectionContraption.correspond(List.of(
|
||||
"com.simibubi.create.content.trains.entity.CarriageContraptionEntity",
|
||||
"com.simibubi.create.content.contraptions.OrientedContraptionEntity", ABSTRAITE), DEFAUT));
|
||||
assertTrue(DetectionContraption.correspond(List.of(
|
||||
"com.simibubi.create.content.contraptions.gantry.GantryContraptionEntity", ABSTRAITE), DEFAUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
void entitesImmobilesNonReconnues() {
|
||||
assertFalse(DetectionContraption.correspond(List.of("com.simibubi.create.content.contraptions.glue.SuperGlueEntity"), DEFAUT));
|
||||
assertFalse(DetectionContraption.correspond(List.of("com.simibubi.create.content.contraptions.actors.seat.SeatEntity"), DEFAUT));
|
||||
assertFalse(DetectionContraption.correspond(List.of("dev.eriksonn.aeronautics.content.blocks.hot_air.gust.GustEntity"), DEFAUT));
|
||||
assertFalse(DetectionContraption.correspond(List.of("dev.simulated_team.simulated.content.entities.honey_glue.HoneyGlueEntity"), DEFAUT));
|
||||
assertFalse(DetectionContraption.correspond(List.of("net.minecraft.world.entity.animal.Pig"), DEFAUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ancienReglageParPaquetToujoursCompris() {
|
||||
List<String> ancien = DetectionContraption.motifs("com.simibubi.create.content.contraptions, dev.ryanhcode, x.y.*");
|
||||
assertTrue(DetectionContraption.correspond(List.of("com.simibubi.create.content.contraptions.glue.SuperGlueEntity"), ancien));
|
||||
assertTrue(DetectionContraption.correspond(List.of("dev.ryanhcode.offroad.content.entities.BoreheadContraptionEntity"), ancien));
|
||||
assertTrue(DetectionContraption.correspond(List.of("x.y.Truc"), ancien));
|
||||
assertFalse(DetectionContraption.correspond(List.of("x.yz.Truc"), ancien));
|
||||
// Pas de fausse correspondance sur un paquet voisin
|
||||
assertFalse(DetectionContraption.correspond(List.of("dev.ryanhcodeX.Truc"), ancien));
|
||||
// Un nom de classe exact couvre ses classes internes, pas un nom plus long
|
||||
assertTrue(DetectionContraption.correspond(List.of(ABSTRAITE + "$Interne"), DEFAUT));
|
||||
assertFalse(DetectionContraption.correspond(List.of(ABSTRAITE + "Bis"), DEFAUT));
|
||||
assertTrue(DetectionContraption.motifs(" , ").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void graceApresContraption() {
|
||||
assertFalse(DetectionContraption.dansLaGrace(100, Integer.MIN_VALUE, 40));
|
||||
assertTrue(DetectionContraption.dansLaGrace(100, 60, 40));
|
||||
assertFalse(DetectionContraption.dansLaGrace(101, 60, 40));
|
||||
assertFalse(DetectionContraption.dansLaGrace(10, 60, 40)); // compteur de ticks revenu en arrière
|
||||
}
|
||||
|
||||
// --- Géométrie portée / hitbox -----------------------------------------------------------------------
|
||||
|
||||
/** Boîte de joueur (0,6 × 1,8) centrée en (x, 0, z). */
|
||||
private static double[] joueurEn(double x, double z) {
|
||||
return new double[] {x - 0.3, 0, z - 0.3, x + 0.3, 1.8, z + 0.3};
|
||||
}
|
||||
|
||||
private static double distance(double[] b) {
|
||||
return PorteeHitbox.distanceOeilBoite(0, 1.62, 0, b[0], b[1], b[2], b[3], b[4], b[5]);
|
||||
}
|
||||
|
||||
private static double manque(double lx, double ly, double lz, double longueur, double[] b) {
|
||||
return PorteeHitbox.manqueRegard(0, 1.62, 0, lx, ly, lz, longueur, b[0], b[1], b[2], b[3], b[4], b[5]);
|
||||
}
|
||||
|
||||
@Test
|
||||
void distanceAuPointLePlusProche() {
|
||||
assertEquals(3.2, distance(joueurEn(3.5, 0)), 1e-9);
|
||||
assertEquals(0.0, distance(new double[] {-1, 0, -1, 1, 2, 1}), 1e-9); // œil dedans
|
||||
assertEquals(Math.sqrt(2) * 2.7, distance(joueurEn(3, 3)), 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void manqueDuRegard() {
|
||||
double[] b = joueurEn(2.3, 0); // boîte x 2,0 à 2,6
|
||||
assertEquals(0.0, manque(1, 0, 0, 4, b), 1e-9); // regard droit dessus
|
||||
assertEquals(0.0, manque(1, -0.1, 0.05, 4, b), 1e-9); // un peu de biais, touche encore
|
||||
// Regard le long de z : il faut gonfler la boîte de 2,0 en x pour toucher.
|
||||
assertEquals(2.0, manque(0, 0, 1, 4, b), 1e-6);
|
||||
// Regard droit dessus mais trop court : il manque 0,5 bloc au bout.
|
||||
assertEquals(0.5, manque(1, 0, 0, 1.5, b), 1e-6);
|
||||
// Regard à l'opposé : il faut gonfler jusqu'à englober l'œil (2,0).
|
||||
assertEquals(2.0, manque(-1, 0, 0, 4, b), 1e-6);
|
||||
// Très loin et à l'opposé : plafonné.
|
||||
assertEquals(PorteeHitbox.MANQUE_MAX, manque(-1, 0, 0, 4, joueurEn(20.3, 0)), 1e-9);
|
||||
// Regard nul : rien à mesurer
|
||||
assertEquals(0.0, manque(0, 0, 0, 4, b), 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void hitboxGonfleeDeTroisDixiemes() {
|
||||
// Cible à 2,5 blocs, regard qui passe 0,3 bloc à côté de la boîte (cas d'un cheat hitbox +0,3) :
|
||||
// le rayon le long de x à z = 0,6 manque une boîte z -0,3..0,3 de 0,3.
|
||||
double[] b = joueurEn(2.8, 0);
|
||||
double m = PorteeHitbox.manqueRegard(0, 1.62, 0.6, 1, 0, 0, 4, b[0], b[1], b[2], b[3], b[4], b[5]);
|
||||
assertEquals(0.3, m, 1e-6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void tolerancesEtPoints() {
|
||||
assertEquals(0.0, PorteeHitbox.toleranceLatence(0, cfg), 1e-9);
|
||||
assertEquals(0.84, PorteeHitbox.toleranceLatence(0.28, cfg), 1e-9); // sprint × 3 ticks
|
||||
assertEquals(1.0, PorteeHitbox.toleranceLatence(5, cfg), 1e-9); // plafond
|
||||
assertEquals(3.3, PorteeHitbox.seuilPortee(3.0, 0, cfg, 1.0), 1e-9);
|
||||
assertEquals(0.0, PorteeHitbox.pointsPortee(3.3, 3.3), 1e-9);
|
||||
assertEquals(2.0, PorteeHitbox.pointsPortee(3.8, 3.3), 1e-9);
|
||||
assertEquals(4.0, PorteeHitbox.pointsPortee(9, 3.3), 1e-9);
|
||||
assertEquals(0.0, PorteeHitbox.pointsPortee(Double.NaN, 3.3), 1e-9);
|
||||
assertEquals(0.0, PorteeHitbox.pointsHitbox(0.25, 0.25), 1e-9);
|
||||
assertEquals(2.0, PorteeHitbox.pointsHitbox(0.55, 0.25), 1e-9);
|
||||
assertEquals(3.0, PorteeHitbox.pointsHitbox(4, 0.25), 1e-9);
|
||||
}
|
||||
|
||||
// --- Moteur : portée / hitbox ------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void coupHonneteSansVerdict() {
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, EtatJoueur.normal(), 2.9, 0.0, 3.0, 0.0).isEmpty());
|
||||
assertTrue(moteur.porteeHitbox(joueur, 50, EtatJoueur.normal(), 3.25, 0.2, 3.0, 0.0).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void porteeEtHitboxEnObservation() {
|
||||
List<Verdict> v = moteur.porteeHitbox(joueur, 0, EtatJoueur.normal(), 3.7, 0.6, 3.0, 0.0);
|
||||
assertEquals(2, v.size());
|
||||
assertEquals(Controle.PORTEE, v.get(0).controle());
|
||||
assertEquals(Controle.HITBOX, v.get(1).controle());
|
||||
for (Verdict x : v) assertEquals(Mode.OBSERVE, x.mode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cibleRapideToleree() {
|
||||
// Cible qui sprinte (0,28 bloc/tick) : 0,84 bloc de plus sur les deux seuils.
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, EtatJoueur.normal(), 3.9, 0.9, 3.0, 0.28).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exemptionsEtLag() {
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, EtatJoueur.builder().creatif(true).build(), 4.9, 2, 5.0, 0).isEmpty());
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, EtatJoueur.builder().pocheContraption(true).build(), 3.9, 2, 3.0, 0).isEmpty());
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, EtatJoueur.builder().enVehicule(true).build(), 3.9, 2, 3.0, 0).isEmpty());
|
||||
// Serveur à 15 TPS : marges × 1,5 → portée 3,45, hitbox 0,375
|
||||
EtatJoueur lag = EtatJoueur.builder().tps(15).build();
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, lag, 3.4, 0.35, 3.0, 0).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void porteeEtHitboxCoupables() {
|
||||
cfg.mode(Controle.PORTEE, Mode.OFF);
|
||||
cfg.mode(Controle.HITBOX, Mode.OFF);
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, EtatJoueur.normal(), 3.9, 2, 3.0, 0).isEmpty());
|
||||
cfg.mode(Controle.HITBOX, Mode.ENFORCE); // OBSERVE par défaut, ENFORCE possible
|
||||
assertEquals(Mode.ENFORCE, cfg.mode(Controle.HITBOX));
|
||||
List<Verdict> v = moteur.porteeHitbox(joueur, 0, EtatJoueur.normal(), 3.9, 2, 3.0, 0);
|
||||
assertEquals(1, v.size());
|
||||
assertEquals(Controle.HITBOX, v.get(0).controle());
|
||||
}
|
||||
|
||||
// --- Modes : OBSERVE par défaut partout, ENFORCE possible partout (correction du 16/10) -------------
|
||||
|
||||
@Test
|
||||
void enforcePossiblePourTousLesControles() {
|
||||
for (Controle c : Controle.values()) {
|
||||
assertEquals(Mode.OBSERVE, cfg.mode(c), c.id());
|
||||
cfg.mode(c, Mode.ENFORCE);
|
||||
assertEquals(Mode.ENFORCE, cfg.mode(c), c.id());
|
||||
cfg.mode(c, Mode.OFF);
|
||||
assertEquals(Mode.OFF, cfg.mode(c), c.id());
|
||||
}
|
||||
for (Controle c : new Controle[] {Controle.NO_FALL, Controle.VITESSE, Controle.VOL,
|
||||
Controle.PORTEE, Controle.HITBOX}) {
|
||||
assertTrue(c.observeParDefaut(), c.id());
|
||||
}
|
||||
assertFalse(Controle.CADENCE.observeParDefaut());
|
||||
}
|
||||
|
||||
@Test
|
||||
void noFallEnforceCorrigeLeDrapeauAuSol() {
|
||||
cfg.mode(Controle.NO_FALL, Mode.ENFORCE);
|
||||
assertFalse(moteur.auSolPourDegatsDeChute(EtatJoueur.normal(), true, false));
|
||||
assertTrue(moteur.auSolPourDegatsDeChute(EtatJoueur.normal(), true, true));
|
||||
}
|
||||
|
||||
private static EtatMouvement mvt(double dxz, double dy, boolean solClient, boolean solServeur) {
|
||||
return new EtatMouvement(dxz, dy, 1, solClient, solServeur, false, false, false, 0, 0, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triche continue 30 s. En OBSERVE (défaut) : des verdicts, un VL qui dépasse l'expulsion, jamais plus qu'une
|
||||
* alerte. En ENFORCE : la sanction devient applicable (comportement de d0c001d).
|
||||
*/
|
||||
private void triche(Controle attendu, EtatMouvement m, Mode mode) {
|
||||
if (mode == Mode.ENFORCE) cfg.mode(attendu, Mode.ENFORCE);
|
||||
boolean vu = false;
|
||||
double vlMax = 0;
|
||||
Sanction max = Sanction.AUCUNE;
|
||||
for (int i = 0; i < 600; i++) {
|
||||
for (Verdict v : moteur.mouvement(joueur, i * 50L, EtatJoueur.normal(), m)) {
|
||||
if (v.controle() != attendu) continue;
|
||||
assertEquals(mode, v.mode());
|
||||
vu = true;
|
||||
vlMax = Math.max(vlMax, v.vl());
|
||||
if (v.applicable().ordinal() > max.ordinal()) max = v.applicable();
|
||||
}
|
||||
}
|
||||
assertTrue(vu, attendu.id());
|
||||
assertTrue(vlMax >= cfg.seuilExpulsion, attendu.id() + " vl=" + vlMax);
|
||||
if (mode == Mode.OBSERVE) assertTrue(max.ordinal() <= Sanction.ALERTE.ordinal(), attendu.id() + " " + max);
|
||||
else assertTrue(max.ordinal() > Sanction.ALERTE.ordinal(), attendu.id() + " " + max);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noFallJournaliseSansSanctionParDefaut() {
|
||||
triche(Controle.NO_FALL, mvt(0, -0.6, true, false), Mode.OBSERVE);
|
||||
assertTrue(moteur.auSolPourDegatsDeChute(EtatJoueur.normal(), true, false)); // drapeau client gardé
|
||||
}
|
||||
|
||||
@Test
|
||||
void vitesseJournaliseeSansSanctionParDefaut() {
|
||||
triche(Controle.VITESSE, mvt(1.5, 0, true, true), Mode.OBSERVE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void volJournaliseSansSanctionParDefaut() {
|
||||
triche(Controle.VOL, mvt(0, 0.0, false, false), Mode.OBSERVE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noFallVitesseVolSanctionnesEnEnforce() {
|
||||
triche(Controle.VITESSE, mvt(1.5, 0, true, true), Mode.ENFORCE);
|
||||
init();
|
||||
triche(Controle.VOL, mvt(0, 0.0, false, false), Mode.ENFORCE);
|
||||
init();
|
||||
triche(Controle.NO_FALL, mvt(0, -0.6, true, false), Mode.ENFORCE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
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.assertNull;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 16/10/2026 : riptide (délégué par GastinelClaims 1.1.7) avec ENFORCE rétabli, et faux positifs prévisibles de
|
||||
* portée / hitbox (ping, rotation en retard d'un tick, élytres, riptide, téléportation, recul, cible rapide).
|
||||
*/
|
||||
class Garde1016Test {
|
||||
|
||||
private GardeConfig cfg;
|
||||
private Moteur moteur;
|
||||
private final UUID joueur = UUID.randomUUID();
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
cfg = new GardeConfig();
|
||||
moteur = new Moteur(cfg);
|
||||
}
|
||||
|
||||
// --- Riptide ------------------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void riptideReleveLeSeuilVanillaPendantLaVrilleEtDeuxSecondesApres() {
|
||||
RiptideSuivi r = new RiptideSuivi();
|
||||
assertEquals(100f, r.seuil(100f, 0, false), 0f); // jamais de vrille : vanilla
|
||||
r.observer(10, true);
|
||||
assertEquals(RiptideTolerance.SEUIL_RIPTIDE, r.seuil(100f, 10, true), 0f);
|
||||
assertEquals(RiptideTolerance.SEUIL_RIPTIDE, r.seuil(100f, 10 + RiptideTolerance.GRACE_TICKS, false), 0f);
|
||||
assertEquals(100f, r.seuil(100f, 11 + RiptideTolerance.GRACE_TICKS, false), 0f);
|
||||
// Seuil élytres (300) relevé aussi pendant la vrille.
|
||||
assertEquals(RiptideTolerance.SEUIL_RIPTIDE, r.seuil(300f, 10, true), 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
void riptideEnchaineSousLaPluieSansRetourEnArriere() {
|
||||
// Enchaînement de 5 riptides (relâchement toutes les 15 ticks) : le seuil reste relevé sans interruption.
|
||||
RiptideSuivi r = new RiptideSuivi();
|
||||
for (int t = 0; t < 75; t++) {
|
||||
if (t % 15 == 0) assertTrue(r.relache(t, true, 12, true, true));
|
||||
r.observer(t, t % 15 < 8);
|
||||
assertEquals(RiptideTolerance.SEUIL_RIPTIDE, r.seuil(100f, t, t % 15 < 8), 0f, "tick " + t);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void tenirOuChargerTropPeuLeTridentNeReleveRien() {
|
||||
RiptideSuivi r = new RiptideSuivi();
|
||||
assertFalse(r.relache(0, false, 30, true, true)); // pas Impulsion
|
||||
assertFalse(r.relache(0, true, RiptideSuivi.CHARGE_MIN_TICKS - 1, true, true)); // charge trop courte
|
||||
assertFalse(r.relache(0, true, 30, false, false)); // sec, sous un toit
|
||||
assertEquals(100f, r.seuil(100f, 1, false), 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
void riptideExempteLeMouvementMemeEnEnforce() {
|
||||
for (Controle c : Controle.values()) cfg.mode(c, Mode.ENFORCE);
|
||||
EtatJoueur vrille = EtatJoueur.builder().riptide(true).build();
|
||||
EtatMouvement saut = new EtatMouvement(60, 8, 1, false, false, false, false, false, 0, 0, false, false);
|
||||
for (int i = 0; i < 200; i++) {
|
||||
assertTrue(moteur.mouvement(joueur, i * 50L, vrille, saut).isEmpty());
|
||||
}
|
||||
// Atterrissage en vrille : le drapeau « au sol » du client est gardé (pas de dégâts de chute ajoutés).
|
||||
assertTrue(moteur.auSolPourDegatsDeChute(vrille, true, false));
|
||||
// Sans riptide, en ENFORCE, ce même mouvement est sanctionné.
|
||||
Sanction max = Sanction.AUCUNE;
|
||||
for (int i = 0; i < 200; i++) {
|
||||
for (Verdict v : moteur.mouvement(joueur, i * 50L, EtatJoueur.normal(), saut)) {
|
||||
if (v.applicable().ordinal() > max.ordinal()) max = v.applicable();
|
||||
}
|
||||
}
|
||||
assertTrue(max.ordinal() >= Sanction.SETBACK.ordinal(), max.toString());
|
||||
}
|
||||
|
||||
// --- Portée / hitbox : géométrie de test ----------------------------------------------------------------
|
||||
|
||||
/** Cible de 0,6 × 1,8 à 3 blocs devant l'œil (axe +z). */
|
||||
private static final double[] BOITE = {0.0, 0.0, 3.0, 0.6, 1.8, 3.6};
|
||||
private static final double[] OEIL = {0.3, 1.62, 0.0};
|
||||
private static final double[] VERS_CIBLE = {0, 0, 1};
|
||||
private static final double[] A_COTE = {1, 0, 0.2};
|
||||
|
||||
private static boolean contient(List<Verdict> v, Controle c) {
|
||||
return v.stream().anyMatch(x -> x.controle() == c);
|
||||
}
|
||||
|
||||
@Test
|
||||
void regardEnRetardDUnTickPasDeFauxPositif() {
|
||||
// Au coup, le serveur a encore le regard du tick précédent (à côté) ; le paquet suivant vise la cible.
|
||||
assertTrue(moteur.coupPorteeHitbox(joueur, 1000, EtatJoueur.normal(), OEIL, A_COTE, BOITE, 3.0, 0).isEmpty());
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 1000, OEIL, VERS_CIBLE).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void regardAcoteAuCoupEtApresEstSignale() {
|
||||
moteur.coupPorteeHitbox(joueur, 1000, EtatJoueur.normal(), OEIL, A_COTE, BOITE, 3.0, 0);
|
||||
assertTrue(contient(moteur.regardPorteeHitbox(joueur, 1050, OEIL, A_COTE), Controle.HITBOX));
|
||||
}
|
||||
|
||||
@Test
|
||||
void paquetTropTardifNeBlanchitPasLeCoup() {
|
||||
moteur.coupPorteeHitbox(joueur, 1000, EtatJoueur.normal(), OEIL, A_COTE, BOITE, 3.0, 0);
|
||||
// Plus de 2 ticks sans paquet : le regard n'avait pas changé, la mesure du coup reste.
|
||||
assertTrue(contient(moteur.regardPorteeHitbox(joueur, 1000 + 50 * 3, OEIL, VERS_CIBLE), Controle.HITBOX));
|
||||
}
|
||||
|
||||
@Test
|
||||
void coupSuivantTermineLeCoupEnAttente() {
|
||||
moteur.coupPorteeHitbox(joueur, 1000, EtatJoueur.normal(), OEIL, A_COTE, BOITE, 3.0, 0);
|
||||
List<Verdict> v = moteur.coupPorteeHitbox(joueur, 1500, EtatJoueur.normal(), OEIL, VERS_CIBLE, BOITE, 3.0, 0);
|
||||
assertTrue(contient(v, Controle.HITBOX));
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 1500, OEIL, VERS_CIBLE).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void oeilEnRetardSprintPotionGlacePasDeFauxPositif() {
|
||||
// Au coup, l'œil connu du serveur est 0,8 bloc en arrière (sprint-saut sous Vitesse II, glace) :
|
||||
// 3,8 blocs. Le paquet suivant le place à 3,0.
|
||||
double[] oeilAncien = {0.3, 1.62, -0.8};
|
||||
moteur.coupPorteeHitbox(joueur, 1000, EtatJoueur.normal(), oeilAncien, VERS_CIBLE, BOITE, 3.0, 0);
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 1000, OEIL, VERS_CIBLE).isEmpty());
|
||||
// Un vrai coup à 3,8 blocs, sans rapprochement ensuite, reste signalé.
|
||||
moteur.coupPorteeHitbox(joueur, 2000, EtatJoueur.normal(), oeilAncien, VERS_CIBLE, BOITE, 3.0, 0);
|
||||
assertTrue(contient(moteur.regardPorteeHitbox(joueur, 2000, oeilAncien, VERS_CIBLE), Controle.PORTEE));
|
||||
}
|
||||
|
||||
@Test
|
||||
void pingEleveElargitLaToleranceMaisPlafonnee() {
|
||||
assertEquals(0.3, PorteeHitbox.toleranceLatence(0.1, 0, cfg), 1e-9);
|
||||
assertEquals(0.8, PorteeHitbox.toleranceLatence(0.1, 250, cfg), 1e-9);
|
||||
assertEquals(0.9, PorteeHitbox.toleranceLatence(0.1, 5000, cfg), 1e-9); // ping falsifié : borné à 300 ms
|
||||
assertEquals(1.0, PorteeHitbox.toleranceLatence(0.5, 5000, cfg), 1e-9); // plafond total
|
||||
// Cible qui recule à 0,1 bloc/tick, coup à 3,9 : signalé à 0 ms de ping, pas à 250 ms.
|
||||
assertTrue(contient(moteur.porteeHitbox(joueur, 0, EtatJoueur.builder().pingMs(0).build(),
|
||||
3.9, 0, 3.0, 0.1), Controle.PORTEE));
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, EtatJoueur.builder().pingMs(250).build(),
|
||||
3.9, 0, 3.0, 0.1).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void situationsNonMesurees() {
|
||||
for (Controle c : Controle.values()) cfg.mode(c, Mode.ENFORCE);
|
||||
EtatJoueur[] etats = {
|
||||
EtatJoueur.builder().riptide(true).build(), // trident : coup au contact de la vrille
|
||||
EtatJoueur.builder().elytres(true).build(),
|
||||
EtatJoueur.builder().ticksDepuisTeleport(5).build(), // /tpa, réapparition, dimension, connexion
|
||||
EtatJoueur.builder().ticksDepuisRecul(3).build(), // knockback
|
||||
};
|
||||
for (EtatJoueur e : etats) {
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, e, 3.95, 3.0, 3.0, 0).isEmpty(), e.toString());
|
||||
moteur.coupPorteeHitbox(joueur, 0, e, OEIL, A_COTE, BOITE, 3.0, 0);
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 0, OEIL, A_COTE).isEmpty(), e.toString());
|
||||
}
|
||||
// Cible très rapide (élytres, cible repoussée, cible téléportée) : non mesurée.
|
||||
assertEquals("cible-rapide", PorteeHitbox.raisonNonMesure(EtatJoueur.normal(), 1.6, cfg));
|
||||
assertTrue(moteur.porteeHitbox(joueur, 0, EtatJoueur.normal(), 3.95, 3.0, 3.0, 1.6).isEmpty());
|
||||
assertNull(PorteeHitbox.raisonNonMesure(EtatJoueur.normal(), 0.3, cfg));
|
||||
// Après la grâce : de nouveau mesuré.
|
||||
assertFalse(moteur.porteeHitbox(joueur, 0, EtatJoueur.builder().ticksDepuisTeleport(200).build(),
|
||||
3.95, 3.0, 3.0, 0).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void contraptionOuVehiculeDeLAttaquantExempte() {
|
||||
moteur.coupPorteeHitbox(joueur, 0, EtatJoueur.builder().pocheContraption(true).build(), OEIL, A_COTE, BOITE, 3.0, 0);
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 0, OEIL, A_COTE).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void observeParDefautJamaisDeBlocage() {
|
||||
for (int i = 0; i < 40; i++) {
|
||||
moteur.coupPorteeHitbox(joueur, i * 100L, EtatJoueur.normal(), OEIL, A_COTE, BOITE, 3.0, 0);
|
||||
for (Verdict v : moteur.regardPorteeHitbox(joueur, i * 100L, OEIL, A_COTE)) {
|
||||
assertEquals(Mode.OBSERVE, v.mode());
|
||||
assertTrue(v.applicable().ordinal() <= Sanction.ALERTE.ordinal());
|
||||
}
|
||||
}
|
||||
assertFalse(moteur.coupsBloques(joueur, 4000));
|
||||
}
|
||||
|
||||
@Test
|
||||
void enforceBloqueLesCoupsApresSanction() {
|
||||
cfg.mode(Controle.HITBOX, Mode.ENFORCE);
|
||||
long t = 0;
|
||||
while (!moteur.coupsBloques(joueur, t) && t < 10_000) {
|
||||
moteur.coupPorteeHitbox(joueur, t, EtatJoueur.normal(), OEIL, A_COTE, BOITE, 3.0, 0);
|
||||
moteur.regardPorteeHitbox(joueur, t, OEIL, A_COTE);
|
||||
t += 100;
|
||||
}
|
||||
assertTrue(moteur.coupsBloques(joueur, t), "jamais bloqué");
|
||||
assertFalse(moteur.coupsBloques(joueur, t + Moteur.DUREE_BLOCAGE_COUPS_MS + 100));
|
||||
}
|
||||
|
||||
// --- Angle killaura différé (16/10, suite) -----------------------------------------------------------------
|
||||
|
||||
private static final double[] DERRIERE = {0, 0, -1};
|
||||
|
||||
@Test
|
||||
void angleKillauraRegardEnRetardPasDeFauxPositif() {
|
||||
cfg.mode(Controle.KILLAURA_ANGLE, Mode.ENFORCE);
|
||||
// Rotation de 180° pendant le tick : le serveur voit encore l'ancien regard au coup.
|
||||
assertTrue(moteur.coupDiffere(joueur, 1000, EtatJoueur.normal(), OEIL, DERRIERE, BOITE, 3.0, 0, true, true).isEmpty());
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 1000, OEIL, VERS_CIBLE).isEmpty());
|
||||
assertFalse(moteur.coupsBloques(joueur, 1100));
|
||||
}
|
||||
|
||||
@Test
|
||||
void angleKillauraDerriereSignaleEtBloqueEnEnforce() {
|
||||
cfg.mode(Controle.KILLAURA_ANGLE, Mode.ENFORCE);
|
||||
long t = 0;
|
||||
boolean vu = false;
|
||||
while (!moteur.coupsBloques(joueur, t) && t < 10_000) {
|
||||
moteur.coupDiffere(joueur, t, EtatJoueur.normal(), OEIL, DERRIERE, BOITE, 3.0, 0, false, true);
|
||||
for (Verdict v : moteur.regardPorteeHitbox(joueur, t, OEIL, DERRIERE)) {
|
||||
vu |= v.controle() == Controle.KILLAURA_ANGLE;
|
||||
assertFalse(v.controle() == Controle.HITBOX || v.controle() == Controle.PORTEE); // cible sur contraption
|
||||
}
|
||||
t += 100;
|
||||
}
|
||||
assertTrue(vu);
|
||||
assertTrue(moteur.coupsBloques(joueur, t));
|
||||
}
|
||||
|
||||
@Test
|
||||
void angleKillauraPasCompteDeuxFois() {
|
||||
// attaque() reçoit -1 (angle différé) : seul le chemin différé compte l'angle.
|
||||
assertTrue(moteur.attaque(joueur, 0, EtatJoueur.normal(), -1, 1, true).isEmpty());
|
||||
moteur.coupDiffere(joueur, 0, EtatJoueur.normal(), OEIL, DERRIERE, BOITE, 3.0, 0, false, true);
|
||||
long n = moteur.regardPorteeHitbox(joueur, 0, OEIL, DERRIERE).stream()
|
||||
.filter(v -> v.controle() == Controle.KILLAURA_ANGLE).count();
|
||||
assertEquals(1, n);
|
||||
}
|
||||
|
||||
@Test
|
||||
void angleKillauraCoupeOuExempte() {
|
||||
cfg.mode(Controle.KILLAURA_ANGLE, Mode.OFF);
|
||||
moteur.coupDiffere(joueur, 0, EtatJoueur.normal(), OEIL, DERRIERE, BOITE, 3.0, 0, false, true);
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 0, OEIL, DERRIERE).isEmpty());
|
||||
cfg.mode(Controle.KILLAURA_ANGLE, Mode.OBSERVE);
|
||||
moteur.coupDiffere(joueur, 0, EtatJoueur.builder().enVehicule(true).build(), OEIL, DERRIERE, BOITE, 3.0, 0, false, true);
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 0, OEIL, DERRIERE).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void angleKillauraPasMesureEnVrilleRiptide() {
|
||||
moteur.coupDiffere(joueur, 0, EtatJoueur.builder().riptide(true).build(), OEIL, DERRIERE, BOITE, 3.0, 0, true, true);
|
||||
assertTrue(moteur.regardPorteeHitbox(joueur, 0, OEIL, DERRIERE).isEmpty());
|
||||
}
|
||||
}
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur