llms.txt и темы
Справочник для агента — на английском, из двух частей:
- Ядро — llms.txt, ~35 КБ. Синтаксис, ловушки сервера, цены, рабочий цикл, список тем. Агент читает его целиком до первой строки кода.
- 14 тем по 2–19 КБ — открывать по задаче. Всё вместе ~160 КБ.
Как дать агенту
- Командой: ядро —
jmvcc docs core, тема —jmvcc docs lists-maps(или начало имени, заголовок, слова). - MCP-инструментом
docs: ядро — безtopic, тема —topic: "lists-maps". - Ссылкой: ядро —
https://jmvcc.dev/llms.txt, тема —https://jmvcc.dev/topics/lists-maps.md.
jmvcc docs без темы — список тем с размерами, jmvcc docs all — всё сразу.
Все действия, значения и события по строке — signatures.txt (~30 тысяч токенов: искать по нему или звать jmvcc search, целиком в контекст не класть).
Скилл justmc для Claude Code сам велит прочитать ядро и называет, какую тему брать под задачу.
Темы
lists-maps— все имена для списков, словарей и текста,x[k], ячейкиtext-menus— плейсхолдеры, цвета, предметы, меню-сундуки, табло, боссбар, диалогиstructs-enums—enumдля фаз,structдля игрока и раундаfunctions-editions—edition 2, виды параметров,ref, несколько значений, inline, лямбдыerrors-match—try/catch/throw,match,?:,??async— смерть потоков, процессы,std::async/after/everygraceful-stop—std::session+event<jmvcc_stop>: вернуть ресурсы при/buildи деплоеrpc-bridge— MCP, все командыjmvcc client,rpc functionbuildings— дома, арены, декор, правка готовой карты; сам строитель пока только у автораdecompile— модуль JSON из игры →.jc,item_raw, головыrecipes— кулдаун, плиты, магазин, паркур, топ-N, раунд, боссlook-and-feel— как игру оценивают глазами: дисплеи, звуки, HUD, управление, камераserver-facts— все факты, проверенные на сервереcosts— полная таблица цен, дисплеи, постройка и смена карт
То же содержание печатает jmvcc docs. По-русски — руководство и Грабли и факты сервера.
Ядро целиком
Показать llms.txt
txt
# JustCode (.jc) — core reference for LLMs and coding agents
JustCode compiles to JSON code modules for the JustMC Minecraft server (Creative+ block coding); the compiler is JMVCC
(`jmvcc`). Read this core WHOLE before the first line of code. Details live in topics (list at the end): open one when
the task touches it — `jmvcc docs <topic>` (MCP: tool `docs`) or the page `https://jmvcc.dev/topics/<topic>.md`. Every
action / value / event is in https://jmvcc.dev/signatures.txt (one per line, ~30k tokens): search it, never guess names.
## Agent loop
```
jmvcc new main # new file main.jc, first line `edition 2`
jmvcc search <words> # actions, values, events AND item/block ids by name or meaning: jmvcc search gold pressure plate
jmvcc sig <name> # signature + description: player::title, value::health, item, %victim%
jmvcc sig player_kill_player # event: who takes part, placeholders, selectors, value:: filled in it; --full: whole enums
jmvcc check main.jc --json # ALL errors/warnings at once as JSON (file, line, column, code, message)
jmvcc compile main.jc # writes main.json; exit 1 on any error, nothing written
jmvcc compile main.jc -w # also warn about an empty main argument and defaults that surprise (time_unit = TICKS,
# remove_mode = FIRST, merging); --all-defaults: every filled-in default and empty argument
jmvcc trace main.jc # compact listing of what it compiled to — check it matches your intent
jmvcc client deploy main.jc # into the game (mod JMVCC Bridge): prints server errors and log(...) — see below
jmvcc decompile export.json -o main.jc # module JSON → .jc, checks the round trip (→ topic decompile)
jmvcc docs [topic] # this reference: no topic = list of topics
```
Errors include "Возможно: ..." (did-you-mean) and the expected signature — apply them literally. Warnings (`warning` in
check, «Предупреждение» in compile / trace): it compiled, but you used an alias or something suspicious. Habits from other
languages (let, print, len, `for x in range(5)`, `switch`…) get a hint with the JustCode to write instead.
Silent server bugs are warnings too (the code loads, then quietly does nothing) — fix them, each message says how:
`no-target` / `no-target-value` / `no-target-placeholder` (`player::` / `entity::` without `<selector>`, `value::health`
or `%player%` / `%uuid%` in code with no target: top level, `world_*` / `chunk_*` events, a NO_TARGET process, a function
called only from there — with no `select::` before; write `<all_players>` / `<last_entity>`, select first, or move it into
a player event; after `select::` actions act on the selection, read it with `value::x<current>` — plain `value::x` is
0, `%player%` stays literal text); `cancel-not-cancellable`
(`world::cancel_event()` in an event that cannot be cancelled: `jmvcc sig <event>` says «отменяется» / «не
отменяется»); `loop-no-wait` (`repeat::forever` without `code::wait` here or in a called function and without break /
return; `while` whose condition variables the body never changes); `divide-by-zero` (`/ 0`, `% 0`, `/= 0`,
`variable::divide` by a constant 0); `unreachable-code` (after return / break / continue / end_thread or an endless
`repeat::forever`); `local-other-handler` (error: a `var` used in another event / function — use `game var`).
Where things are: compiler `<JMVCC>` (your jmvcc folder), docs `<JMVCC>\docs` (this file, `topics/`, `recipes*.jc`; all signatures — https://jmvcc.dev/signatures.txt).
Launchers: `<JMVCC>\jmvcc.cmd` (cmd/PowerShell), `<JMVCC>/jmvcc` (Git Bash); old alias `jmcc` (`jmcc.cmd`). For events
`jmvcc sig` takes the bare name (`player_kill_player`): `'event<x>'` works only quoted, and `jmvcc.cmd` re-parses `<` `>`
through cmd.exe even quoted.
MCP: `jmvcc mcp` (stdio) has the same loop as tools; `deploy` / `stop` need `confirm: true` — only after the user agreed;
`send` can change the world too (install, VS Code → topic rpc-bridge). Compiler bug or missing feature:
`jmvcc report [file.jc] -m "what happened"` (MCP `report`) builds a markdown report — give the text to the user (for the author).
### Run it in the game (all commands → topic rpc-bridge)
**The player's life first.** Before EVERY deploy to a live world: `grep -n "location(" main.jc` and check every
teleport / spawn / respawn point against the MEASURED floor (the author's test world: 32×32, x,z -16..15, top block y=3, players
at y=4, void beyond = death; yours differs — `jmvcc client world-profile`): a block under the feet, not inside a block, water or lava. Unsure — measure
(`jmvcc client export`, → topic look-and-feel) or do not deploy. Never deploy someone else's code (recipes, examples,
benches) before checking its points (recipes tie them to `FLOOR_Y`: set it). Player died (`client status` →
DeathScreen, «умер» in logs) — stop at once: no more steps or deploys, tell the user, then deploy an empty module.
```
jmvcc client status # is the mod up, player on the server, remote control on, current session
jmvcc client deploy main.jc # compile → upload → /build, /dev, /module load-url, /play → wait 5 s → errors, log(...),
# module messages of the new session; exit 1 on errors. Exit 4 = refused to erase
# lines edited by hand: ask the user (never --force yourself)
jmvcc client world-profile # safe zone + floor: deploy refuses (4) points off it; never --allow-outside yourself
jmvcc client logs [--errors] [--since 42] # current session without chat; --since: only new events
jmvcc client vars game [substr] # game/save variables with values now
jmvcc client send "/play" # server command or chat message (never "!..." — global chat is blocked)
```
A runtime error line: `#17 19:01:52 error <action>: <reason> @ x y z` (action and reason from the server, x y z = the
code block). Fix the code, deploy again, read logs again. Exit codes: 1 error / failed deploy, 2 the mod is not running
(ask the player to start the game with it), 3 remote control is off (ask the user to type `/j remote on` in chat).
Git Bash rewrites a leading `/` into a path: write `"//build"` there or set `MSYS_NO_PATHCONV=1`.
`log("x = $x, top =", top)` — debug print for you: `player::message<all_players>("\u2063x = …")`, args joined by spaces,
`$x` / `%var%` as in messages, a statement only. The invisible U+2063 makes the mod log it as type `log`; your own
`function log(...)` wins. Every player sees it in chat: remove log lines when the code works.
## Program shape
```js
edition 2 // FIRST line of every new file (`jmvcc new` writes it): own vars per call
import "utils" // other .jc file, imports come right after it
game var round = 0 // global for the world (not saved)
save var %player%_coins // saved; %player% makes it per player; declare without value
event<player_join> { // events: jmvcc search <word> or https://jmvcc.dev/signatures.txt "## events"
player::message("Hi %player%") // %player% = current player's name inside text
%player%_coins ??= 10 // default for a new player (only if not set yet)
if (%player%_coins == 0) { // == != < > <= >= && || ! work in if (...) and while (...)
player::message("broke")
}
}
```
Statements are separated by newline or `;` (none needed after `}`: `if (x) { return 1 } return 0`). Top-level code
(outside events) runs in `world_start`. A file without `edition 2` is edition 1 (old files, docs/recipes*.jc): same
syntax, but `var` and parameters are shared with called functions; `jmvcc migrate file.jc` converts one
(→ topic functions-editions).
## Variables
- `var x = 1` — a variable of THIS code (this event run, this function call): a called function does not see or change
it, every call (also recursive) has its own, it survives `code::wait`, dies when that code ends. Loop variables and
`catch (e)` are the same; `line var` = `var`. `local var x` — shared by the whole thread (called functions see and change
it; rarely needed: pass a parameter or return a value). `game var` — whole world, lost on world restart. `save var` —
whole world, survives restarts. A top-level `var` belongs to `world_start` only and is empty in other events
(warning) — shared state is `game var`.
- A variable never assigned is the NUMBER `0` (also `0` in text) — not an empty list / map / location.
- `const N = 5` (= `inline var N = 5`) — compile-time constant, 0 actions; counts as a literal in factories.
- `x ??= v` assigns only if x does not exist yet. A `save var x = v` at top level is re-set on EVERY world start
(warning): write `save var top ??= {}` (in world_start), or `save var %player%_coins` + `%player%_coins ??= 0` in
player_join.
- Names may contain placeholders (`save var %player%_kills`); backticks allow any name: ``var `a b ${i}` = 1``. A backtick
or placeholder name used outside its declaration must itself be declared — the keyword decides the scope — otherwise
`unknown-identifier`. +1 saved win for the player whose name is in `w` (e.g. from a world loop):
``line var w = alive[0]; save var `${w}_wins`; `${w}_wins` += 1`` — resolves at runtime to `Steve_wins`, the SAME
storage as `%player%_wins` for Steve (and as `%killer%_wins` when Steve is the killer).
- `var x` (no value) declares without code (a new `var` is 0). Several at once: `var a, b = 0, c`, `game var x, y = 1`,
`save var %player%_a, %player%_b`, `line var i = 0, n` = one declaration per line. `game` / `save` declarations are
visible in the whole file (order does not matter); repeating one without a value is allowed.
- Taking values apart: `var [a, b] = [1, x + 1]`, `var [q, r] = divmod(17, 5)`, `var [x, _, z] = l`, `var [x, y, z] = loc` (location / vector: by coordinates), swap `a, b = b, a`;
`var a, b = f()` is a without value and b = f() (→ topic functions-editions).
- Map literal `{ "bread": 5, "sword": 50 }`, `{}`, `{ [name]: 1, 3: "x" }` (= `variable::create_map_from_values`); a bare
key `{ a: 1 }` is an error: `"a": 1` is a text key, `[a]: 1` uses the value of a.
- Text: `"coins: " + n` = `"coins: ${n}"` (one side must be a text literal; otherwise `+` is math).
- Time literals are TICKS: `5s` = 100, `20t` = 20, `1m30s` = 1800, `0.5s` = 10 (t = 1, s = 20, m = 1200).
`code::wait(5s)` = `code::wait(100)`; `code::wait(5s, "SECONDS")` is an error (`duration`), so is a part of a tick (`0.33s`).
- `assert(hp > 0, "hp = $hp")`, `debug { log("state $state") }` — only in a dev build (`--dev` or `--rpc` on compile /
check / trace / client deploy): `if not (c) { throw("assert main.jc:17: hp>0 — hp = …") }`; a release build has 0 actions
and does not evaluate the condition. `jmvcc check` always checks them.
- Compile-time types (→ topic structs-enums): `enum Phase { LOBBY, GAME }` (numbers; a typo is an error),
`game var state: Phase = Phase.LOBBY`; `struct Run { hp = 20 }` + `game var %player%: Run` → `%player%_hp` =
`%player%.hp`; defaults only via `%player% = Run()` (game) / `%player% ??= Profile()` (save).
## Values
- Numbers `1`, `-2.5`. Text `"a"` or `'a'`; escapes `\n \t \" \' \\ \$`. Interpolation `"$name"`, `"${expr}"`; a bare
`$word` must be a declared variable, `\$` is a literal `$`. Inside `${...}` goes a JustCode expression, never a
placeholder (`"${%var(x)}"` is wrong).
- Placeholders (filled in by the server; unknown ones warn; → topic text-menus): `%player% %entity% %victim% %damager%
%shooter% %killer% %selected% %display_name%`, each also `_uuid` (`%uuid%` = `%entity_uuid%`); `%random%`, `%time%` ...
- Booleans `true` / `false`: the switch TRUE / FALSE in a boolean argument (a condition works there too:
`player::set_allow_flying(hp > 5)` → if / else with TRUE / FALSE); the numbers 1 / 0 in variables (`"$on"` prints 1).
- Lists `[1, 2, 3]`: `l[0]`, `l[0] = 5`, `l[i] += 1`. Maps: create first (`m = {}`; save / game: `m ??= {}`), then
`m["k"] = 5` (a new key is added), `var v = m["k"]`, `m[k] += 1`. A missing key / index out of range reads 0 (also
for `== 0`). `x[k]` is a MAP when code above made or used x as a map or k is a text, otherwise a LIST; nested
`grid[y][x] = 1`, `m["row"][0] += 1` work (→ topic lists-maps).
- Math `+ - * / %`, unary `-x` = `%math(0-x)` (`-5` is a number). Functions (compile to %math): abs sqrt cbrt sign ceil(x[,digits]) floor(x[,digits])
round(x[,digits]) pow(x,y) root(x,n) min max clamp(x,lo,hi) wrap(x,lo,hi) sin cos (degrees) sinr cosr (radians) asin
acos atan2(y,x); a declared function with the same name (except the first 11) wins.
- `x += 1; x -= 1; x *= 2; x /= 2; x %= 3; x++; x--; x ??= 0` (`op=` also on items: `l[i] += 1`, `m["k"] -= 1`,
`grid[y][x] *= 2`; not `++` / `??=`). `i++` in an expression works as in C/JS (old value, i changes once at once:
`while (i++ < 3)`, `f(i++)`, `l[i++]`; one temp inside a condition or next to other reads); an `i` LEFT of `i++` in
the same statement (`l[i] = l[i++] + 1`) already sees the new value — warning; put `i++` on its own line.
- Factories (arguments must be LITERALS or `const`, a `var` is a type-mismatch error): `item("diamond_sword")`,
`item(id, name, count, lore = [...])` (`&` codes → colored), `location(x, y, z, yaw, pitch)` (yaw defaults to 90!
always pass yaw AND pitch; pitch > 0 looks down), `vector(x, y, z)`, `sound("entity.player.levelup")`,
`particle("flame")`, `potion("speed")`. With variables `location(x, y, z)` / `vector(...)` are one action
(`set_all_coordinates`). Fields: `loc.x .y .z .yaw .pitch`, `v.x`; `loc.y = 70`, `loc.y += 1`. Block states go as TEXT
into a block argument (`world::set_block("oak_stairs[facing=north,half=top]", loc)`, checked), never into `item()`.
- Game values: `value::health`, `value::location<killer_entity>` ("## value" in signatures.txt). Value selectors:
current default default_entity killer_entity damager_entity victim_entity shooter_entity projectile last_entity.
## Calling actions
```js
player::message(["a", "b"], merging = "SEPARATE_LINES") // positional, then named
player::message("one value") // list args (type[N]) take [..] or one value
player::message<all_players>("to everyone") // <selector> picks the target (`jmvcc sig` lists them)
code::wait(5, time_unit = "seconds") // enums are case-insensitive
var n = variable::length(list = scores) // actions shown as "var x = ..." return a value
world::chunk_get_custom_tag(n, loc, "tag") // same, older form: output variable first, alone on a line
var len = scores.length() // same via dot: only variable:: actions with a receiver
scores.sort() // a modifying action alone on a line updates the receiver
```
A query result must be used (`l.length()` alone on a line is an error); a condition alone on a line is an error (wrap
it in `if`). Objects: `player entity world variable code select repeat value`. Names here are JMVCC names; the server name
(`jmvcc sig` shows «на сервере: …») works too with the same JSON. Full ids (`player_send_message`), ids without prefix
WITH the object (`player::send_title` → `player::title`; a bare `send_title(...)` is an error naming `player::title`),
`game::` = `world::`, `if_player::` = `player::` work with a warning — use the name it prints.
Omitted arguments: enums get their FIRST value (or the `=X` in the signature), booleans the shown `boolean=TRUE/FALSE`,
the rest stays empty — pass important ones explicitly; `-w` lists `implicit-default` / `empty-argument` (a missing `subtitle` or `amount`; silent where
empty means something: `play_sound` without `location` = heard by the player, `event_block_equals` without `locations` =
the event block (reported in events without one, e.g. `player_join`), `on_range` without `interval` = step 1). Where the
server menu has another default the signature shows it (`(в меню INCLUDE_ALL)`) and omitting warns
`implicit-default-differs`: `number_in_range` without `including` EXCLUDES both ends, `set_equipment` without `slot` is
CHEST, not HAND. Arguments the server added later (`!=`'s `compare_type`, `lerp_number`'s `easing`, `move_to_location`'s
`navigation_mode`) are not written when omitted (server default: ALL, NONE, ...). Old forms warn (`legacy-argument`:
`input_only_type = true` → `input_match = "ITEM_TYPE"`; `enum-renamed`: pose `SNEAKING` → `CROUCHING`); values the server
dropped (gamerule `SPAWN_CHUNK_RADIUS`, ...) are an error `removed-enum-value`: the server refuses such code.
## Most used JMVCC names (all of them, kinds, prelude → topic lists-maps)
One method name picks the list / map / text action by what the variable holds (created above, a result, a literal, a
`value::`, a parameter type `function f(m: map)`); not known → list action + `kind-guessed` warning, a wrong kind →
`kind-mismatch` error with the replacement.
- Lists: `l.append(x)` (a list goes in as ONE element), `l.extend(o)`, `l.insert(i, x)`, `l.remove(x)` (by value),
`l.remove_at(i)`, `l.get(i, default)`, `l.index_of(x)` (-1 if none), `l.contains(x)`, `l.is_empty()`, `l.length()`,
`l.sort()`, `l.reverse()`, `l.shuffle()`, `l.unique()`, `l.join(", ")`, `l.random()` (an element), `l.slice(a, b)`
(from 0, end excluded; outside the list = server error `index_out_of_bounds`).
- Prelude (compiled to the loop you would write): `l.filter(x -> x > 5)`, `l.map(x -> x * 2)`, `l.each { x -> ... }`,
`l.any(...)`, `l.all(...)`, `l.count(...)`, `l.find(...)` (0 if none), `l.find_index(...)` (-1), `l.sum()`,
`alive = alive.keep_in(value::all_players_names)` (players still online).
- Maps: `m.get(k, default)`, `m.set(k, v)`, `m.remove(k)`, `m.has_key(k)`, `m.keys()`, `m.values()`, `m.length()`,
`m.merge(other)`, `m.clear()`; sorted: `variable::sort(map = m, sort_order = "DESCENDING", sort_type = "VALUES")`.
- Text: `t.length()`, `t.contains("a")`, `t.starts_with("a")`, `t.index_of("a")`, `t.split(",")`, `t.replace("a", "b")`,
`t.strip()`, `t.slice(a, b)` (clamped), `t.parse_int()` (integers only), `t.get_char_at(i)`.
- Others: `player::give_item`, `remove_item`, `give_potion_effect`; `entity::set_health`; `world::spawn_entity`;
`code::wait(t)`, `code::end_thread()`, `code::stop_repeat()`, `repeat::times(n) { i -> }`,
`repeat::for_each_in_map(m) { k, v -> }`, `select::player_by_name([name])` ... `select::reset()`.
## Conditions
```js
if (a > 5) { ... } else if (a == 5) { ... } else { ... }
if (value::health < 5 && !player::is_sneaking()) { ... } // && || ! and ( ) combine anything
if (x == "red" || x == "blue") { ... } // == / != work for any type, < > <= >= for numbers
if not (player::has_item(item("diamond"))) { ... } // = if (!player::has_item(...)); condition actions: [условие] in sig
var kit = vip ? "gold" : "iron" // = if (vip) { kit = "gold" } else { kit = "iron" }
var label = match (state) { State.LOBBY -> "Lobby", State.GAME -> "Game", else -> "?" }
var ok = hp > 5 && lvl < 3 // 1 or 0; then if (ok) / if (!ok && x > 1)
var price = prices[id] ?? 10 // missing key → 10 (same read action); nick ?? "guest"
```
`a < b` is the same action as `a.less(b)`. `&&` nests ifs (the right side runs only when the left is true); `||` uses a
temp. Ternary branches are lazy; a ternary alone on a line is an error (`ternary-statement`); a constant condition
(`const DEBUG = 0`) picks the branch at compile time. `if (ok)` only for a yes/no variable (only comparisons, true /
false, 0 / 1, yes/no functions written to it, or `var ok: bool`); text in `if (name)` is error `bool-text` — write
`if (name != "")`. `??` only on a variable and `m[k]` / `l[i]` / `m.get(k)` (`coalesce-target`); `x ??= f()` calls f only
when x is not set. `a < b < c` is a syntax error. `return` is a reserved word. Selectors use `<>`:
`value::health<killer_entity> < 5` (→ topic errors-match).
## Loops
```js
for (i in 0..<n) { ... } // 0 … n-1 (..< — without the end)
for (i in 1..=10 step 2) { ... } // 1 3 5 7 9 (..= — with the end)
for (name in alive) { ... } // list values; for (i, name in alive) — index and value
for (k, v in scores) { ... } // map: key and value (chosen by what scores holds, like x[k])
while (hp > 0 && alive.length() > 1) { ... } // re-checked every step, f() and l[i] too
while (true) { code::wait(20) } // = repeat::forever()
if (x in 1..=5) { } if (k in [2, 4, 8]) { } if (name in alive) { } if (key in scores) { } if ("ab" in t) { }
match (hp) { <= 0 -> dead()
1..=5 -> low()
6, 7 -> mid()
else -> ok() }
```
- Same JSON as `repeat::`: `a..=b` = `repeat::on_range(a, b)` (end INCLUDED), `a..<b` = `on_range(a, b - 1)`,
`for (x in l)` = `for_each_in_list`, `while (c)` = `repeat::while(c)`; `repeat::forever() { }`,
`repeat::for_each_in_list(l) { i, v -> }`, `repeat::on_range(0, 10) { i -> }` work too. An empty range (`0..<0`, `5..=2`) runs 0 steps; down: `for (i in 10..=1 step -1)`, `10..<0 step -1` (10 … 1);
`step 0` and bare `a..b` (`range-syntax`) are errors.
- `x in a..=b` = `number_in_range` (≈1.5, cheaper than two comparisons), `x in [1, 2]` = one equals with a list,
`x in l` = `l.contains(x)`, `k in m` = `m.has_key(k)`, `"ab" in t` = `t.contains("ab")`; right side not known — error
`in-kind`. A range arm in `match` is one check; a range and values in one arm — split into two arms.
- In a loop `break` leaves it, `continue` skips to the next step. Outside a loop `break` ends the whole event /
function thread.
## Functions and processes
```js
function sq(x) { return x * x } // works for functions declared below too
var a = sq(3) + sq(4) // calls inside an expression run before it is computed
function check(n) { if (n < 0) { return 0 } return n } // return on EVERY path, or the old value leaks
function is_top(n) { return n > 5 } // yes/no: if (is_top(s) && !is_top(o)); in while: is_top(i) == 1
function take(ref coins, price) { if (coins < price) { return false }
coins -= price
return true } // ref: the caller's variable (the argument must be a variable)
function divmod(a, b) { return floor(a / b), a % b } // var [q, r] = divmod(17, 5)
inline function low(h) { return h < 5 } // pasted at every call: if (hp < 5), ≈1 instead of ≈13
process spawn_wave() { ... } // spawn_wave() starts it in parallel; no return value
```
- Edition 2: each call has its own parameters and `var`s (recursion works: 500 nested calls, 5000 stop the line). A
parameter is a VALUE (`x += 1` inside does not change the caller's: return it or use `ref`); a list / map argument is
the SAME list (`l.append(x)` inside is seen outside). Defaults / names: `f(a, b = 1)` → `f(5)`, `f(a = 2, b = 3)`. Types
`f(n: number, t: text, l: list, m: map, v: vector, p: location, i: item, s: Phase, on: bool)` pick the method's action,
a call with another kind is a compile error, the server checks them at every call; untyped → kind from all calls.
`return` without a value leaves; in an event it ends the event. Inline functions, lambdas `x -> ...` (only for an
inline `body: fn` parameter), `@icon` / `@description` / `@hidden`, edition 1 → topic functions-editions.
- Threads die with their target: a player event and a process started from it with `name()` stop MID-EXECUTION when the
player leaves (an entity dies; `entity_death` goes on after `code::wait`). `/play` typed again fires `player_join`
again and the OLD `repeat::forever` there keeps running (two loops) — use `std::every`, it replaces itself. World loops:
top-level code or `std::async(target = "NO_TARGET") { }`.
- Background (→ topic async): `std::async { risky() }` (own process: its error does not stop this line),
`std::after(40) { door = 0 }` (in 40 ticks, code below goes on), `std::every(1s) { hud() }` (first run at once, `break`
stops it; `std::every(20, "hud")` + `std::cancel("hud")`). A captured `var` written inside changes only the copy
(`async-write`): shared state → `game var`.
- Error isolation: a server error stops the REST OF ITS CODE LINE, also the caller's when it is in a called function;
other events and processes go on. Top-level code is ONE line: start the world loop first (only plain setup before it)
or in its own `std::every` / `std::async`; risky actions (item components, NBT, ray traces, guessed enums) → `std::async`.
- Row length: an event / function / process loads only with ≤ 67 blocks (`jmvcc trace` count); the compiler cuts longer
rows into `jmcc.fN` itself; a `return` / `break` that would land in such a tail is a check error — move that code into
your own function. A module holds ~526 rows (Star) / 548 (Nova). Functions are for reuse, not length (a call costs).
## Errors, match, std::
```js
try { give_reward(l.slice(1, 9)) } catch (e) { log("failed: $e") } // e: server error id or the throw message
if (hp < 0) { throw("hp < 0: $hp") } // stops the line; try catches it (also inside called functions)
match (phase) { // = if / else-if chain; x evaluated once
Phase.LOBBY -> start_lobby()
GAME, END -> { log("busy") } // several values; bare members of an enum work
else -> log("?") // optional, last
}
var t = std::mmss(ms) // ms → "01:15" (hours dropped), one action, 4× cheaper than by hand
var h = std::hmmss(ms) // "1:02:05"; std::time(ms, "m:ss.SSS") — any pattern
std::with_player(name) { player::message("hi") } // select::player_by_name([name]) … select::reset()
```
No `finally`, `switch`, `catch (e: T)`; `=>`, `_`, `default` in match are errors (use `->`, `else`). `std::` times take
MILLISECONDS (seconds → `std::mmss(secs * 1000)`). In `std::with_player` read values with `<current>`
(`value::health<current>`); a bare `value::x` there is an error (→ topic errors-match).
Long sessions (a craft with a wait, a round) and `/build`: `std::session("name") { }` + `event<jmvcc_stop> { }`
(→ topic graceful-stop). Calling functions of the RUNNING code: `rpc function` (→ topic rpc-bridge).
## Server traps (verified; they break code silently)
- Never-set variable = number 0: `m[k] = v` / `set_map_value` on it is a server error that stops the line, `l.append(x)`
does NOTHING (still unset), `l.remove(x)` is an error. Create first: `m ??= {}`, `l ??= []`. Before teleporting to a
stored location keep a flag (`%player%_has_cp = 1`). `var b = a` COPIES a list.
- Explicit `get_map_value` / `get_list_value` without `default_value` on a missing key gives null: prints "0" but
`== 0` is FALSE. `m[k]` / `l[i]` pass `default_value = 0` for you.
- `value::event_block_type` is the FULL state (`"minecraft:light_weighted_pressure_plate[power=0]"`): `==` with an id is
always false — use `world::event_block_equals([item("id")])` / `world::block_equals(loc, [item("id")])`.
- Everything code builds or spawns (blocks, mobs, displays, NPCs) SURVIVES `/play` and `/build`; game vars do not.
Top-level code runs on every world start: spawn once — `save var npc` + `npc ??= ""` +
`if (!world::has_entity([npc])) { world::spawn_mob(...); npc = value::uuid<last_entity> }`; keep uuids of spawned
things in a save var and remove leftovers on start.
- `break` outside a loop inside a function ends the WHOLE calling line; leave a function with `return`; stop the
caller's `repeat::forever` with `code::stop_repeat()`. A function with `code::wait`: the caller waits for it.
- Changing a list inside `for (x in l)` over it stops the loop after the current step (`loop-list-modified`).
- Two functions with the same name: a call runs BOTH (`duplicate-function`). `code::controller_async_run` does not work
(`async-run-broken`).
- Text: `%%` is NOT an escape — never write it. A text keeps ≤ 25000 characters, the rest is cut silently
(`text-too-long`). Colors `&a`, hex `&#RRGGBB` work; MiniMessage `<red>` and `§b` do not; color FIRST, then `&l`.
Numeric text works in math (`var s = "5"; s * 2` = 10; the literal `"5" * 2` is a compile error); a non-numeric text in
`>` / `number_in_range` is a server error. `-7 % 60` = -7; `floor(75 / 60)` = 1; `sin` / `cos` take degrees.
- Units: shown in signatures; `code::wait` defaults to TICKS (20 = 1 s); `potion(..., duration = 200)` = 200 ticks;
`value::timestamp` = UNIX ms. `give_item` without `amount` gives the item's count. Boss bar progress is 0..100.
- Events: on `/play` top-level code runs first, then `player_join` — also for players already in the world.
`player_move` fires every tick while moving (20/s). Standing on a pressure plate fires `player_interact` (physical)
~2 times a second: cooldown or act on a NEW plate. `player_right_click` fires once per click (filter
`value::event_equipment_slot != "hand"`); an empty hand into the air fires nothing. Death not caused by a player:
`%killer%` / `%victim%` stay literal text. Open questions: whose name `%player%` is in a text sent `<all_players>` —
capture `line var who = "%player%"` first; the default player of `player_kill_player` — use `%killer%` / `%victim%`,
`<killer_player>` / `<victim_player>`.
- `world::set_block(...)` from a loop: pass `update_blocks = true` (or changes may not show up on the client); at most
3000 locations per call, the rest is dropped silently.
- Measure the world, never assume the floor; never teleport a player over air (see «The player's life first» above).
- Menus: `show_menu` puts the 1st item in slot 0, `value::event_slot` counts from 0; only clicks in the menu half reach
`player_click_inventory` (own inventory → `player_click_own_inventory`) (→ topic text-menus).
## Costs (measured; full table → topic costs)
One simple action (`a = i`) = 1 ≈ 0.7 µs. Budget in % of `value::cpu_usage` (read it on the spot): heavy code ≤ ~3 ms per
tick, peaks ≤ 80%; sustained > 100% crashes the world (high_cpu).
- `==` / `!=` ≈8 (equals with a list), `>` `<` `>=` `<=` ≈1, `x in a..=b` / number_in_range ≈1.5. With `-O`
(`jmvcc client deploy -O`) `x == 5` becomes number_in_range when x only holds numbers; enums: `state == Phase.GAME`
≈1.5 vs text ≈8. `k == a || k == b` ≈14 per term → `x in [a, b]`. Dispatch by key: a list / map
(`code::call_function(LF[k])`), never an `==` chain (10 branches ≈46).
- `m[k]` ≈1.2, `m[k] = v` ≈1.8, `l[i]` ≈1, `l[i] = v` ≈1.5, `l.append` ≈7.5 (several values in one `append([a, b])`),
`l.index_of(x) > -1` ≈2.6 vs `contains` ≈9, `"$a$b"` ≈2, `%math` ≈3, `+=` ≈1. Reading a big list out of a map copies it.
- A call ≈2 (+ arguments / return), `start_process` ≈4 (runs at once, up to its first wait), loop step ≈0.5,
`while` with a counter ≈1.8. A sleeping process is free: `wait(5)` / `wait(20)` where every tick is not needed.
- Output: particle ≈17, action bar ≈8, sound / title ≈3; display spawn ≈40 µs. No per-tick particles or displays; HUD
once a second from one loop; effects only on events.
## Common mistakes → write instead
`l.add(x)` → `l.append(x)` (`add` is a number sum); `t.trim()` → `t.strip()` or `t.slice(a, b)`; `t.to_number()` →
`t.parse_int()`; `x.count()` → `x.length()`; `repeat::range(0, n)` → `repeat::on_range(0, n - 1)` / `for (i in 0..<n)`;
`variable::random([1, 10])` is "1 or 10" → `variable::random_in_range(1, 10)`; `send_title(...)` → `player::title(...)`;
`item(name_var)` → a literal or `const`; `save var x = 0` at top level → `x ??= 0`; a hand-made mm:ss → `std::mmss(ms)`;
an emoji from memory → a symbol from `/symbols 1..8` in game; `log` left in a finished game → remove it.
## Recipe (edition 2, compiles as is; more → topic recipes)
```js
edition 2
inline var FLOOR_Y = 3 // top floor block of YOUR world: measure it; players at FLOOR_Y + 1
save var %player%_coins
save var %player%_last_use
event<player_join> {
%player%_coins ??= 0 // default only for a new player
player::message("Coins: ${%player%_coins}")
std::every(1s) { player::action_bar("&6Coins: ${%player%_coins}") } // HUD; a 2nd /play replaces it
}
event<player_right_click> { // cooldown via timestamp (ms); return ends the event
if (value::event_equipment_slot != "hand") { return }
var now = value::timestamp
if (now < %player%_last_use + 3000) {
player::action_bar("&cCooldown!")
return
}
%player%_last_use = now
player::play_sound(sound("entity.experience_orb.pickup", 0.3, 1.8))
}
event<player_interact> { // pressure plate: check the type with event_block_equals
if (value::event_interaction == "physical" && world::event_block_equals([item("stone_pressure_plate")])) {
player::teleport(location(0, FLOOR_Y + 1, 0, 0, 0), keep_rotation = false)
}
}
event<player_kill_player> { // name the killer explicitly (same storage as their %player%_coins)
save var %killer%_coins
%killer%_coins += 10
player::message<killer_player>("+10 coins, victim: %victim%")
}
```
## Not in the language
`switch` (use match), `finally`, nested destructuring `[a, [b, c]]` / `...rest` / `{a, b} = m` (read a map by key),
classes (inheritance, virtual methods — `struct` is plain fields; `x.f()` calls your `f(x)`), kind types on variables
(`var x: list` is an error: a variable's kind comes from its value; `: Type` on a variable — only your own enum / struct;
kinds `number|text|list|map|…` — only on function parameters: `function f(x: list)`), lambdas as values (only arguments
of an inline function), code values on the server.
## Topics
Open with `jmvcc docs <name>` (a prefix or keywords work too; `jmvcc docs` lists them, `jmvcc docs all` prints
everything), the MCP tool `docs` with `topic`, or the page `https://jmvcc.dev/topics/<name>.md`.
- `lists-maps` (10 KB) — all list / map / text names, how methods and `x[k]` pick the kind, prelude, cells
- `text-menus` (9 KB) — placeholders, colors, items, chest menus and clicks, sidebar, boss bar, dialogs
- `structs-enums` (5 KB) — `enum` phases, `struct` state per player / round, struct methods
- `functions-editions` (12 KB) — edition 1 vs 2, parameter kinds, `ref`, several values, inline, lambdas, `@icon`
- `errors-match` (5 KB) — try / catch / throw, `match`, ternary, yes/no variables, `??`
- `async` (6 KB) — thread death, processes, `std::async` / `after` / `every`, generation tokens, error isolation
- `graceful-stop` (7 KB) — `std::session` + `event<jmvcc_stop>`: give resources back on `/build` / deploy
- `rpc-bridge` (12 KB) — MCP setup, every `jmvcc client` command (tests, menus, keys, items, /hdb heads), `rpc function`
- `buildings` (3 KB) — the builder tool (not in the public build yet): houses, arenas, decor, heads with skins, improving an existing map
- `decompile` (3 KB) — in-game module JSON → .jc, `item_raw` and other raw values, custom heads
- `recipes` (15 KB) — cooldown, plates, shop menu, parkour, top-N, mini-game round, boss fight
- `look-and-feel` (12 KB) — what players want to see: info on objects, flat text, sounds, HUD, controls, camera
- `server-facts` (19 KB) — every fact verified on the server, plus open questions
- `costs` (7 KB) — the full price table, displays, building / switching maps