Project

CLI and editors

One tool, crafting, to install, create a mod, check it and test it without opening the game. And a language server that gives your editor the same errors you'd see when loading the mod.

command not found: crafting. After building, the executable is at crafting-cli/build/install/crafting/bin/crafting. Add that folder to your PATH or link it from one that already is, for example ln -s "$PWD/crafting-cli/build/install/crafting/bin/crafting" /usr/local/bin/crafting.

Commands

Command What it does
install --mc 26.3 [--dir DIR] Adds the Crafting profile to the official launcher.
install --mc 26.3 --server DIR Sets up a server folder with start-crafting.sh and .bat.
new <name> [--kind script|kotlin|plugin] Creates a new mod.
check <file.craft>… Checks syntax and types.
sandbox [folder] Simulated server for testing mods without the game.
mods [folder] Lists the mods in a game folder and checks their dependencies.
lsp Language server for editors (the editor launches it).
version Crafting version.

Create a mod

Creates a mod already split by responsibility, as recommended in Organizing a mod:

Command Creates
crafting new gems main.craft, content/items.craft, content/blocks.craft, content/recipes.craft, events/welcome.craft, commands/gem.craft
crafting new gems --kind kotlin GemsMod.kt (only wires up the parts), content/ModContent.kt, events/Welcome.kt, commands/GemCommand.kt, a manifest and build.gradle.kts for Java 25
crafting new gems --kind plugin The entry class, events/ChatFilter.kt and commands/HelloCommand.kt

Check a mod

Checks the syntax and types of one or more .craft files, following their imports. Each error includes the file and line, plus a suggestion when there's a similar name. It exits with a non-zero code if there are errors, so you can use it in continuous integration.

Terminal
crafting check mods/rubies/main.craft

Test in the sandbox

A simulated server with the same API as the game. It loads the mods in <folder>/mods and <folder>/plugins in development mode: saving a file reloads the mod.

Commands inside the sandboxText
join <name>                   a player joins
leave <name>                  leaves
as <name> <chat or /command>  chat or run a command as that player
/<command>                    command as the console
break <name> <x> <y> <z>      break a block
tick [n]                      advance n ticks
op <name>                     grant operator permissions
inv <name>                    show the inventory
reload <mod>                  reload a script or plugin
quit                          exit

Editors

They all use the same language server, crafting lsp, which runs the real CraftScript checker. They need crafting on the PATH.

VS Code

The CraftScript extension provides: highlighting (including {interpolation} and &a colors inside strings), errors as you type, typed autocompletion (after player., after on, after :, and for your classes and imported modules), hover information, snippets, and the Check current file and Run sandbox server for this mod commands.

Terminal
git clone <extension-repository> craftscript-vscode && cd craftscript-vscode
npm install --omit=dev
npx @vscode/vsce package --allow-missing-repository
code --install-extension craftscript-0.1.0.vsix

If crafting isn't on the PATH, set its path in the craftscript.craftingPath setting.

Neovim 0.11+

~/.config/nvim/plugin/craftscript.luaLua
vim.filetype.add({ extension = { craft = "craftscript" } })

vim.lsp.config("craftscript", {
  cmd = { "crafting", "lsp" },
  filetypes = { "craftscript" },
  root_markers = { "main.craft", ".git" },
})
vim.lsp.enable("craftscript")

Helix

~/.config/helix/languages.tomlTOML
[language-server.craftscript]
command = "crafting"
args = ["lsp"]

[[language]]
name = "craftscript"
scope = "source.craftscript"
file-types = ["craft"]
roots = ["main.craft"]
comment-token = "//"
indent = { tab-width = 4, unit = "    " }
language-servers = ["craftscript"]

Sublime Text and JetBrains

Sublime Text: the LSP package with the command ["crafting", "lsp"] for .craft files, and the CraftScript.tmLanguage.json grammar. JetBrains: the LSP4IJ plugin with the same command, and import the grammar as a TextMate bundle. The grammar works in any editor that reads .tmLanguage files.