BlockEnv Documentation

website·Indexed 30 days ago

https://blockenv.jaronline.dev

A tool for testing Minecraft Java modpacks in production-like environments. BlockEnv allows users to create, manage, and launch testing environments to identify and fix issues before production.

Tokens
2.4K
Snippets
18
Records
22
Agent score
49%

What's inside BlockEnv

  1. Overview of BlockEnv for Minecraft modpack testing

    BlockEnv is a tool used to create and manage isolated environments for testing Minecraft modpacks. It allows developers to run Minecraft with various modpacks and configurations in a production-like setting locally, providing full access to debug logs and crash reports to identify and fix issues before deploying to production.
  2. Use the blockenv CLI to manage Minecraft Java testing environments

    blockenv is a command-line tool used to create and manage testing environments for Minecraft Java modpacks. The general command syntax is blockenv [options] [command].
    blockenv [options] [command]
  3. Install BlockEnv in a project

    BlockEnv requires Node.js to be installed on your system. It can be installed as a development dependency using npm, yarn, or pnpm.
    npm install --save-dev --save-exact @jaronline/blockenv
  4. Examples of using blockenv setup

    Common usage scenarios for the blockenv setup command:

    1. Standard Client Setup: Set up a client environment with a specific loader and Minecraft version.
    2. Server Setup with Version Inference: Use --new-setup-order to infer the Minecraft version from the loader version.
    3. Environment Preset: Use the --environment flag to load settings from blockenv.config.json, reducing the need to specify the loader and loader version manually.
    # Standard client setup
    blockenv setup --side client --loader neoforge --loader-version 21.1.173 --minecraft-version 1.21.1
    
    # Server setup inferring Minecraft version from loader
    blockenv setup --side server --loader neoforge --loader-version 21.1.173 --new-setup-order
    
    # Setup using an environment preset from blockenv.config.json
    blockenv setup --environment client --minecraft-version 1.21.1
    
    # Setup using environment preset and new setup order
    blockenv setup --environment server --loader neoforge --loader-version 21.1.173 --new-setup-order
  5. Install BlockEnv CLI globally

    The BlockEnv CLI can be installed globally to allow the blockenv command to be run from any terminal location. Note that a project-specific configuration file is still required for the CLI to function.
    npm install --global @jaronline/blockenv
  6. Configure blockenv setup options

    The blockenv setup command supports the following configuration options:

    • -s, --side <side>: Specify whether to setup the client or server.
    • -e, --environment <environment>: Specify which environment preset to setup (requires corresponding configuration in blockenv.config.json).
    • -l, --loader <loader>: Specify the modloader (currently only neoforge is supported).
    • --loader-version <version>: Specify the version of the modloader.
    • -m, --minecraft-version <version>: Specify the Minecraft version.
    • --new-setup-order: If true, runs the installer first, then downloads libraries and assets (default: false).
    • -h, --help: Display help for the command.
  7. Set up a testing environment with blockenv setup

    Use the blockenv setup command to initialize a testing environment. You can specify the target side (client or server), the modloader, and the specific versions of Minecraft and the loader. The --new-setup-order flag changes the execution sequence to run the installer before downloading libraries and assets.
    blockenv setup [options]
  8. Launch a Minecraft client or server using blockenv launch

    The blockenv launch command is used to start a Minecraft client or server. Before using this command, you must first set up a BlockEnv environment using the blockenv setup command.

    Command Syntax

    blockenv launch [options]

    Available Options

    • -s, --side <side>: Specify whether to launch the server or client. Choices are client (default) or server.
    • -e, --environment <environment>: Specify the environment to use for the launch.
    • -p, --profile <profile>: Specify the client profile to launch.
    • --player-name <playerName>: Specify the player name to use in the game.
    • -h, --help: Display help for the command.
    blockenv launch [options]
  9. Setup and launch a Minecraft server environment

    To run a server environment for testing a modded Minecraft server, perform a setup to download necessary files and then launch the server.
    # Setup the server environment
    npx blockenv setup --side server --loader MOD_LOADER --loader-version MOD_LOADER_VERSION
    
    # Launch the server environment
    npx blockenv launch --side server
  10. Setup and launch a Minecraft client environment

    To run a client environment for testing a modpack, first perform a setup to download necessary files, then launch the environment using a specific profile. Available profiles are listed in the launcher_profiles.json file within the client environment directory.
    # Setup the client environment
    npx blockenv setup --side client --loader MOD_LOADER --loader-version MOD_LOADER_VERSION
    
    # Launch the client environment
    npx blockenv launch --side client --profile PROFILE_NAME
  11. Clean a BlockEnv testing environment

    The blockenv clean command removes configurations, mods, and temporary files to reset a testing environment or free up space. Warning: This action is destructive and removes critical configuration and mod data; use with caution.

    Depending on the --side specified, the following items are removed:

    • Both sides: config/*, defaultconfigs/*, logs/*, mods/*, resourcepacks/*, usercache.json, usernamecache.json.
    • Client-side only: downloads/*, shaderpacks/*, options.txt, servers.dat, servers.dat_old.
    • Server-side only: world/, whitelist.json, ops.json, banned-ips.json, banned-players.json.
    # Clean the client environment
    blockenv clean --side client
    
    # Clean the server environment
    blockenv clean --side server
  12. Configure BlockEnv project settings

    Create a blockenv.config.json file in the project root directory. This file must define the baseDir, which is the path to the directory where BlockEnv environments will be stored.
    {
      "baseDir": "environment"
    }