WorldEdit Documentation

repository·version/7.4.x·Indexed 25 days ago

https://github.com/enginehub/worldedit

A powerful Minecraft map editor for players and server administrators providing tools for selections, schematics, copy/paste, brushes, and scripting. Supports Java Edition across NeoForge, Fabric, Bukkit, Spigot, Paper, and Sponge. Includes documentation for development, compiling with Gradle, using the WorldEdit CLI, and implementing custom commands via the CommandsManager and @Command annotations.

Tokens
17K
Snippets
19
Records
211
Agent score
81%

What's inside WorldEdit

  1. Configure Git diff for WorldEdit core logic changes

    version/7.4.x

    When comparing changes between worldedit-core-mc and platform-specific implementations like worldedit-fabric or worldedit-neoforge, you can use a custom text converter to reduce noise. This setup replaces platform-specific names with platform$ in diffs, allowing you to focus on core logic changes rather than renames.

    Follow these steps to configure your local Git environment:

    1. Add the following lines to your .git/info/attributes file:
    worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/**/*.java diff=core-mc
    worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/**/*.java diff=core-mc
    worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/**/*.java diff=core-mc
    1. Configure the core-mc diff tool using the provided Python script:
    git config diff.core-mc.textconv ./worldedit-core-mc/textconv-core-mc.py
    1. Enable rename detection in Git:
    git config diff.renames copy

    Note: Remember to remove the changes made to .git/info/attributes once you have finished your comparison to prevent affecting future diffs.

    git config diff.core-mc.textconv ./worldedit-core-mc/textconv-core-mc.py
    git config diff.renames copy
  2. Submit changes to WorldEdit

    version/7.4.x

    WorldEdit is licensed under GPL v3. To contribute code:

    1. Create a fork of the repository on GitHub.
    2. Apply your changes to your fork.
    3. Create a Pull Request to the main WorldEdit repository.

    Refer to CONTRIBUTING.md for specific guidelines.

  3. Run WorldEdit from source code

    version/7.4.x

    To run a local instance of Minecraft with WorldEdit for development, follow these steps:

    1. Download the source code (via Git or as a .zip).
    2. Ensure Java 21 or greater is installed (Gradle will download JDK 21 automatically if not present, but a base Java installation is required to start Gradle).
    3. Navigate to the source directory in your terminal.
    4. Execute the appropriate Gradle command for your OS.

    Note: You must restart the game after making code changes for them to take effect.

  4. Download WorldEdit for use

    version/7.4.x

    If you want to use WorldEdit as a mod or plugin rather than developing it, download the latest versions from Modrinth. WorldEdit is compatible with Java Edition and supports NeoForge, Fabric, Bukkit, Spigot, Paper, and Sponge.

    https://modrinth.com/plugin/worldedit/versions
  5. Speed up the development cycle

    version/7.4.x
    To reduce the time spent restarting the game when testing changes, run a server instead of a client. Use the runServer task instead of runClient. This allows you to simply reconnect to the server after a restart rather than reloading the entire game client.
  6. Compile WorldEdit using Gradle

    version/7.4.x

    To compile WorldEdit, you must have Java 21 or greater installed to bootstrap the process. The build uses the Gradle wrapper (gradlew), so you do not need to install Gradle manually. WorldEdit is a multi-module project containing worldedit-core, worldedit-bukkit, worldedit-sponge, worldedit-neoforge, and worldedit-fabric.

    # On Windows
    gradlew build
    
    # On Linux, BSD, or Mac OS X
    ./gradlew build
  7. Implement and register commands with CommandsManager

    version/7.4.x

    The CommandsManager<T> class allows you to create a command system by annotating methods within a class. You can register classes containing commands, and the manager will handle routing, nested commands, permissions, and argument parsing via reflection.

    Key Annotations to Use:

    • @Command: Marks a method as a command. Defines aliases, usage, description, help text, and flags.
    • @NestedCommand: Used to define sub-commands. You can specify which classes contain the nested commands and whether the parent method's body should execute (executeBody = true/false).
    • @CommandPermissions: Defines the permission nodes required to execute the command.
    • @CommandAlias: Used to provide alternative names for an existing command.

    Registration Modes:

    1. Static Registration: If no Injector is provided via setInjector(), methods marked with @Command must be static.
    2. Instance Registration: If an Injector is registered, the manager will use it to create instances of the command classes, allowing you to use non-static methods.

    To register a class, use register(Class<?> cls) or registerAndReturn(Class<?> cls) to get a list of the registered @Command annotations.

  8. Use relative offsets with the '^' prefix

    version/7.4.x

    WorldEdit supports relative offsets in commands by prefixing the argument with a caret (^). This allows you to specify a vector relative to the current orientation (pitch and yaw) of a Locatable actor (such as a player).

    When using the ^ prefix, the input is treated as a relative vector and is rotated based on the actor's current view direction before being converted to block coordinates.