Skip to content

Add the Sand language, language server, and Zed support - #507

Open
ThatOneToast wants to merge 18 commits into
mainfrom
t3/evaluate-custom-datapack-language
Open

ThatOneToast wants to merge 18 commits into
mainfrom
t3/evaluate-custom-datapack-language

Conversation

@ThatOneToast

@ThatOneToast ThatOneToast commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

.sand files express gameplay and compile through the portable backend shared with Rust and JSON packs. Language projects need neither Cargo nor sand.toml.

Language and runtime

  • Scalar types (number, fixed-point float, bool, enums), constants, modules, imports, and privacy.
  • Functions with parameters, mutable parameter bindings, return values, recursion, and caller-frame preservation for reentrant calls.
  • Generic functions, nominal records, and impl methods specialize through the shared typed call/value model. Calls infer types or accept ::<...>, including qualified constructors and method parameters. Instances have separate slots and context inference, bounded expansion, and authored source identities for navigation/rename. Concrete signatures drive nested-type signature help and call-result completions.
  • Nominal nested structs in locals, function arguments/returns, event payloads and State fields, sharing the existing score-slot/call model. Copies are independent and literal fields evaluate in authored order.
  • Fixed arrays ([T; N]) support literals/repeats, nested values, indexed reads/writes, borrowed element methods, snapshot iteration, and len/is_empty/contains/get_or/fill. Runtime invalid reads return the element default; invalid writes and mutable method calls leave the target unchanged.
  • Growable Vec<T> values reuse typed owned storage across State, records, arguments/returns and events, including recursive records through vectors. Indexing and mutable element methods use frozen addresses. Bounded push/pop/insert/remove/extend/clear/truncate, deep equality, array conversion, and snapshot iteration have native proofs. Strings can also be iterated by Unicode scalar character.
  • Missing entity-State reads use the value type's default instead of retaining a previous getter call's data; scalar reads check existence without creating source scores. Reattaching still applies declared field defaults.
  • Owned string values work in State, structs, arrays, constants, parameters, returns, and event payloads. Concatenation, equality, Unicode scalar indexing/slicing, substring methods, and scalar/enum to_string share the typed value/call/frame model. Runtime messages display plain text; styled formats may interpolate stored strings.
  • Typed portable storage fields/projections/operations reuse canonical NBT values and UUID State lifecycle. Stored values never become command macro text; numeric indices are staged before writes. Typed NBT strings safely escape control characters.
  • Retained EntityRef values use the canonical pack-owned runtime identity allocator. Explicit entity/player resolution skips absent entities; online players resolve across dimensions. damage(amount, by = reference) preserves attacker kill credit.
  • Inherent impl blocks for structs and State: associated functions, Self, value self/mut self receivers, State &self/&mut self receivers, visibility, method imports and executor inference. Read-only State receivers reject direct writes, mutable method calls, timer mutation and State detachment.
  • Computed assignments snapshot their RHS before the final destination write. Casts and bounded float compound arithmetic clamp only after conversion/rescaling.
  • Runtime start_timer ticks/seconds, with positive range guards and checked seconds conversion. Invalid runtime durations leave the timer unchanged.
  • Value-producing exhaustive matches share typed constants and dispatch with statement matches; flat dispatch handles large arm counts without operation-depth growth. Nested record/fixed-array destructuring supports renamed fields, omitted fields, ignored values and per-binding mutability. Shorthand-aware editor renames preserve member and local identities.
  • Locals, early returns, boolean expressions and predicate values in arguments, exhaustive statement match with constant alternatives, loops, counting ranges, .rev(), .step_by(n), and loop jumps. Range bounds and runtime command arguments evaluate once in source order.
  • Player/global/entity State, flows, timers, typed custom events, vanilla player events, entity queries, executor actions, properties, world operations, text, and basic resources.
  • Runtime item counts, damage, experience, sound volume/pitch, and teleport coordinates use canonical typed operands. Invalid runtime bounds skip the command; invalid constants produce diagnostics. Runtime teleport coordinates preserve exact positions without Minecraft's integer block-centering.
  • Constant signed division, remainder, and fixed-point arithmetic follow the runtime's floor semantics.
  • Offline Mojang-report catalogs for each verified target drive language checking, completion, and portable backend validation. A CLI built for 26.3 rejects 26.3-only vanilla content when targeting 26.2. Catalogs are refreshed through an explicit verified maintenance generator.
  • Compiler capability metadata derives operation/event vocabulary from the schema and advertises all catalog targets.

