Slice 3: Player Peripheral #1

Open
opened 2026-12-01 02:44:20 +00:00 by muse-lantern · 0 comments
Owner

CC Autoplay — Slice 3: Player Peripheral — Build Plan

Milestones

M1 — API/peripheral scaffolding

Goal: Establish the CC:T integration contract for the player computer.

  • Add player as a built-in Lua API on the player computer (same model as turtle: ILuaAPI registered via Computer.addApi), not a peripheral.
  • Auto-attach player_inventory and player_hotbar as local peripherals by default via computer.getEnvironment().setPeripheral(ComputerSide, IPeripheral).
  • Fixed side mapping: player_inventory on back, player_hotbar on bottom.
  • Discovery contract: peripheral.find("player_inventory") and peripheral.find("player_hotbar") are the stable lookup path; sides are deterministic for peripheral.wrap.
  • Add safe CC-thread <-> Minecraft client-thread marshaling helpers for reads/actions.
  • Add event plumbing for player computer events (computer.queueEvent).

Done when: From Lua, peripheral.find("player_inventory")/peripheral.find("player_hotbar") return the built-in peripherals, peripheral.wrap("back")/("bottom") work, and the player API is present.

M2 — Player inventory and hotbar peripherals

Goal: Expose the player's own inventory/hotbar through standard CC inventory semantics.

  • Implement player_inventory (27 main slots) and player_hotbar (9 slots) as CC inventory peripherals.
  • Standard inventory methods (CC:T 1.121.0 / AbstractInventoryMethods shape):
    • size()
    • list()
    • getItemDetail(slot)
    • getItemLimit(slot)
    • pushItems(toName, fromSlot [, limit [, toSlot]])
    • pullItems(fromName, fromSlot [, limit [, toSlot]])
  • Hotbar turtle-style commands on player_hotbar:
    • select(slot), getSelectedSlot()
    • getItemCount([slot])
    • drop([count]), dropUp([count]), dropDown([count])
    • place()
    • transferTo(slot [, count])
    • equipLeft(), equipRight()
  • Inventory management is instant from the player's perspective; implementation may yield to tick where required by client-thread safety.
  • Armor swapping and auto-sorting live in this inventory surface (scope detail to be refined before implementation).

Done when: Lua can list/inspect player inventory and hotbar, move items between them and other attached inventory peripherals, select hotbar slots, and perform hotbar item actions.

M3 — Reach/sight snapshots and block selection

Goal: Provide a fair, sight-based world view for scripts.

  • Maintain a live reach/sight snapshot at 20 client ticks/sec.
  • Reading reach/sight returns an immutable snapshot; if world state changed, caller re-reads.
  • Block record schema follows turtle.inspect() data shape:
    • name
    • state
    • tags
  • Add snapshot metadata needed for selection/action (at minimum world position and distance; exact schema finalized before implementation).
  • Reach radius for actions is 4.5 blocks. Blocks beyond 4.5 may be visible in sight scans but not actionable.
  • Visible-only scanning: no wallhacks, no chunk-data reads, no unseen block knowledge.

Done when: Lua can get a current reach snapshot, identify a specific block, and use that selection for later interaction calls.

M4 — World actions and interacted container peripherals

Goal: Let scripts act on the world like a player, with normal constraints.

  • World actions (within 4.5 blocks, real time): break, place, interact/use, open/interact with containers.
  • Break respects held tool and block break time; no instant breaks.
  • Place uses selected hotbar slot; one placement per action.
  • Interacting with an external container block exposes a temporary container peripheral.
  • Container peripheral lifecycle: normal close semantics as if the player closed it; detach on exit. Additional detach triggers (out of range, broken block, forced screen close, disconnect) to be specified in implementation.
  • Per-block handlers (special-cased):
    • Chest/simple inventory: standard inventory peripheral behavior.
    • Furnace-like: slot 1 burnable/input, slot 2 fuel, slot 3 result; result is not insertable.
    • Crafting table: 3x3 grid + result = 10 slots; extracting result crafts as in normal gameplay.
    • Additional blocks added incrementally with explicit slot/behavior contracts.
  • pushItems/pullItems use CC:T standard arg order: pushItems(toName, fromSlot [, limit [, toSlot]]), pullItems(fromName, fromSlot [, limit [, toSlot]]).

