-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
The mod is available to download on Modrinth, CurseForge and as a Github Release.
Alternatively, you can build it yourself by cloning this repository and running ./gradlew build in the root directory. The built mod will appear in build/libs.
If you didn't download the mod through a launcher, you'll have to put the mod .jar file in the mods directory of your Minecraft instance.
The VSCode extension is available on the VSCode marketplace or on the Open VSX Registry or as a Github Release.
Alternatively, you can also build it yourself by running npm install, npm install -g @vscode/vsce and vsce package in the editor_extensions/vscode/commandcrafter directory, which will generate a .vsix file that can be used to install the extension in your editor.
Once CommandCrafter is installed, the easiest way to use the language server is to first start Minecraft and then start VSCode and open your datapack folder, which will let VSCode automatically connect to your Minecraft instance.
Note that (by default) the Language Server service is only provided by the Minecraft client, not the server. Thus, if you want to connect to it, the VSCode extension needs to connect to your client. But it is still recommended to install the mod on the server too, because many features work better when the client is able to communicate with the server.
Once VSCode is connected to Minecraft, you should get all the nice language server stuff, like syntax highlighting, errors, auto completions, hover providers etc. for functions and JSON files in datapacks. Additionally, VSCode should automatically focus the Minecraft log in the "Minecraft Console" view, as well as an input field for running commands. Here, you can also view the log of connected servers, if they have CommandCrafter installed, by selecting the "server" channel. Depending on the theme you are using, highlighting might not work or might require additional settings, in case the theme doesn't support semantic tokens by default. Regarding auto completions, it is also important to remember that VSCode might not always requests completions, but you can still get some by pressing Ctrl + Space.
Furthermore, once the language server is connected and you enter a world, you can edit scoreboards and storages in VSCode using the "Scoreboard/Storage Viewer" at the bottom of the "Explorer" tab.
Note that, like with the Language Server service, the debugger is also only provided by the Minecraft client by default. Thus, if you want to connect to it, the VSCode extension needs to connect to your client.
To use the debugger, you can let VSCode generate a launch.json file, which should contain a default launch configuration that will connect to Minecraft and enable debugging all functions that are run in Minecraft. To start the generated launch configuration, press F5. Alternatively, it is possible to add the "Minecraft: Debug Function" launch configuration, which will let you run a certain function upon starting the debugger and only debug within this function invocation.
Breakpoints within functions and function tags will now be resolved once Minecraft connected to a server that also has the mod installed. Once a breakpoint is hit, you will be able to step through the execution while monitoring the function's context.
When debugging a function, you can use the "step over" button to step over entire commands as expected. However, when a command consists of multiple sections (like execute at @a if block ~ ~ ~ water run function my_function), you can also use the "step in" action to go through the sections. When going through the sections of a command like this, it is important to know the order in which Minecraft executes this command: In this example Minecraft will run "if block" for all of the players first, before moving on to executing "run function" for all the players who matched the condition. This means when you step into "if block" you can use "step over" to step through all the players for which this section is run. You can also use "step in" to step into the "run function" section, which will run through all the "if block" executions first and then pause once the first player who passed the condition executes "run function". When a section is either the function command or execute if function command, you can also use "Step in" to step into the function call.
For more "Step in" options, there is the "Step in targets" action (Ctrl + F11), which can give you multiple options for where you want to step next. In the case of CommandCrafter, those options will include stepping into the start of the next segment (like the normal "Step in" action), stepping into the next segment but following the current context (for example, when you have stepped to a certain player in the if block ~ ~ ~ water section, this lets you directly go to the same player in the run function section instead of going back to the first player), and stepping into a call that is invoked by the section (like stepping into a function called by execute if function).
If you pause within a function that contains macros, the debugger will show a new file that contains the commands of the function with the macros filled in. Additionally, the breakpoints from the original function file will be mirrored in the new file.
While debugging, you can continue to use the Scoreboard/Storage viewer to see the state your function is working with in addition to seeing the command context, macros and function results as variables in VSCode. More info is also available if you hover over command arguments or paste them into the debug console.
Last but not least, CommandCrafter expands on the mcfunction parser, which can still parse vanilla functions, but also lets you configure the language a bit to make developing datapacks easier. This is done by starting a line in your function with the @language directive that lets you select and configure the language that is used for parsing the function. Currently, CommandCrafter only offers the vanilla language with the following configuration options:
-
@language vanilla- the vanilla parser -
@language vanilla easyNewLine- this lets you write commands that span multiple lines without writing a\at the end of each line. For example nbt arguments can directly span multiple lines without any extra effort, because Minecraft always knows whether the nbt argument is finished or not. This is not as easy for command literals, so when you want to split up a command likeexecute as @a run say Hi!into multiple line you need to make sure that the following lines have a larger indent than the first line. This is how Minecraft knows that they are supposed to continue the command from the previous line. -
@language vanilla inlineResources- this lets you specify functions and tags that are only used in one place directly where they are used (for example inline functions with curly braces:execute if function { return 1 }and inline tags with parentheses:kill @a[type=["minecraft:marker", "minecraft:armor_stand"]]) -
@language vanilla improved- a combination ofeasyNewLineandinlineResources
The specified language is then used to parse the file until the next @language directive is encountered.
Important to know: You can transpile those new parser features into a vanilla datpack using the /datapack build <datapack> command, which will output the final vanilla datapack as a zip file under saves/<your world>/builtDatapacks/