Tools

  • sand lang new|check|build|run|emit|zed; sand run recognizes language projects.
  • Package-wide sand fmt and sand lang fmt, including --check.
  • LSP diagnostics, hover, signature help, navigation, rename, completion, formatting, naming/mutability quick fixes, symbols, and inlay hints.
  • Generated tree-sitter parser and Zed extension, including struct/impl/receiver syntax, nested projections, method completion/signatures, navigation, rename and outline groups.
  • Blinkstep example demonstrates encapsulated position values, player State methods and runtime cooldowns.
  • CI runs a 20-assertion control-flow probe, 10 assignment/timer assertions, 12 record/method assertions, and a two-player runtime operand/State-method probe on vanilla 26.2, retaining failure artifacts.

The guide, parity table, and remaining expansion checklist are in book/src/language.md and ROADMAP.md.

Remaining scope

This PR does not yet deliver every requested language extension. Maps/sets, general borrowed slices, first-class functions/closures, traits, suspended continuations (wait), richer persistent entity relationships, broader resource/world APIs, language-authored tests/debugging, and the high-level Rust gameplay systems remain unfinished. Struct methods support value, read-only borrowed, and mutable borrowed receivers; mutable receiver updates commit on return through the shared call model. State receivers address persistent storage. These do not introduce general Rust reference values. Value matches produce owned values from comma-separated expressions; block expressions, binding/guard match patterns and enum payloads remain pending. Real Zed-session interaction remains unverified: the native UI tool reports cgWindowNotFound despite Zed being listed as running. Minecraft's numeric and command execution limits still apply.

Validation

  • The preceding increment passed scripts/check.sh; the latest expansion checkpoint has focused compiler/LSP and portable-backend tests plus native proofs. The final full repository gate remains pending while the broader expansion continues.
  • git diff --check passes.
  • Focused regressions cover record storage/copying, recursion, event payload isolation, field privacy, receiver mutability/context, associated imports, editor method queries, numeric semantics, operand types/ranges, malformed portable fields/scales, target filtering and resource validation, version aliases, capabilities, and nested grouping.
  • Vanilla 26.2: all 20 arithmetic/control-flow, 10 assignment/timer and 12 record/method assertions pass in repeated invocations; startup and reload also pass.
  • Vanilla 26.2 with two real passive clients: separate inventories, experience and State-method counters, invalid item/damage guards, custom-item macro text, sound command loading, player position/attribute properties, entity damage, and coordinate argument order pass. This verifies server behavior, not rendered client UI or active controls.
  • Tree-sitter parses the record fixture and all Blinkstep modules without errors; highlighting queries compile and run.
  • Blinkstep builds without language warnings; a maintained test compiles its modules.

Latest expansion checkpoint: ten vanilla borrowed-receiver assertions pass. The two-player probe verifies identity across reload, cross-dimension player resolution, empty/dead reference handling, and separate vanilla kill credit. A maintained marked-combat example combines retained ownership, entity timers, recipes and mutable methods.

Fixed-array checkpoint: 40 assertions pass on vanilla 26.2, including nested records, independent copies, recursion, indexed mutable receivers, invalid indices, snapshot iteration, and loop jumps. The quest-board example builds without warnings. Array formatting, completions, signatures, and generated tree-sitter parsing have focused regression coverage. The final full repository check remains pending while the broader expansion continues.

Runtime-text checkpoint: 66 assertions pass on vanilla 26.2, including integer/fixed-point limits, Unicode, control characters, arbitrary literal macro-like text, recursive calls and borrowed methods, events, and entity attach/detach. The two-player probe verifies independent text values across reload and exercises runtime chat. All language/LSP tests, focused portable storage and ownership tests, API coverage guards, Python harness regressions, Clippy, formatting, schema generation checks, documentation links and git diff --check pass. The saved journal example builds without warnings; tree-sitter parses the text fixture without errors. The full repository gate must still run against the final expansion.