Done when: A script can select a reachable chest/furnace/crafting table, interact to expose it, transfer/craft via the exposed peripheral, and close it normally.

M5 — Chat events and chat API

Goal: Expose chat as observable events and player-controlled outbound actions.

  • Fire CC events on the player computer:
    • chat_message
    • chat_whisper
  • Event payload: (isServer: bool, who: string, what: string, verified: bool).
    • isServer: easy server/system filter.
    • who: sender username, or server/system identity as defined by implementation (not the literal string "server" unless explicitly chosen).
    • what: message contents.
    • verified: Minecraft message signature/validation flag; not required for feature use.
  • Outbound chat API:
    • chat.send(message) — send message as the player.
    • chat.whisper(who, message) — send whisper command/message to a user.
  • Chat namespace/API placement follows the explicit chat.* surface above (finalize as separate chat API or player-adjacent API during M1/M5 implementation; default plan assumes chat API).

Done when: Lua can receive chat events, filter server/user messages, send chat, and whisper.

M6 — Movement and dirty map

Goal: Provide fair movement primitives and planner-based navigation.

  • Directional steering API: turn, walk forward/backward, strafe, jump, sprint, sneak.
  • Go-to-target is a planner, not executor:
    • Runs in Java, not Lua.
    • Returns a step-by-step instruction list from the dirty map.
    • Lua executes steps by calling movement functions.
    • Checks each step result against expected outcome; on mismatch, stops and returns/throws error.
    • Interruptible mid-process; script/player can take control back.
    • Recalculation is script-controlled, not automatic.
  • Dirty map: per-server local data file/DB alongside virtual FS.
    • Trigger-based scans (not passive).
    • Stores player position, reachable blocks, and visible blocks seen during scans.
    • Intentionally dirty/incomplete/stale; no chunk-data/server-state backfill.
  • Open decision before build: go-to strategy is either full A* over known blocks or walk-toward-and-jump. Do not pick unilaterally.

Done when: Lua can steer the player directly, request a go-to plan over known map data, execute/interrupt it, and handle step failures.

M7 — Vision extras and glasses overlay

Goal: Add richer perception and AR overlay, without giving unfair sensing.

  • Expose player coordinates and look angle through the player API (GPS-style convenience must not imply modem/GPS host behavior unless explicitly implemented).
  • Sight functions report relative look angle where something is visible.
  • Scanner/sensor reference (Plethora-inspired, renamed/fair): visible-only scan; interaction radius 4.5.
  • Glasses/canvas overlay is AR only, not a sensor:
    • canvas() (2D) and canvas3d() (3D)
    • Draw primitives (text, rectangle, box, line, point) as scoped by implementation.
  • Glasses give no block/entity knowledge by themselves.

Done when: Lua can read look/position, perform fair visible scans, and draw AR markers tied to script-known data.

Goal

Expose the local player to ComputerCraft Lua so scripts can automate player actions: inventory management, movement, world interaction, and chat. Client-side only, Fabric, Minecraft 26.1/26.3 target as repo currently configured, CC:Tweaked 1.121.0.

Fairness principle (load-bearing)

