Merge pull request #912 from rdbtCVS/t3/fix-grimac-false-flags

🤖 Agent: thanks rdbt! Verify passes. Checked locally merged with current main: fmt and clippy clean, cargo test -p horizon-client (885 passed), 14 harnesses including your two new oracles (player_sync, interaction_input, local_input, sprint_input, item_use, item_use_start, item_use_lifecycle, use_item_on, teleport_consume, lan, dedicated_server, server_player_combat, server_player_targets, server_entities), and lan_e2e pvp, hurt, eat, eating, clicks, chat, respawn in both modes: all pass. Fixes #903.
This commit is contained in:
Ludovic Marie
2026-10-18 23:12:59 +02:00
committed by GitHub
12 changed files with 1183 additions and 127 deletions
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
"""Compare queued interaction ordering with the real Minecraft.handleKeybinds."""
import itertools
import json
import random
try:
from . import lab, oracle_harness as harness
except ImportError:
import lab, oracle_harness as harness
def corpus():
rng = random.Random(0x434C49434B)
for using, destroying, attack_down, use_down, entity in itertools.product([False, True], repeat=5):
for clicks in [[], [1], [0, 1], [1, 0], [2, 1, 0], [0, 0, 1, 1, 2]]:
for delay in [0, 3]:
yield dict(using=using, destroying=destroying, attack_down=attack_down,
use_down=use_down, entity=entity, clicks=clicks, delay=delay,
dig_on_attack=rng.choice([False, True]),
begin_using=rng.choice([False, True]))
# A player interaction returning PASS must go directly to the held item.
# The level still reports a solid block underneath the entity hit.
for entity in [False, True]:
for clicks in [[1], [1, 1], [0, 1], [1, 2]]:
yield dict(using=False, destroying=False, attack_down=False, use_down=False,
entity=entity, clicks=clicks, delay=0, dig_on_attack=False,
begin_using=False, passing=True)
def main():
def inputs(build):
rows = list(corpus())
path = build / "inputs.jsonl"
path.write_text("".join(json.dumps(row) + "\n" for row in rows))
return path, len(rows)
harness.differential(
"interaction-input-parity", "VanillaInteractionInputOracle", "interaction_input_fixture", inputs,
"Invokes Minecraft.handleKeybinds itself with real KeyMapping click counters. "
"Compares attack/use/pick ordering, release gating, drained clicks during use, "
"held-button repetition and use cooldowns for block/entity targets. "
"Includes passing entity interactions over solid blocks: only the held "
"item may be tried afterward. "
"Game-mode side effects and world simulation are controlled fixtures.",
sources=[lab.ROOT / "crates/horizon-client/src/interaction_input.rs",
lab.ROOT / "crates/horizon-client/src/game/remote.rs",
lab.ROOT / "crates/horizon-client/src/game/hand.rs",
lab.ROOT / "mods/horizon/src/test/java/dev/horizonlab/parity/ParityData.java"])
if __name__ == "__main__":
main()
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env python3
"""Compare movement packet selection and teleport velocity with the pinned client."""
import json
import random
import struct
try:
from . import lab, oracle_harness as harness
except ImportError:
import lab, oracle_harness as harness
def corpus():
# Stationary heartbeats, rotation-only updates, status changes and corrected
# positions followed by unchanged looks must retain vanilla's packet types.
yield dict(kind="movement", ops=[[0, 0, 0, 0, 0, False, False]] * 61)
yield dict(kind="movement", ops=[
[0, 64, 0, 90, 0, True, False],
[0, 64, 0, 90, 0, True, False],
[0, 64, 0, 91, 0, True, False],
[100, 80, -20, 180, 20, False, False],
[100, 80, -20, 180, 20, True, False],
[100, 80, -20, 180, 20, True, True],
])
rng = random.Random(0x53594E43)
for _ in range(300):
state = [0, 0, 0, 0, 0, False, False]
ops = []
for _ in range(80):
if rng.random() < 0.5:
axis = rng.randrange(3)
state[axis] += rng.choice([0, 0.0001, 0.0002, 0.0002000001, 0.1, 10])
if rng.random() < 0.3:
state[3] += rng.choice([-360, -1, 0, 0.001, 1, 360])
state[4] = rng.choice([-90, 0, 30, 90])
if rng.random() < 0.2:
state[rng.randrange(5, 7)] = rng.choice([False, True])
ops.append(state.copy())
yield dict(kind="movement", ops=ops)
for flags in range(16):
for _ in range(40):
yield dict(kind="velocity", flags=flags << 5,
velocity=[rng.uniform(-4, 4) for _ in range(3)],
delta=[rng.uniform(-4, 4) for _ in range(3)],
old=[rng.uniform(-720, 720), rng.uniform(-90, 90)],
new=[rng.uniform(-720, 720), rng.uniform(-90, 90)])
def main():
def inputs(build):
rows = list(corpus())
def bits(v):
return struct.pack(">d", v).hex()
for row in rows:
if row["kind"] == "movement":
row["ops"] = [[*map(bits, op[:5]), *op[5:]] for op in row["ops"]]
else:
for key in ["velocity", "delta", "old", "new"]:
row[key] = list(map(bits, row[key]))
path = build / "inputs.jsonl"
path.write_text("".join(json.dumps(row) + "\n" for row in rows))
return path, len(rows)
harness.differential(
"player-sync-parity", "VanillaPlayerSyncOracle", "player_sync_fixture", inputs,
"Actual LocalPlayer.sendPosition packet payloads over persistent movement "
"sequences; PositionMoveRotation.calculateAbsolute velocity with every "
"relative-delta/rotate-delta combination. World simulation, connection "
"scheduling and live anticheat behaviour are outside this harness.",
sources=[lab.ROOT / "crates/horizon-client/src/player_sync.rs",
lab.ROOT / "crates/horizon-client/src/game/remote.rs",
lab.ROOT / "crates/horizon-client/src/net.rs"])
if __name__ == "__main__":
main()