Cookbook
Code recipes for common Bedrock scripting tasks. The cookbook is community-driven: every recipe is a contributed page, focused on one small, copy-pasteable pattern. If you've solved something that others would benefit from, send a pull request.
The cookbook is just getting started. Expect the page list below to fill in as recipes are contributed.
Contribute a recipe
Recipes live as individual MDX pages under
website/src/pages/docs/cookbook/ in the
Keyyard/create-mc-bedrock-cli (opens in a new tab)
repo. To contribute one:
- Fork the repo and check out the
websitebranch. - Add a new
.mdxfile underwebsite/src/pages/docs/cookbook/. - Add an entry for the new page in
website/src/pages/docs/cookbook/_meta.json. - Open a pull request describing what the recipe does and why someone would reach for it.
A good cookbook entry is:
- Focused. One pattern per page. Resist the urge to teach the whole API around it.
- Copy-pasteable. A working snippet that someone can drop into
src/main.tsand modify. - Honest about caveats. If the pattern has a known sharp edge (perf, edge case, gotcha), say so.
See Contributing for the broader guidelines.
Suggested topics
Recipes that would be especially welcome. For scaffolding the JSON
itself, the create generators
already cover items, weapons, tools, armor, entities, and blocks; these
recipes are about the script-side patterns around them:
- Custom items. Wiring a generated item to a script hook (use effects, cooldowns, durability logic).
- Custom blocks. Defining a custom block and reacting to interactions from a script.
- Custom entities. Spawning, behaviors, and script-side event handlers.
- Server event handling. Common patterns for
world.afterEvents(opens in a new tab) and friends. - Scoreboard helpers. Wrappers around the scoreboard APIs for common tasks (set/get, increment, reset on join).
- Common scripting patterns. Tick loops, cooldown maps, player state caches, and other building blocks.
If you're thinking about a recipe that isn't on this list, that's fine. The list is suggestions, not a fixed roster.
Related
- Contributing for PR guidelines.
- Getting Started if you haven't yet scaffolded a project to drop recipes into.
- Compiler Pipeline for what happens to the code in a recipe after you save.