From 0e67883bec139d4a07fb00f9b906a2a2d4e8257a Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 16 Mar 2026 19:41:53 -0400 Subject: [PATCH] Add online player positions to sudo context --- mc_aigod_paper.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/mc_aigod_paper.py b/mc_aigod_paper.py index 5d3bde4..6b2b595 100644 --- a/mc_aigod_paper.py +++ b/mc_aigod_paper.py @@ -2367,10 +2367,31 @@ def process_sudo(player, prompt, config): add_sudo_history(player, prompt, commands, executed) return + # Collect positions for all online players. + position_lines = [] + for p in online: + try: + pos_raw = rcon( + f"data get entity {p} Pos", + config["rcon_host"], config["rcon_port"], config["rcon_password"] + ) + pos_m = re.findall(r'(-?[\d.]+)d', pos_raw) + if pos_m and len(pos_m) >= 3: + x, y, z = int(float(pos_m[0])), int(float(pos_m[1])), int(float(pos_m[2])) + position_lines.append(f" {p}: x={x}, y={y}, z={z}") + except Exception: + pass + + positions_block = ( + "Player positions:\n" + "\n".join(position_lines) + if position_lines else "" + ) + context_hint = ( f"Requesting player: {player}\n" f"Online players: {', '.join(online) or 'none'}\n" - f"Natural language request: {prompt}\n" + + (positions_block + "\n" if positions_block else "") + + f"Natural language request: {prompt}\n" + get_sudo_history_block() )