The code drives the player, but the player stays bound by human limits:

  • Same 4.5-block reach as a survival player.
  • Same break times as the held tool.
  • Same walk/sprint speed.
  • No seeing through walls. No knowing block data the player couldn't sense.
  • Knowledge is not action: the script can know about diamond ore down the cave (it's visible), but it has to walk there and mine it like a player would.

Baritone is the line not to cross. Baritone decides and executes with full world knowledge — it reads chunk data, knows every block, and auto-pathfinds with complete information. You may look at Baritone to understand how it works. Do not reimplement it. Our approach is sight-based (a map built from what the player actually saw) and the script stays in control.

Naming and Lua surface

  • player — final name. Lua API, like turtle; not a peripheral. It is the main player contract.
  • player_inventory — final name. Auto-attached peripheral. Side: back.
  • player_hotbar — final name. Auto-attached peripheral. Side: bottom.
  • chat — outbound chat namespace/API (chat.send, chat.whisper); finalize exact registration style during implementation, but keep the chat.* Lua shape.
  • Peripheral discovery uses peripheral.find(...) as the primary contract. No modem peripheral is required.

What already exists (do not rebuild)

  • Slice 1 — scaffold: Fabric client-only mod, loads with CC:T 1.121.0. Repo muse-lantern/cc-autoplay, branch main.
  • Slice 2 — terminal + virtual FS: PlayerComputer (real CC:T Computer running Cobalt Lua with CraftOS bios) with virtual filesystem. / is per-server (.minecraft/cc-autoplay/servers/<hashed-server-ip>), /rom is read-only CraftOS ROM, /.player/ is shared across worlds. Terminal renders with CC:T's FixedWidthFontRenderer. Custom inventory UI screen (271 wide: 17px sidebar + 254px texture), modeled on CC:T's turtle screen, with power/terminate buttons. Vanilla slot layout so normal slot-click packets work.
  • Mod id: cc-autoplayer (do not rename unprompted). License: not chosen (do not add one unprompted).

Integration contract (CC:T 1.121.0)

  • PlayerComputer owns a core dan200.computercraft.core.computer.Computer.
  • Register player as ILuaAPI via computer.addApi(...).
  • Register peripherals as IPeripheral and attach with computer.getEnvironment().setPeripheral(ComputerSide, IPeripheral).
  • Environment (core) exposes setPeripheral/getPeripheral; IAPIEnvironment does not expose setPeripheral.
  • Lua runs on the CC computer thread; Minecraft client/world/screen/input access must be marshaled to the client thread.
  • Reads should return snapshots/immutable data where possible; stale data is caller's responsibility to re-read.

Inventory

Two built-in peripherals. Both expose the standard CC inventory API:

  • player_inventory — main inventory (27 slots), back.
  • player_hotbar — hotbar (9 slots), bottom.

Standard methods:

  • size() — number of slots.
  • list() — sparse table, slot number to {name, count, nbt}.
  • getItemDetail(slot) — full detail: displayName, damage/maxDamage/durability, enchantments, etc.
  • getItemLimit(slot) — max stack size for the slot.
  • pushItems(toName, fromSlot [, limit [, toSlot]]) — move items to another peripheral.
  • pullItems(fromName, fromSlot [, limit [, toSlot]]) — pull items from another peripheral.

Arg order note: CC:T 1.121.0 AbstractInventoryMethods confirms the standard order above (toName/fromName, fromSlot, limit, toSlot).

Hotbar turtle-style commands (on player_hotbar):

  • select(slot) — select a hotbar slot.
  • drop([count]) — drop the selected item.
  • place() — place the selected block.
  • dropUp([count]), dropDown([count]) — drop upward/downward.
  • transferTo(slot [, count]) — move selected stack to another slot.
  • getSelectedSlot() — currently selected hotbar slot.
  • getItemCount([slot]) — count of items in a slot.
  • equipLeft(), equipRight() — equip the selected item to the left/right hand.

Reach/sight and block interaction

  • Maintain a live block snapshot at 20 client ticks/sec.
  • Querying reach/sight returns an immutable snapshot. If the snapshot changes, caller re-reads.
  • Snapshot schema follows turtle.inspect() data:
    • name
    • state
    • tags
  • Each snapshot entry also needs a stable selection key for actions (position/index/id) and action metadata (distance, in-reach flag, etc.) — finalize exact schema before M3 implementation.
  • Interaction radius is 4.5 blocks. Sight may include visible blocks beyond 4.5, but actions are limited to 4.5.
  • External container interaction exposes a temporary peripheral when a reachable block is interacted with. Detach on normal close (as if player closed it). Define additional detach rules during M4.

World actions

All in reach (4.5 blocks). All take real time.

  • Break a block — takes the block's break time with the held tool.
  • Place a block — needs the block in the selected hotbar slot. One placement per action.
  • Interact — right-click a block or entity (open a door, press a button, use an item).
  • Open menus/containers — opens the actual menu; interaction-scoped peripheral appears for supported containers.

Chat

  • Events: chat_message, chat_whisper.
  • Payload: (isServer: bool, who: string, what: string, verified: bool).
    • isServer allows quick filtering; sender identity provides a second check.
    • verified is Minecraft signature/validation state; not required.
  • Outbound:
    • chat.send(message)
    • chat.whisper(who, message)

Movement

Two modes. Both are in scope.

Directional steering

Direct control: turn, walk forward/backward, strafe, jump, sprint, sneak. The code steers; the player moves at normal speed.

Go-to-target

The script names a target position. The mod plans a route and returns it. Go-to is a planner, not an executor:

  • Runs in Java, not Lua.
  • Returns a list of step-by-step instructions.
  • Lua executes instructions by calling movement functions.
  • Checks each step's result against expected outcome; if mismatched, stops and throws/returns error. No silent re-plan.
  • Interruptible mid-process by script/player.
  • Recalculation is script-controlled.
  • Generated from the dirty map.

Open decision: go-to strategy

Not yet decided. Two options:

  1. Full A* over known blocks.
  2. Walk-toward-and-jump (simpler fallback).

Do not pick one unilaterally — ask before building go-to.

Dirty map

A data storage feature: local per-server data holding a surface scan of the world.

  • Scan runs as a trigger.
  • Records: player position, 4.5m reach blocks, and visible blocks.
  • Stored in local DB/file per server, alongside virtual FS.
  • Go-to reads the dirty map to plan a route.
  • Map can update as go-to is working; script decides whether to recalculate.
  • Dirty by nature: incomplete, possibly outdated, only what the player actually saw. No chunk-data/server-state backfill.

Vision and glasses

  • Coordinates/look: exposed through player API. Do not conflate with CC:T gps modem host behavior unless explicitly implemented.
  • Look angle: exposed; sight functions report relative angle where something is visible.
  • Scanner/sensor: Plethora-inspired, renamed/fair. Visible-only scan is a deliberate deviation from Plethora's through-walls scan.
  • Glasses: AR overlay API, not a sensor. canvas() and canvas3d(); scripts draw text/rect/box/line/point primitives. Scope canvas object model when building M7.

Out of scope for this slice

  • Plethora compatibility shim (acceptable later, not required now).
  • Baritone-style full-knowledge pathfinding (explicitly excluded).
  • Mod id rename (do not rename cc-autoplayer unprompted).
  • License (not chosen — do not add one unprompted).
  • Sodium 0.9.4-beta.2 vs 0.9.3 swap (asked, unanswered — do not change unprompted).

Open questions (ask before building)

  1. Go-to pathfinding: full A* over known blocks, or walk-toward-and-jump?
  2. Scanner radius: unverified — confirm against the Fabric Plethora port.
  3. Chat namespace registration: separate chat API or player-adjacent API? (Lua shape chat.send/chat.whisper is desired.)
  4. Reach/sight snapshot schema: exact fields/selection key beyond name/state/tags.
  5. Interacted peripheral naming/lifecycle: peripheral type/name exposed on interact; detach triggers beyond normal close.
  6. Container semantics: how standard CC inventory methods map to furnace/crafting-table special slots and result extraction.
  7. Plethora method names: confirm against Fabric port (docs.sc3.io / Re-Plethora) before building — 1.12.2 docs not final.
  8. Glasses canvas object API: scope when building M7; do not port whole object tree in one pass.

Build context

  • Repo: muse-lantern/cc-autoplay on git.merith.xyz, branch main. Push to remote lantern only, never origin.
  • Commit identity: muse-lantern <lantern@example.com>.
  • Toolchain: Java 25, Fabric 26.3, CC:T 1.121.0. Build in Docker (Temurin 25), run/test on lantern-vm under xvfb. Launch: cd ~/workspace/cc-autoplay && JAVA_HOME=/home/lantern/jdk-25 xvfb-run -a ./gradlew runClient --no-daemon.
  • Known limitation: xdotool mouse clicks do not fire onPress on buttons under xvfb. Button click-through can only be verified by Zach locally. Keyboard navigation works. Never claim clicks are verified.
  • Design rule: heavy computation (pathfinding, scanning) in Java. Lua is for orchestration only.
# CC Autoplay — Slice 3: Player Peripheral — Build Plan ## Milestones ### M1 — API/peripheral scaffolding **Goal:** Establish the CC:T integration contract for the player computer. - Add `player` as a built-in Lua API on the player computer (same model as `turtle`: `ILuaAPI` registered via `Computer.addApi`), not a peripheral. - Auto-attach `player_inventory` and `player_hotbar` as local peripherals by default via `computer.getEnvironment().setPeripheral(ComputerSide, IPeripheral)`. - Fixed side mapping: `player_inventory` on `back`, `player_hotbar` on `bottom`. - Discovery contract: `peripheral.find("player_inventory")` and `peripheral.find("player_hotbar")` are the stable lookup path; sides are deterministic for `peripheral.wrap`. - Add safe CC-thread <-> Minecraft client-thread marshaling helpers for reads/actions. - Add event plumbing for player computer events (`computer.queueEvent`). **Done when:** From Lua, `peripheral.find("player_inventory")`/`peripheral.find("player_hotbar")` return the built-in peripherals, `peripheral.wrap("back")`/`("bottom")` work, and the `player` API is present. ### M2 — Player inventory and hotbar peripherals **Goal:** Expose the player's own inventory/hotbar through standard CC inventory semantics. - Implement `player_inventory` (27 main slots) and `player_hotbar` (9 slots) as CC inventory peripherals. - Standard inventory methods (CC:T 1.121.0 / AbstractInventoryMethods shape): - `size()` - `list()` - `getItemDetail(slot)` - `getItemLimit(slot)` - `pushItems(toName, fromSlot [, limit [, toSlot]])` - `pullItems(fromName, fromSlot [, limit [, toSlot]])` - Hotbar turtle-style commands on `player_hotbar`: - `select(slot)`, `getSelectedSlot()` - `getItemCount([slot])` - `drop([count])`, `dropUp([count])`, `dropDown([count])` - `place()` - `transferTo(slot [, count])` - `equipLeft()`, `equipRight()` - Inventory management is instant from the player's perspective; implementation may yield to tick where required by client-thread safety. - Armor swapping and auto-sorting live in this inventory surface (scope detail to be refined before implementation). **Done when:** Lua can list/inspect player inventory and hotbar, move items between them and other attached inventory peripherals, select hotbar slots, and perform hotbar item actions. ### M3 — Reach/sight snapshots and block selection **Goal:** Provide a fair, sight-based world view for scripts. - Maintain a live reach/sight snapshot at 20 client ticks/sec. - Reading reach/sight returns an immutable snapshot; if world state changed, caller re-reads. - Block record schema follows `turtle.inspect()` data shape: - `name` - `state` - `tags` - Add snapshot metadata needed for selection/action (at minimum world position and distance; exact schema finalized before implementation). - Reach radius for actions is 4.5 blocks. Blocks beyond 4.5 may be visible in sight scans but not actionable. - Visible-only scanning: no wallhacks, no chunk-data reads, no unseen block knowledge. **Done when:** Lua can get a current reach snapshot, identify a specific block, and use that selection for later interaction calls. ### M4 — World actions and interacted container peripherals **Goal:** Let scripts act on the world like a player, with normal constraints. - World actions (within 4.5 blocks, real time): break, place, interact/use, open/interact with containers. - Break respects held tool and block break time; no instant breaks. - Place uses selected hotbar slot; one placement per action. - Interacting with an external container block exposes a temporary container peripheral. - Container peripheral lifecycle: normal close semantics as if the player closed it; detach on exit. Additional detach triggers (out of range, broken block, forced screen close, disconnect) to be specified in implementation. - Per-block handlers (special-cased): - **Chest/simple inventory:** standard inventory peripheral behavior. - **Furnace-like:** slot 1 burnable/input, slot 2 fuel, slot 3 result; result is not insertable. - **Crafting table:** 3x3 grid + result = 10 slots; extracting result crafts as in normal gameplay. - Additional blocks added incrementally with explicit slot/behavior contracts. - `pushItems`/`pullItems` use CC:T standard arg order: `pushItems(toName, fromSlot [, limit [, toSlot]])`, `pullItems(fromName, fromSlot [, limit [, toSlot]])`. **Done when:** A script can select a reachable chest/furnace/crafting table, interact to expose it, transfer/craft via the exposed peripheral, and close it normally. ### M5 — Chat events and chat API **Goal:** Expose chat as observable events and player-controlled outbound actions. - Fire CC events on the player computer: - `chat_message` - `chat_whisper` - Event payload: `(isServer: bool, who: string, what: string, verified: bool)`. - `isServer`: easy server/system filter. - `who`: sender username, or server/system identity as defined by implementation (not the literal string `"server"` unless explicitly chosen). - `what`: message contents. - `verified`: Minecraft message signature/validation flag; not required for feature use. - Outbound chat API: - `chat.send(message)` — send message as the player. - `chat.whisper(who, message)` — send whisper command/message to a user. - Chat namespace/API placement follows the explicit `chat.*` surface above (finalize as separate `chat` API or `player`-adjacent API during M1/M5 implementation; default plan assumes `chat` API). **Done when:** Lua can receive chat events, filter server/user messages, send chat, and whisper. ### M6 — Movement and dirty map **Goal:** Provide fair movement primitives and planner-based navigation. - Directional steering API: turn, walk forward/backward, strafe, jump, sprint, sneak. - Go-to-target is a **planner, not executor**: - Runs in Java, not Lua. - Returns a step-by-step instruction list from the dirty map. - Lua executes steps by calling movement functions. - Checks each step result against expected outcome; on mismatch, stops and returns/throws error. - Interruptible mid-process; script/player can take control back. - Recalculation is script-controlled, not automatic. - Dirty map: per-server local data file/DB alongside virtual FS. - Trigger-based scans (not passive). - Stores player position, reachable blocks, and visible blocks seen during scans. - Intentionally dirty/incomplete/stale; no chunk-data/server-state backfill. - **Open decision before build:** go-to strategy is either full A* over known blocks or walk-toward-and-jump. Do not pick unilaterally. **Done when:** Lua can steer the player directly, request a go-to plan over known map data, execute/interrupt it, and handle step failures. ### M7 — Vision extras and glasses overlay **Goal:** Add richer perception and AR overlay, without giving unfair sensing. - Expose player coordinates and look angle through the `player` API (GPS-style convenience must not imply modem/GPS host behavior unless explicitly implemented). - Sight functions report relative look angle where something is visible. - Scanner/sensor reference (Plethora-inspired, renamed/fair): visible-only scan; interaction radius 4.5. - Glasses/canvas overlay is AR only, not a sensor: - `canvas()` (2D) and `canvas3d()` (3D) - Draw primitives (text, rectangle, box, line, point) as scoped by implementation. - Glasses give no block/entity knowledge by themselves. **Done when:** Lua can read look/position, perform fair visible scans, and draw AR markers tied to script-known data. ## Goal Expose the local player to ComputerCraft Lua so scripts can automate player actions: inventory management, movement, world interaction, and chat. Client-side only, Fabric, Minecraft 26.1/26.3 target as repo currently configured, CC:Tweaked 1.121.0. ## Fairness principle (load-bearing) The code drives the player, but the player stays bound by human limits: - Same 4.5-block reach as a survival player. - Same break times as the held tool. - Same walk/sprint speed. - No seeing through walls. No knowing block data the player couldn't sense. - Knowledge is not action: the script can *know* about diamond ore down the cave (it's visible), but it has to walk there and mine it like a player would. Baritone is the line not to cross. Baritone decides *and* executes with full world knowledge — it reads chunk data, knows every block, and auto-pathfinds with complete information. You may look at Baritone to understand how it works. Do **not** reimplement it. Our approach is sight-based (a map built from what the player actually saw) and the script stays in control. ## Naming and Lua surface - **`player`** — final name. Lua API, like `turtle`; not a peripheral. It is the main player contract. - **`player_inventory`** — final name. Auto-attached peripheral. Side: `back`. - **`player_hotbar`** — final name. Auto-attached peripheral. Side: `bottom`. - **`chat`** — outbound chat namespace/API (`chat.send`, `chat.whisper`); finalize exact registration style during implementation, but keep the `chat.*` Lua shape. - Peripheral discovery uses `peripheral.find(...)` as the primary contract. No modem peripheral is required. ## What already exists (do not rebuild) - **Slice 1 — scaffold:** Fabric client-only mod, loads with CC:T 1.121.0. Repo `muse-lantern/cc-autoplay`, branch `main`. - **Slice 2 — terminal + virtual FS:** `PlayerComputer` (real CC:T `Computer` running Cobalt Lua with CraftOS bios) with virtual filesystem. `/` is per-server (`.minecraft/cc-autoplay/servers/<hashed-server-ip>`), `/rom` is read-only CraftOS ROM, `/.player/` is shared across worlds. Terminal renders with CC:T's `FixedWidthFontRenderer`. Custom inventory UI screen (271 wide: 17px sidebar + 254px texture), modeled on CC:T's turtle screen, with power/terminate buttons. Vanilla slot layout so normal slot-click packets work. - **Mod id:** `cc-autoplayer` (do not rename unprompted). **License:** not chosen (do not add one unprompted). ## Integration contract (CC:T 1.121.0) - `PlayerComputer` owns a core `dan200.computercraft.core.computer.Computer`. - Register `player` as `ILuaAPI` via `computer.addApi(...)`. - Register peripherals as `IPeripheral` and attach with `computer.getEnvironment().setPeripheral(ComputerSide, IPeripheral)`. - `Environment` (core) exposes `setPeripheral/getPeripheral`; `IAPIEnvironment` does not expose `setPeripheral`. - Lua runs on the CC computer thread; Minecraft client/world/screen/input access must be marshaled to the client thread. - Reads should return snapshots/immutable data where possible; stale data is caller's responsibility to re-read. ## Inventory Two built-in peripherals. Both expose the **standard CC inventory API**: - **`player_inventory`** — main inventory (27 slots), `back`. - **`player_hotbar`** — hotbar (9 slots), `bottom`. Standard methods: - `size()` — number of slots. - `list()` — sparse table, slot number to `{name, count, nbt}`. - `getItemDetail(slot)` — full detail: displayName, damage/maxDamage/durability, enchantments, etc. - `getItemLimit(slot)` — max stack size for the slot. - `pushItems(toName, fromSlot [, limit [, toSlot]])` — move items to another peripheral. - `pullItems(fromName, fromSlot [, limit [, toSlot]])` — pull items from another peripheral. **Arg order note:** CC:T 1.121.0 `AbstractInventoryMethods` confirms the standard order above (`toName/fromName, fromSlot, limit, toSlot`). Hotbar turtle-style commands (on `player_hotbar`): - `select(slot)` — select a hotbar slot. - `drop([count])` — drop the selected item. - `place()` — place the selected block. - `dropUp([count])`, `dropDown([count])` — drop upward/downward. - `transferTo(slot [, count])` — move selected stack to another slot. - `getSelectedSlot()` — currently selected hotbar slot. - `getItemCount([slot])` — count of items in a slot. - `equipLeft()`, `equipRight()` — equip the selected item to the left/right hand. ## Reach/sight and block interaction - Maintain a live block snapshot at 20 client ticks/sec. - Querying reach/sight returns an immutable snapshot. If the snapshot changes, caller re-reads. - Snapshot schema follows `turtle.inspect()` data: - `name` - `state` - `tags` - Each snapshot entry also needs a stable selection key for actions (position/index/id) and action metadata (distance, in-reach flag, etc.) — finalize exact schema before M3 implementation. - Interaction radius is 4.5 blocks. Sight may include visible blocks beyond 4.5, but actions are limited to 4.5. - External container interaction exposes a temporary peripheral when a reachable block is interacted with. Detach on normal close (as if player closed it). Define additional detach rules during M4. ## World actions All in reach (4.5 blocks). All take real time. - **Break a block** — takes the block's break time with the held tool. - **Place a block** — needs the block in the selected hotbar slot. One placement per action. - **Interact** — right-click a block or entity (open a door, press a button, use an item). - **Open menus/containers** — opens the actual menu; interaction-scoped peripheral appears for supported containers. ## Chat - Events: `chat_message`, `chat_whisper`. - Payload: `(isServer: bool, who: string, what: string, verified: bool)`. - `isServer` allows quick filtering; sender identity provides a second check. - `verified` is Minecraft signature/validation state; not required. - Outbound: - `chat.send(message)` - `chat.whisper(who, message)` ## Movement Two modes. Both are in scope. ### Directional steering Direct control: turn, walk forward/backward, strafe, jump, sprint, sneak. The code steers; the player moves at normal speed. ### Go-to-target The script names a target position. The mod plans a route and returns it. **Go-to is a planner, not an executor:** - Runs in **Java, not Lua**. - Returns a list of step-by-step instructions. - Lua executes instructions by calling movement functions. - Checks each step's result against expected outcome; if mismatched, stops and throws/returns error. No silent re-plan. - Interruptible mid-process by script/player. - Recalculation is script-controlled. - Generated from the dirty map. ### Open decision: go-to strategy **Not yet decided.** Two options: 1. **Full A\*** over known blocks. 2. **Walk-toward-and-jump** (simpler fallback). Do **not** pick one unilaterally — ask before building go-to. ## Dirty map A **data storage feature**: local per-server data holding a surface scan of the world. - Scan runs as a trigger. - Records: player position, 4.5m reach blocks, and visible blocks. - Stored in local DB/file per server, alongside virtual FS. - Go-to reads the dirty map to plan a route. - Map can update as go-to is working; script decides whether to recalculate. - Dirty by nature: incomplete, possibly outdated, only what the player actually saw. No chunk-data/server-state backfill. ## Vision and glasses - **Coordinates/look:** exposed through `player` API. Do not conflate with CC:T `gps` modem host behavior unless explicitly implemented. - **Look angle:** exposed; sight functions report relative angle where something is visible. - **Scanner/sensor:** Plethora-inspired, renamed/fair. Visible-only scan is a deliberate deviation from Plethora's through-walls scan. - **Glasses:** AR overlay API, not a sensor. `canvas()` and `canvas3d()`; scripts draw text/rect/box/line/point primitives. Scope canvas object model when building M7. ## Out of scope for this slice - Plethora compatibility shim (acceptable later, not required now). - Baritone-style full-knowledge pathfinding (explicitly excluded). - Mod id rename (do not rename `cc-autoplayer` unprompted). - License (not chosen — do not add one unprompted). - Sodium 0.9.4-beta.2 vs 0.9.3 swap (asked, unanswered — do not change unprompted). ## Open questions (ask before building) 1. **Go-to pathfinding:** full A\* over known blocks, or walk-toward-and-jump? 2. **Scanner radius:** unverified — confirm against the Fabric Plethora port. 3. **Chat namespace registration:** separate `chat` API or `player`-adjacent API? (Lua shape `chat.send`/`chat.whisper` is desired.) 4. **Reach/sight snapshot schema:** exact fields/selection key beyond `name/state/tags`. 5. **Interacted peripheral naming/lifecycle:** peripheral type/name exposed on interact; detach triggers beyond normal close. 6. **Container semantics:** how standard CC inventory methods map to furnace/crafting-table special slots and result extraction. 7. **Plethora method names:** confirm against Fabric port (docs.sc3.io / Re-Plethora) before building — 1.12.2 docs not final. 8. **Glasses canvas object API:** scope when building M7; do not port whole object tree in one pass. ## Build context - **Repo:** muse-lantern/cc-autoplay on git.merith.xyz, branch `main`. Push to remote `lantern` only, never `origin`. - **Commit identity:** `muse-lantern <lantern@example.com>`. - **Toolchain:** Java 25, Fabric 26.3, CC:T 1.121.0. Build in Docker (Temurin 25), run/test on lantern-vm under xvfb. Launch: `cd ~/workspace/cc-autoplay && JAVA_HOME=/home/lantern/jdk-25 xvfb-run -a ./gradlew runClient --no-daemon`. - **Known limitation:** xdotool mouse clicks do not fire `onPress` on buttons under xvfb. Button click-through can only be verified by Zach locally. Keyboard navigation works. Never claim clicks are verified. - **Design rule:** heavy computation (pathfinding, scanning) in Java. Lua is for orchestration only.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
muse-lantern/cc-autoplay#1
No description provided.