### Good Code Formatting Example Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/CONTRIBUTING.md Demonstrates proper code formatting with correct indentation and spacing. ```java if (var.func(param1, param2)) { // do things } ``` -------------------------------- ### Bad Code Formatting Example Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/CONTRIBUTING.md Illustrates incorrect code formatting, highlighting common mistakes to avoid. ```java if(var.func( param1, param2 )) { // do things } ``` -------------------------------- ### Run WorldEdit Client (Windows Command Prompt) Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/README.md Use this command to run the WorldEdit client on Windows using the Command Prompt. This command compiles and launches the game with WorldEdit integrated. ```bash gradlew :worldedit-fabric:runClient ``` -------------------------------- ### Create Backup using zip command Source: https://github.com/enginehub/worldedit/wiki/Snapshots A command for *nix/BSD users to create a timestamped ZIP backup of the 'world' directory. The filename format ensures proper sorting by WorldEdit. ```bash zip -v backups/`date "+%Y-%m-%d-%H-%M-%S"`.zip -r world ``` -------------------------------- ### Run WorldEdit Client (Mac/Linux) Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/README.md Use this command to run the WorldEdit client on Mac OS X or Linux systems. This command compiles and launches the game with WorldEdit integrated. ```bash ./gradlew :worldedit-fabric:runClient ``` -------------------------------- ### Compile WorldEdit on Windows Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/COMPILING.md Use this command in the command prompt opened from the WorldEdit folder to build the project on Windows. ```bash gradlew build ``` -------------------------------- ### Running a Script Source: https://github.com/enginehub/worldedit/wiki/Scripting Scripts are executed from the in-game chat by specifying the script filename. Arguments can be passed to the script. ```APIDOC ## Run Script ### Description Executes a JavaScript script from the chat. ### Syntax `/editscript [Filename] [arguments...]` ### Parameters #### Path Parameters - **Filename** (string) - Required - The name of the script file located in the `editscripts/` folder. - **arguments** (string) - Optional - Any arguments to be passed to the script. ``` -------------------------------- ### Run WorldEdit Client (Windows PowerShell) Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/README.md Use this command to run the WorldEdit client on Windows using PowerShell. This command compiles and launches the game with WorldEdit integrated. ```bash .\gradlew :worldedit-fabric:runClient ``` -------------------------------- ### Configure Snapshot Directory Source: https://github.com/enginehub/worldedit/wiki/Snapshots Set the directory where WorldEdit looks for backups (snapshots) in the `worldedit.properties` file. Ensure file paths are correctly escaped, especially on Windows. ```properties snapshots-dir=C:\\Minecraft\\Snapshots ``` -------------------------------- ### Use Latest Snapshot Source: https://github.com/enginehub/worldedit/wiki/Snapshots Use the `//use latest` command to revert to using the newest snapshot. This is useful if you have previously selected a specific older snapshot. ```plaintext //use latest ``` -------------------------------- ### Add SMWorldEdit to server.properties Source: https://github.com/enginehub/worldedit/wiki/Installation Modify the server.properties file to include SMWorldEdit in the plugins list. Separate multiple plugins with a comma. ```properties plugins=SMWorldEdit ``` -------------------------------- ### List Available Snapshots Source: https://github.com/enginehub/worldedit/wiki/Snapshots Use the `/listsnapshots` command to view the newest five available snapshots. This helps in selecting a specific snapshot for restoration. ```plaintext /listsnapshots ``` -------------------------------- ### Use Specific Snapshot Source: https://github.com/enginehub/worldedit/wiki/Snapshots Employ the `//use snapshot-name` command to switch to a specific snapshot for future restorations. Replace `snapshot-name` with the actual name of the snapshot. ```plaintext //use snapshot-name ``` -------------------------------- ### Compile WorldEdit on Linux/BSD/Mac OS X Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/COMPILING.md Navigate to the WorldEdit directory in your terminal and use this command to build the project on Unix-like systems. ```bash ./gradlew build ``` -------------------------------- ### Generate Eclipse Project Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/COMPILING.md Execute this Gradle command to generate Eclipse project files for each module of WorldEdit. ```bash gradlew eclipse ``` -------------------------------- ### Generate IntelliJ IDEA Modules Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/COMPILING.md Run this Gradle command to generate IntelliJ IDEA project files for each module of WorldEdit. ```bash gradlew idea ``` -------------------------------- ### Set Region to Glass Source: https://github.com/enginehub/worldedit/wiki/Usage Use this command after defining a region with //pos1 and //pos2 to fill the selected area with glass blocks. ```plaintext //set glass ``` -------------------------------- ### Stacking Blocks for Towers Source: https://github.com/enginehub/worldedit/wiki/Usage Use `//stackair up` to build vertical structures like towers. Specify the number of copies to create upwards. ```plaintext //stackair 10 up ``` -------------------------------- ### Stacking Blocks for Bridges Source: https://github.com/enginehub/worldedit/wiki/Usage Use `//stackair` to quickly create linear structures like bridges by copying selected blocks. Specify the number of copies to make. ```plaintext //stackair 10 ``` -------------------------------- ### Restore Region from Latest Backup Source: https://github.com/enginehub/worldedit/wiki/Snapshots Use the `//restore` command after defining a region to restore it from the newest available snapshot. This is the default behavior. ```plaintext //restore ``` -------------------------------- ### Add Gradle Task for WorldEdit Fabric Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/README.md This configuration adds a Gradle task named 'runClient' for the 'worldedit-fabric' project within an IDE. It allows launching the game directly from the IDE. ```text Choose `worldedit-fabric` for the project. For the tasks, type in `runClient` ``` -------------------------------- ### Configure Git Rename Detection Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/worldedit-core-mc/README.md Enable Git's rename detection to 'copy' for better tracking of file movements during diff operations. ```gitconfig git config diff.renames copy ``` -------------------------------- ### Global Variables Source: https://github.com/enginehub/worldedit/wiki/Scripting Available global variables and their properties/methods within a script. ```APIDOC ## Global Variables ### context An object providing context about the script execution. #### Fields - **player** (Player) - A reference to the Player object that initiated the script. #### Methods - **print**(string message): Prints a message to the initiating player's chat. - **error**(string message): Prints an error message (in red) to the initiating player's chat. ### args An array containing the arguments passed to the script from the chat command. ### player A direct reference to the Player object that initiated the script (equivalent to `context.player`). ### minecraft An object providing access to Minecraft-specific functionalities. #### Methods - **setBlock**(int x, int y, int z, int blockType): Sets a block at the specified coordinates. Returns `true` if the block was changed, `false` otherwise. - **getBlock**(int x, int y, int z): Returns the block type at the specified coordinates. ``` -------------------------------- ### Configure Git Diff Attributes Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/worldedit-core-mc/README.md Add these lines to your .git/info/attributes file to specify custom diff drivers for Java files within the WorldEdit core and platform modules. ```gitattributes 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 ``` -------------------------------- ### Create Hollow Glass Sphere Source: https://github.com/enginehub/worldedit/wiki/Usage Generates a hollow sphere of glass with a specified radius. This command uses the current placement position (defaulting to the block above the player or selection position 1 if toggled with /toggleplace). ```plaintext //hsphere glass 4 ``` -------------------------------- ### Configure Git Diff Textconv Source: https://github.com/enginehub/worldedit/blob/version/7.4.x/worldedit-core-mc/README.md Set the text conversion command for the 'core-mc' diff driver. This command processes Java files to normalize platform-specific elements. ```gitconfig git config diff.core-mc.textconv ./worldedit-core-mc/textconv-core-mc.py ``` -------------------------------- ### Player Object Source: https://github.com/enginehub/worldedit/wiki/Scripting Represents a player in the game, with properties for their state and methods for interaction. ```APIDOC ## Player Object ### Fields - **name** (string): The player's username. - **pitch** (double): The player's current view pitch. - **yaw** (double): The player's current view yaw. - **x** (double): The player's current X coordinate. - **y** (double): The player's current Y coordinate. - **z** (double): The player's current Z coordinate. - **blockX** (int): The X coordinate of the block the player is currently in. - **blockY** (int): The Y coordinate of the block the player is currently in. - **blockZ** (int): The Z coordinate of the block the player is currently in. ### Methods - **print**(string message): Prints a message to this player's chat. - **error**(string message): Prints an error message (in red) to this player's chat. ``` -------------------------------- ### Specify Block with Sign Text Source: https://github.com/enginehub/worldedit/wiki/Usage Sets the selected region to a sign with custom text. The text is formatted with pipe symbols (|) separating lines. Note that this may not work for chunks outside the loaded area. ```plaintext //set sign:4|Line1|Line2_Text|Line3 ``` -------------------------------- ### Specify Block with Data Value Source: https://github.com/enginehub/worldedit/wiki/Usage Sets the selected region to a specific block type and its data value. This is useful for blocks like crops where data determines their state. ```plaintext //set crops:7 ``` -------------------------------- ### Redo Last Undone Operation Source: https://github.com/enginehub/worldedit/wiki/Usage Re-applies the last operation that was undone using the //undo command. ```plaintext //redo ```