Vector checkpoint: 95 assertions pass on vanilla 26.2, including recursive records, event copies, snapshots, loop jumps, capacity boundaries, and a reproduced stale-read regression after entity-State detachment. The two-player probe verifies independent vectors across reload and retains all entity-resolution/kill-credit checks. Array (40) and text (66) native regression fixtures pass. All language/LSP tests, Clippy, Python checks, schema checks, generated tree-sitter parsing, documentation links and whitespace checks pass; the exploration-log example builds without warnings. Expanded constant text and State defaults have checked allocation budgets. Indexed receivers now offer editor completion/signatures. The final full repository gate remains pending until the requested expansion is finished.

Pattern checkpoint: 29 native assertions pass on vanilla 26.2 with repeated invocations and reload, including selected-only evaluation, scrutinee snapshots, recursive owned results, deep destructuring copies and loop control. The existing 20-assertion control-flow native regression passes. Focused pattern/IDE/parser tests, Clippy, generated tree-sitter parsing, docs links and whitespace checks pass; the mining-streak example builds without warnings. The full final repository gate remains pending while the broader expansion continues.

Generic checkpoint: 38 assertions pass on vanilla 26.2, including recursive owned values, State defaults, event payloads, qualified constructors, borrowed generic methods and indexed receivers, with repeated invocation and reload. The 95-assertion vector native regression also passes on the current compiler. All language/LSP tests, Clippy, formatting, docs links, generated parser checks and whitespace checks pass. The mining-history example builds without warnings and demonstrates one generic library instantiated for strings and numbers. The full final repository gate remains pending while the remaining expansion continues.

Introduce `.sand` source files that compile through the portable program
backend, so packs need neither Cargo nor sand.toml.

- sand-lang: parser, analysis, execution-context inference, typed vanilla
  values, naming lints, and editor queries with position-aware completion
- sand-lsp and `sand lsp`: diagnostics, hover, completion, signature help,
  navigation, and rename
- `sand lang new|check|build|run|emit|zed`; `sand run` also accepts language
  projects
- Portable model: arithmetic, control flow, text, entities and entity State,
  attributes, teleport, player events, custom items, recipes, and tags
- Generated `sand::vanilla::ParticleType` and `Attribute` registries
- tree-sitter grammar and Zed extension

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-08T16:51:44.207941Z
We couldn’t complete this review. Comment @codex review to try again.
526efe2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9c2f095f-74b3-4aad-98de-aeb3ecefc71a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

ThatOneToast and others added 17 commits November 11, 2026 10:35
Add custom events, timers, world actions and conditions, boss bars,
single-pool loot tables, and smithing upgrades to the Sand language and
the portable program, with completion, hover, highlighting, and docs.

Portable output now runs through the same final 26.3 resource-schema pass
as Rust export, so packs targeting 26.3 emit predicates with `type` and
load instead of failing registry parsing. Player loops keep Rust's
contract of changing the executor only; event dispatch runs at the
player, as Rust's does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the Sand language

Calls that can re-enter their caller save the caller's locals, parameters,
and temporaries on a command-storage stack (PushFrame/PopFrame) and restore
them afterwards; other calls compile exactly as before. Self-calls and
arguments that call functions are computed into temporaries before any
parameter is written.

Loops gain `for i in a..b` / `a..=b`, `loop`, `break`, and `continue`
inside `while`; `while` accepts any condition. Functions returning bool
can be used directly as conditions. The portable program gains DataGet for
reading entity data such as health and food.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`Player.health`, `Player.food`, and other entity data read as typed
values; every attribute is a property that can be read and assigned, such as
`Player.max_health = 40.0;` or `zombie.scale *= 2.0;`. Loop bindings act as
handles for the entity they run as. get_attribute and set_attribute are
removed in favour of properties. Editors complete properties after a handle,
show their type and whether they are writable, and complete break, continue,
loop, and counting for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`as` converts between number, float, bool, and enums with one rule shared
by constants and run time, and explains impossible casts. Unary minus binds
tighter than `as`, as in Rust. `emit Name(args);` replaces the emit
builtin, handlers may ignore an event's payload, and the old spelling gets a
fix-it message. Keyword hover covers loops, jumps, casts, and emit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…itter grammar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…face

The language guide covers counting for, loop, break and continue, any while
condition, recursion and how frames are saved, the cast table, Player and
loop-handle properties, and payload-free event handlers. API surface tests
record the frame, entity-data, and EntityData method additions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant