Class MovementTrace

java.lang.Object
ac.boar.anticheat.util.MovementTrace

public final class MovementTrace extends Object
Records what the movement prediction does on each tick.

The trace collects log lines into a buffer for the current tick. When a new tick starts, the old buffer moves into a small history. The history keeps the last HISTORY_TICKS ticks. Nothing is written to the log during normal play.

When the prediction fails hard enough to send a correction, dump(String) builds one text block with the full history and the failing tick, and flush(String) writes that block to the log. This gives the data needed to re-create the failure: the client input, the start state, and each step of the simulation.

  • Constructor Details

    • MovementTrace

      public MovementTrace(BoarPlayer player)
  • Method Details

    • begin

      public void begin()
      Starts a new tick. Moves the lines of the previous tick into the history, then records a snapshot of the state the prediction starts from.
    • log

      public void log(String line)
      Adds one line to the buffer of the current tick.
    • dump

      public String dump(String reason)
      Builds the full trace text: the reason, the retained history, and the current tick. Clears the history afterwards. The current tick keeps collecting lines until the next begin() call, so steps after the failure still get recorded.
    • flush

      public void flush(String reason)
      Writes the trace to the log as one message.