P1.13 : diagnostic « Mismatch in destroy block pos »

- core.ActionsBloc : START / ABORT de casse de bloc (LeftClickBlock, ecoute
  en LOWEST, meme annule). Un ABORT sans START accepte correspondant donne
  une ligne DIAGNOSTIC (au plus une toutes les 10 s par joueur), avec le
  dernier START et s'il a ete annule par un mod.
- D'apres ServerPlayerGameMode (sources NeoForge 21.1.234), destroyPos vaut
  (0,0,0) tant qu'aucun START n'a ete accepte : un START annule par une
  protection de zone puis un ABORT suffit a produire le message.
- Reglage [diagnostic] : actionsBlocIncoherentes (true). Jamais de sanction.
- Tests : ActionsBlocP1Test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
gastineltetClaude Sonnet 5.5 a révisé 2026-10-24 00:36:45 +02:00
1 Parent 7c86d634b9
révision adc326a897
7 fichiers modifiés
+140 -1

Aucun fichier ne correspond à votre recherche

+14
Voir le fichier
@@ -410,6 +410,20 @@ public final class Garde {
if (s == Sanction.EXPULSION) appliquerSanctionMouvement(p, s, v);
return Cablage.sanctionDeMouvement(s);
}
/**
* 0.5 (P1.13) : action de casse de bloc reçue (événement LeftClickBlock, vu même annulé). Diagnostic seulement :
* ligne de journal pour un ABORT sans START correspondant (message vanilla « Mismatch in destroy block pos »).
*/
public static void noterActionBloc(ServerPlayer p, boolean start, boolean abort, BlockPos pos, boolean annule) {
if (!CONFIG.diagnosticActionsBloc || !surThreadServeur(p) || MOTEUR.estExpulse(p.getUUID())) return;
com.gastinelgarde.core.ActionsBloc a = MOTEUR.suivi(p.getUUID()).actionsBloc;
if (start) {
a.start(pos.getX(), pos.getY(), pos.getZ(), annule);
} else if (abort) {
String ligne = a.abort(pos.getX(), pos.getY(), pos.getZ(), System.currentTimeMillis());
if (ligne != null) ecrireJournal("DIAGNOSTIC " + p.getGameProfile().getName() + " casse de bloc : " + ligne);
}
}
public static void noterTickServeur(MinecraftServer server, long dureeNs) {
double ms = dureeNs / 1_000_000.0;
if (ms > 250.0) gelTick = server.getTickCount();
+10
Voir le fichier
@@ -124,6 +124,16 @@ public final class GardeEvents {
event.setDamageMultiplier(1.0F);
}
}
/** 0.5 (P1.13) : diagnostic « Mismatch in destroy block pos » (vu après les autres mods, même annulé). */
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public static void onClicGaucheBloc(net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event) {
if (event.getLevel().isClientSide()) return;
if (!(event.getEntity() instanceof ServerPlayer p) || p instanceof FakePlayer) return;
var a = event.getAction();
Garde.noterActionBloc(p, a == net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.LeftClickBlock.Action.START,
a == net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.LeftClickBlock.Action.ABORT,
event.getPos(), event.isCanceled());
}
/** F04 : seul un trident Impulsion relâché après charge ouvre la tolérance riptide (pas le trident tenu). */
@SubscribeEvent
public static void onRelache(LivingEntityUseItemEvent.Stop event) {
+8 -1
Voir le fichier
@@ -22,7 +22,7 @@ public final class GardeSpec {
private static final ModConfigSpec.DoubleValue SEUIL_EXPULSION;
private static final ModConfigSpec.EnumValue<Sanction> SANCTION_MAX;
private static final ModConfigSpec.BooleanValue JOURNAL_TOUJOURS, SETBACK_SOL;
private static final ModConfigSpec.BooleanValue JOURNAL_TOUJOURS, SETBACK_SOL, DIAG_ACTIONS;
private static final ModConfigSpec.IntValue GRACE_CONNEXION, GRACE_APRES_EXPULSION;
private static final ModConfigSpec.DoubleValue STEP_HAUTEUR, STEP_MARGE, CRIT_MICRO;
private static final ModConfigSpec.IntValue CRIT_SERIE, ANTI_FAIM_TICKS, ELY_DEPLOIEMENTS;
@@ -267,6 +267,12 @@ public final class GardeSpec {
.defineInRange("antiFaimTicks", 20, 5, 1200);
b.pop();
b.comment("0.5 : diagnostics (journal seulement, jamais de sanction).").push("diagnostic");
DIAG_ACTIONS = b.comment("Journaliser les ABORT de casse de bloc sans START correspondant (message vanilla « Mismatch in destroy block pos »),",
"au plus une ligne toutes les 10 s par joueur.")
.define("actionsBlocIncoherentes", true);
b.pop();
b.comment("0.5 : grâces à la connexion (reconnexion en l'air, expulsion récente).").push("graces");
GRACE_CONNEXION = b.comment("Ticks sans contrôle de mouvement ni timer après la connexion (la téléportation de connexion en donne déjà graceTeleportTicks).")
.defineInRange("graceConnexionTicks", 100, 0, 1200);
@@ -365,6 +371,7 @@ public final class GardeSpec {
c.sanctionMax = SANCTION_MAX.get();
c.journalToujoursSanctions = JOURNAL_TOUJOURS.get();
c.journalLignesParSeconde = JOURNAL_LIMITE.get();
c.diagnosticActionsBloc = DIAG_ACTIONS.get();
c.angleMaxDegres = ANGLE_MAX.get();
c.ciblesMax = CIBLES_MAX.get();
c.fenetreCiblesMs = FENETRE_CIBLES_MS.get();
+53
Voir le fichier
@@ -0,0 +1,53 @@
package com.gastinelgarde.core;
/**
* 0.5 (P1.13) : diagnostic du message vanilla « Mismatch in destroy block pos: (0,0,0) … ». D'après
* ServerPlayerGameMode.handleBlockBreakAction (sources NeoForge 21.1.234) : {@code destroyPos} vaut (0,0,0) au départ
* et n'est mis à jour qu'à un START_DESTROY_BLOCK accepté (événement LeftClickBlock non annulé, à portée, interaction
* permise, pas créatif, pas de casse instantanée). Un ABORT sur une autre position donne le message. Causes
* possibles : START annulé par un mod (protection de zone), START refusé (trop loin), casse instantanée, ou client
* qui envoie ABORT sans START (FastBreak, Nuker, mod client) [À VÉRIFIER avec ces lignes de journal].
*
* Aucun contrôle, aucune sanction : une ligne de journal par incohérence, au plus une toutes les 10 s par joueur.
*/
public final class ActionsBloc {
public static final long DELAI_JOURNAL_MS = 10_000;
private boolean startVu;
private long startX, startY, startZ;
private boolean startAnnule;
private long dernierJournalMs = Long.MIN_VALUE;
private int incoherences;
/** START_DESTROY_BLOCK reçu ; {@code annule} : l'événement a été annulé par un mod. */
public void start(long x, long y, long z, boolean annule) {
startVu = true;
startX = x;
startY = y;
startZ = z;
startAnnule = annule;
}
/**
* ABORT_DESTROY_BLOCK reçu : texte de diagnostic s'il ne correspond pas au dernier START accepté (null sinon, ou si
* une ligne a déjà été écrite il y a moins de {@link #DELAI_JOURNAL_MS}).
*/
public String abort(long x, long y, long z, long nowMs) {
boolean memePos = startVu && startX == x && startY == y && startZ == z;
if (memePos && !startAnnule) return null;
incoherences++;
if (dernierJournalMs != Long.MIN_VALUE && nowMs - dernierJournalMs < DELAI_JOURNAL_MS && nowMs >= dernierJournalMs) {
return null;
}
dernierJournalMs = nowMs;
String start = !startVu ? "aucun START vu"
: String.format("dernier START (%d,%d,%d)%s", startX, startY, startZ, startAnnule ? " annule par un mod" : "");
return String.format("ABORT (%d,%d,%d) sans START correspondant : %s, %d incoherence(s) depuis la connexion",
x, y, z, start, incoherences);
}
public int incoherences() {
return incoherences;
}
}
+4
Voir le fichier
@@ -181,6 +181,10 @@ public final class GardeConfig {
/** Anti-faim : paquets consécutifs de course au sol déclarée « en l'air » avant infraction (1 s à 20 paquets/s). */
public int antiFaimTicks = 20;
// --- 0.5 (P1.13, section [diagnostic]) : journal seulement, jamais de sanction ---
/** Journaliser les ABORT de casse de bloc sans START correspondant (« Mismatch in destroy block pos »). */
public boolean diagnosticActionsBloc = true;
// --- Exemptions ---
public int graceTeleportTicks = 40;
/** 0.5 (P1.2) : grâce de mouvement / timer après la connexion (ticks) ; plus longue après une expulsion récente. */
+2
Voir le fichier
@@ -67,6 +67,8 @@ public final class Suivi {
public final AntiFaim antiFaim = new AntiFaim();
/** 0.5 (P1.6) : déploiements d'élytres répétés. */
public final DeploiementsElytres deploiements = new DeploiementsElytres();
/** 0.5 (P1.13) : diagnostic des actions de casse de bloc. */
public final ActionsBloc actionsBloc = new ActionsBloc();
public Suivi(double decroissanceParSeconde) {
this(decroissanceParSeconde, new GardeConfig());
+49
Voir le fichier
@@ -0,0 +1,49 @@
package com.gastinelgarde.core;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/** 0.5, P1.13 : automate START / ABORT de casse de bloc (diagnostic « Mismatch in destroy block pos »). */
class ActionsBlocP1Test {
@Test
void startPuisAbortMemePositionRien() {
ActionsBloc a = new ActionsBloc();
a.start(1, 64, 2, false);
assertNull(a.abort(1, 64, 2, 1000));
assertEquals(0, a.incoherences());
}
@Test
void abortSansStartCommeLeMessageVanilla() {
ActionsBloc a = new ActionsBloc();
String l = a.abort(5, 70, -3, 1000);
assertTrue(l.contains("ABORT (5,70,-3)") && l.contains("aucun START vu"), l);
}
@Test
void startAnnuleParUnModEstSignale() {
ActionsBloc a = new ActionsBloc();
a.start(5, 70, -3, true); // protection de zone : destroyPos vanilla pas mis à jour
String l = a.abort(5, 70, -3, 1000);
assertTrue(l.contains("annule par un mod"), l);
}
@Test
void autrePositionEtLimiteDeJournal() {
ActionsBloc a = new ActionsBloc();
a.start(0, 64, 0, false);
assertTrue(a.abort(1, 64, 0, 1000) != null);
assertNull(a.abort(2, 64, 0, 5000), "moins de 10 s : compté, pas écrit");
String l = a.abort(3, 64, 0, 1000 + ActionsBloc.DELAI_JOURNAL_MS);
assertTrue(l.contains("3 incoherence(s)"), l);
}
@Test
void diagnosticActifParDefaut() {
assertTrue(new GardeConfig().diagnosticActionsBloc);
}
}