2025-10-17 16:40:44 +08:00
2025-10-10 14:06:10 +08:00
2025-10-11 16:45:50 +08:00
2025-10-07 22:09:07 +08:00
2025-10-14 13:54:43 +08:00

cc-utils

A collection of advanced utilities and libraries for Minecraft ComputerCraft, written in TypeScript and compiled to Lua. This project includes a powerful access control system, an automated crafting utility for the Create mod, and a declarative TUI framework.

Features

1. Access Control System

A comprehensive system for managing player access to a specific area. It uses a playerDetector to monitor for players in range and a chatBox to interact with them and administrators.

  • Player Detection: Monitors a configurable range for players.
  • Group-Based Permissions: Assign players to groups (admin, user, VIP, enemies, etc.) with specific permissions (isAllowed, isNotice).
  • In-Game CLI: Administrators can manage the system in-game via chat commands (e.g., @AC /add <group> <player>).
  • TUI for Configuration: A user-friendly Text-based User Interface (TUI) for easy configuration. It can be launched with accesscontrol config or by pressing c in the main program or log viewer.
  • Customizable Toasts: Configure welcome, notice, and warning toast messages for different players and situations.
  • Logging: Detailed logging of events, viewable with the included logviewer program.

2. AutoCraft System

An automated crafting solution designed to work with the Create mod's packaged recipes.

  • Automated Crafting: Detects cardboard packages in a chest and automatically crafts the recipes they contain.
  • Recipe Parsing: Extracts complex, multi-step crafting recipes from package NBT data.
  • Inventory Management: Manages pulling ingredients from a source inventory and pushing crafted items to a destination.

3. ccTUI Framework

A declarative, reactive TUI (Terminal User Interface) framework inspired by SolidJS for building complex and interactive interfaces in ComputerCraft.

  • Declarative Syntax: Build UIs with simple, composable functions like div, label, button, and input.
  • Reactive State Management: Uses signals (createSignal), stores (createStore), and effects (createEffect) for fine-grained, automatic UI updates.
  • Flexbox Layout: Easily create complex layouts using CSS-like classes (flex, flex-row, flex-col, justify-center, items-center, etc.).
  • Control Flow: Includes <For> and <Show> components for conditional and list-based rendering.
  • Component-Based: Structure your UI into reusable components. See src/tuiExample/main.ts for a demo.

4. Core Libraries

  • ccLog: A robust logging library with automatic, time-based log file rotation.
  • PeripheralManager: A utility for easily finding and requiring peripherals by name or type.
  • CraftManager: A library for parsing and executing crafting recipes from Create mod packages.

Prerequisites

Setup & Installation

  1. Clone the repository:

    git clone <repository-url>
    cd cc-utils
    
  2. Install dependencies:

    pnpm install
    

Building

This project uses just to manage build tasks. The compiled Lua files will be placed in the build/ directory.

  • Build all modules:

    just build
    
  • Build a specific module:

    just build-accesscontrol
    just build-autocraft
    just build-example
    

Deployment

To deploy the built programs to your in-game computer, you need to configure the sync path in the .justfile.

  1. Open the .justfile and modify the sync-path variable to point to your CraftOS-PC computer's directory.

    # Example for Linux
    sync-path := "/home/user/.local/share/craftos-pc/computer/0/user/"
    
    # Example for Windows
    # sync-path := "/cygdrive/c/Users/YourUser/AppData/Roaming/CraftOS-PC/computer/0/user/"
    
  2. Run the sync command:

    just sync
    

    This will copy the contents of the build/ directory to your computer.

Usage

Access Control

  • Start the system:

    accesscontrol start
    
  • Open the configuration TUI:

    accesscontrol config
    

    Alternatively, press c while the main program is running.

  • View logs:

    logviewer accesscontrol.log
    
  • Admin Commands (in-game chat):

    @AC /help
    @AC /add user Notch
    @AC /list
    

AutoCraft

The autocraft program runs in the background. Simply run it on a turtle with the correct peripheral setup (see src/autocraft/main.ts). It will automatically process packages placed in the designated chest.

autocraft

TUI Example

Run the example program to see a demonstration of the ccTUI framework.

tuiExample

Development

  • Lint and format the code:
    just lint
    

License

This project is licensed under the MIT License. See the LICENSE file for details.

Description
A set of utils for CC:Tweaked (Minecraft ComputerCraft).
Readme MIT 514 KiB
Languages
TypeScript 99.6%
JavaScript 0.3%