### Install Beet using uv tool Source: https://github.com/mcbeet/beet/blob/main/README.md Install Beet as a global tool using the `uv tool install` command. This is the recommended installation method. ```console $ uv tool install beet ``` -------------------------------- ### Install Mecha using uv tool Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/README.md Installs the Mecha command-line tool globally using the `uv tool install` command. This is the recommended method for installing Mecha. ```console $ uv tool install mecha ``` -------------------------------- ### Install Beet with pip on Windows Source: https://github.com/mcbeet/beet/blob/main/docs/quick-start/get-started.md Use this command to install Beet in a virtual environment on Windows. ```bash python3 -m venv .venv .venv\Scripts\activate pip install beet ``` -------------------------------- ### Install Beet with uv Source: https://github.com/mcbeet/beet/blob/main/docs/quick-start/get-started.md Install Beet using the uv package manager. Ensure uv is initialized in your project first. ```bash uv init uv add beet ``` -------------------------------- ### Install Beet with pip on macOS/Linux Source: https://github.com/mcbeet/beet/blob/main/docs/quick-start/get-started.md Use these commands to install Beet in a virtual environment on macOS or Linux. ```sh python3 -m venv .venv source .venv/bin/activate pip install beet ``` -------------------------------- ### Say Command Examples Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/parse__multiline_command_examples__1.txt Basic 'say' commands for broadcasting messages in chat. Includes a continuation example. ```minecraft say foo bar hello wat welp ``` ```minecraft say this is a continuation ``` ```minecraft say hello ``` -------------------------------- ### Install Lectern with uv Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/README.md Command to install Lectern as a global tool using the uv package manager. Ensure uv is installed first. ```console $ uv tool install lectern ``` -------------------------------- ### Demo Function Examples Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_docstring__0.pack.md Examples of using the 'say' command in Minecraft functions to display various types of text and numbers. Includes examples with newlines and escaped characters. ```mcfunction say '\n hello\n world\n' ``` ```mcfunction say 42 ``` ```mcfunction say My function ``` ```mcfunction say 123 ``` ```mcfunction say My other function ``` ```mcfunction say "This is a class.\n\nIt doesn't do anything.\n" ``` ```mcfunction say '\n foo\\n\\nbar\n' ``` -------------------------------- ### Example mcfunction: demo:foo Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_custom_provider__0.pack.md A simple mcfunction example demonstrating variable assignment and printing. The 'say' command is intended to be preserved. ```mcfunction value = 123 print(value) say this should be left untouched ``` -------------------------------- ### Verify Mecha Installation Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/README.md Checks if the Mecha command-line utility has been successfully installed by running the `--help` command. This confirms that Mecha is accessible in your system's PATH. ```console $ mecha --help ``` -------------------------------- ### Mcfunction Demo Foo Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/examples__markdown_examples_basic2_txt__0.pack.md An example of mcfunction syntax, demonstrating basic commands and a custom directive. ```mcfunction say foo @functionn demo:foo say still in the same function @@@@ @ @ @ ``` -------------------------------- ### Demo Function Example Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_backslash_continuation__0.pack.md An example Minecraft function that executes a command for players with the 'blob' tag and then says hello. This is a basic demonstration of function execution. ```mcfunction execute as @a[tag=blob] run function demo:foo say hello ``` -------------------------------- ### Simple mcfunction Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/messaging__build_1__0.pack.md A basic mcfunction file that executes a single command. ```mcfunction say hello3 ``` -------------------------------- ### Mecha CLI Validation Example Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/README.md Demonstrates how to use the Mecha CLI to validate a data pack and shows an example of an error output. ```bash $ mecha path/to/my_data_pack Validating with mecha vX.X.X ERROR | mecha Expected curly '}' but got bracket ']'. | path/to/my_data_pack/data/demo/functions/foo.mcfunction:5:34 | 4 | | 5 | say hello @a[scores={foo=1, bar=2] | : ^ Error: Reported 1 error. ``` -------------------------------- ### Demo Function Example Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_custom_command__0.pack.md An example Minecraft function demonstrating 'say' and 'execute if score' commands. ```mcfunction say Hello @a[tag=!registered] execute if score #init temp = #wat temp run say Hello @a[tag=hi] ``` -------------------------------- ### Initialize PngFile Handle Source: https://github.com/mcbeet/beet/blob/main/docs/overview.md Initialize a PngFile handle with a source path. The file starts in an unloaded state. ```python from beet import PngFile handle = PngFile(source_path="../logo.png") handle ``` -------------------------------- ### Demo mcfunction with comments and commands Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_preserve__0.pack.md An example mcfunction file demonstrating preserved comments, various commands, and hover events. ```mcfunction # This is a file with comments that need to be preserved # First command execute as @a at @s align xyz if block ~ ~ ~ wool[foo=bar] run summon armor_stand ~ ~ ~ {Tags: ["position_history", "new"], Invisible: 1b, Marker: 1b} # Summon the trail #>Some explanation # # Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod # tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, # quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo # consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse # cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat # non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. tellraw @s {text: "Hover me!", hoverEvent: {action: "show_text", value: "Hi!"}} # The hover event is cool say breaking news say breaking news say breaking news say breaking news say breaking news execute as @a at @s if block ~ ~-1 ~ #wool run give @s stone{display: {Name: '[{"text": "Hello", "bold": true}]', Lore: ['[{ "text": "Something else here" }]']}} # When the player is on wool # Give a special stone block execute if block ~ ~ ~ #namespace:tag if entity @s[tag=foo] tellraw @a {text: "Hello # there"} say this is a continuation # some comment say wat # Final comment ``` -------------------------------- ### mcfunction from Script Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/examples__beet_project__0.pack.md Shows mcfunctions that might be generated from a script, executing a sequence of numbered commands. ```mcfunction say hello ``` ```mcfunction say 0 say 1 say 2 say 3 say 4 say 5 say 6 say 7 say 8 say 9 ``` -------------------------------- ### Initialize JsonFile Handle Source: https://github.com/mcbeet/beet/blob/main/docs/overview.md Initialize a JsonFile handle with a source path. The file starts in an unloaded state. ```python from beet import JsonFile handle = JsonFile(source_path="../examples/load_basic/beet.json") handle ``` -------------------------------- ### Sync Dependencies with uv Source: https://github.com/mcbeet/beet/blob/main/README.md Use this command to synchronize project dependencies. Ensure uv is installed and configured. ```console $ uv sync ``` -------------------------------- ### Mecha CLI Statistics Output Example Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/README.md An example of the statistics output generated by the Mecha CLI when using the --stats option. ```text INFO | stats Analyzed 1 function | ------------------------------------------------------------------------------- | Total commands (1 behind execute) | 4 | ------------------------------------------------------------------------------- | /scoreboard | 3 | objectives add | 1 | players set | 1 | players operation matches ... | 1 | as | 1 | run | 1 | ------------------------------------------------------------------------------- | Total selectors | 3 | ------------------------------------------------------------------------------- | @e | 2 | [tag] | 2 | [scores] | 1 | @s | 1 | @e with missing or inverted type | 2 | ------------------------------------------------------------------------------- | Scoreboard objectives | 2 | ------------------------------------------------------------------------------- | my_consts (dummy) | 3 | 10 | 2 | foo | 3 ``` -------------------------------- ### Bolt Script Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/bolt__parse_341__0.txt This is a sample Bolt script that demonstrates variable assignment and nested memoization with a 'say' command. ```bolt a = 1 b = 2 memo a, b: say (a + b) memo b: say b ``` -------------------------------- ### Another Function Documentation Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/examples/html_comments.md Illustrates another instance of documenting a function within an HTML comment. ```html ``` -------------------------------- ### Basic mcfunction Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/examples__markdown_README_md__0.pack.md A simple mcfunction that prints messages. This is useful for basic command sequences. ```mcfunction say This is added before. say Hello, world! say This is added afterwards. ``` -------------------------------- ### Bolt Memo mcfunction Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_memo__0.pack.md This snippet demonstrates a basic command within the bolt_memo function. It's useful for simple operations or as a starting point for more complex mcfunction scripts. ```mcfunction say uwu ``` -------------------------------- ### Tagged mcfunction Examples Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/examples__beet_project__0.pack.md Shows how to define function tags in JSON format, mapping tag names to specific functions. ```json { "values": [ "with_beet:foo" ] } ``` ```json { "values": [ "with_beet:bar" ] } ``` ```json { "values": [ "with_beet:bar" ] } ``` -------------------------------- ### Serve and Build Documentation with zensical Source: https://github.com/mcbeet/beet/blob/main/README.md Manage documentation using zensical. Use 'zensical serve' to preview changes locally and 'zensical build' to generate the documentation site. ```console $ uv run zensical serve ``` ```console $ uv run zensical build ``` -------------------------------- ### Function Call Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_memo3__0.pack.md An example of calling a Minecraft function from another function. ```mcfunction function demo:foo/5 ``` -------------------------------- ### Create Document with Initial Content or Path Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/README.md Instantiate a Document providing existing DataPack/ResourcePack, initial text/markdown, or a path to load from. ```python Document(data=DataPack(), assets=ResourcePack()) ``` ```python Document(text=...) ``` ```python Document(markdown=...) ``` ```python Document(path="path/to/document.md") ``` -------------------------------- ### Invalid mcfunction Example 1 Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/examples__markdown_examples_embedded_vs_text_md__0.pack.md An example of an mcfunction file that is not valid due to incorrect syntax. ```mcfunction @function this is invalid ``` -------------------------------- ### Initialize Lectern Document Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/README.md Create a new Document instance with default DataPack and ResourcePack. Asserts verify the initial empty state. ```python from beet import DataPack, ResourcePack from lectern import Document document = Document() assert document.data == DataPack() assert document.assets == ResourcePack() ``` -------------------------------- ### Invalid NBT Tag Example Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/parse__argument_examples_minecraft_nbt_tag_1_9__0.txt An example of an incorrectly formatted NBT tag with a missing closing bracket. ```minecraft_nbt {foo: [1,2} ``` -------------------------------- ### Install Bolt with Pip Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/README.md Install the Bolt package using pip. This is the standard method for adding Bolt to your Python environment. ```bash pip install bolt ``` -------------------------------- ### Display Help Information Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/README.md Use the --help option to display usage information and available options for the lectern command. ```console $ lectern --help ``` -------------------------------- ### Score Holder Argument Selector Example Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/parse__argument_examples_minecraft_score_holder_2_6__0.txt An example of using the score holder argument with a selector, demonstrating the expected format. ```minecraft @a[name=] ``` -------------------------------- ### Using the 'hello' Directive Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/examples/with_beet/hello.md Illustrates how to invoke the 'hello' directive with different arguments. This directive is likely defined elsewhere and processed by Lectern. ```plaintext @hello Alice ``` ```plaintext @hello Bob ``` -------------------------------- ### Minecraft Entity Selector Parsing Example Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/parse__argument_examples_minecraft_entity_2_1__0.txt Demonstrates parsing a Minecraft entity selector. This example shows a valid selector. ```text minecraft:entity 2 1 --- {'type': 'players', 'amount': 'multiple'} --- @e[type=foo] ``` -------------------------------- ### Cached mcfunction Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_compile_cached__0.pack.md An example of a cached function that executes multiple commands sequentially. Bolt optimizes the execution of such functions. ```mcfunction say something slow 0 say something slow 1 say something slow 2 say something slow 3 say something slow 4 say something slow 5 say something slow 6 say something slow 7 say something slow 8 say something slow 9 ``` -------------------------------- ### Mecha CLI Help Output Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/README.md Displays the available options and usage instructions for the Mecha command-line utility. ```bash $ mecha --help Usage: mecha [OPTIONS] [SOURCE]... Validate data packs and .mcfunction files. Options: -m, --minecraft VERSION Minecraft version. -l, --log LEVEL Configure output verbosity. -s, --stats Collect statistics. -j, --json FILENAME Output json. -v, --version Show the version and exit. -h, --help Show this message and exit. ``` -------------------------------- ### Parse Example: @print Decorator Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/bolt__parse_257__0.txt A basic example demonstrating the usage of the @print decorator in Bolt. This is a valid syntax that the parser should handle correctly. ```bolt @print ``` -------------------------------- ### Demo Function Calls Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_nested_location__0.pack.md Illustrates various ways to call functions within the 'demo:foo' namespace. ```mcfunction function demo:foo/thing1 function demo:foo/__ function demo:foo/foo_bar_ ``` ```mcfunction function demo:foo/thing1/thing2/thing003/hello say demo:foo/thing1/thing2/thing75bcd15/hello ``` ```mcfunction say ('demo:foo/thing1/blob', 'demo:foo/thing1/dem') ``` ```mcfunction execute as @a run function demo:foo/thing1/thing2 schedule function demo:foo/thing1/blob 2s append ``` ```mcfunction execute if predicate demo:welp run say yes ``` -------------------------------- ### Mcfunction Scoreboard Operation Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_strip_final_newline__0.pack.md Sets the 'foo' scoreboard player's score to the value of the 'bar' scoreboard player. This is a basic example of scoreboard manipulation. ```mcfunction scoreboard players operation foo set = bar set ``` -------------------------------- ### Bolt Parse Error Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/bolt__parse_115__0.txt This example demonstrates the specific syntax that triggers the 'Expected quote but got brace' error in Bolt. It shows the line and column where the error occurs. ```text #>ERROR Expected quote but got brace '}'. # line 1, column 8 # 1 | yo = f"}" # : ^ ``` ```python yo = f"}" ``` -------------------------------- ### Example Minecraft Function: Facing Target Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_multiline__0.pack.md An example Minecraft function that checks if any player is facing a specific target entity within a certain range. This function uses advanced execution and targeting commands. ```mcfunction execute as @a at @s anchored eyes facing 0 0 0 anchored feet positioned ^ ^ ^1 rotated as @s positioned ^ ^ ^-1 if entity @s[distance=..0.6] run say I'm facing the target! ``` -------------------------------- ### Item Manipulation Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_basic__0.pack.md Example of replacing items between entity hands. ```bolt item replace entity @s weapon.offhand from entity @s weapon.mainhand ``` ```bolt item replace entity @s weapon.offhand from entity @s weapon.mainhand ``` -------------------------------- ### Basic Function Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_shadow_global__0.pack.md A simple Minecraft function that uses the 'say' command to output a tuple. This is a basic demonstration of function execution. ```mcfunction say (1, 2, 3) ``` -------------------------------- ### Block Manipulation and Messages Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_basic__0.pack.md Examples of setting blocks and displaying messages. ```bolt setblock 1 2 3 stone ``` ```bolt setblock 1 2 3 stone ``` ```bolt say {'foo': 1, 'bar': 2, 'thing': 42} ``` ```bolt say {1: 1, 'a': 'a', 'b': 'thing', 'c': 'c', 2: 2} ``` ```bolt say {1: {2: 'foo'}} ``` ```bolt say [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] ``` ```bolt say [3, 4, 5, 6, 7, 8, 9, 10, 11] ``` ```bolt say [0, 1, 2, 3, 4, 5, 6, 7, 8] ``` ```bolt say [3, 4, 5, 6, 7, 8] ``` ```bolt say [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] ``` ```bolt say [3, 4, 5, 6, 7, 8, 9, 10, 11] ``` ```bolt say [0, 1, 2, 3, 4, 5, 6, 7, 8] ``` ```bolt say [3, 4, 5, 6, 7, 8] ``` ```bolt say [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ``` ```bolt say [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ``` ```bolt say [11, 10, 9, 8, 7, 6, 5, 4] ``` ```bolt say [9, 8, 7, 6, 5, 4] ``` ```bolt say [0, 1, 2] ``` ```bolt say ==[a]==" ``` ```bolt say True ``` ```bolt say None ``` ```bolt say b ``` ```bolt say True ``` ```bolt say False ``` ```bolt say foo ``` ```bolt say ==[b]==" ``` ```bolt say True ``` ```bolt say a ``` ```bolt say c ``` ```bolt say False ``` ```bolt say False ``` ```bolt say bar ``` ```bolt say ==[c]==" ``` ```bolt say True ``` ```bolt say b ``` ```bolt say d ``` ```bolt say False ``` ```bolt say False ``` ```bolt say foo ``` ```bolt say ==[d]==" ``` ```bolt say True ``` ```bolt say c ``` ```bolt say None ``` ```bolt say False ``` ```bolt say True ``` ```bolt say bar ``` ```bolt say hello!!!!! ``` ```bolt function demo:bbb ``` ```bolt data merge storage some:path/to/storage {Count: 23b} ``` ```bolt execute at @e[type=creeper] run summon lightning_bolt ``` ```bolt data merge storage demo:foo {custom_data1: [0, 1, 2], custom_data2: [0, 1, 2]} ``` ```bolt setblock 0 0 0 minecraft:stone ``` ```bolt say same thing ``` ```bolt tellraw @a {text: "hello world"} ``` ```bolt execute as @a[scores={foo=1..}] run scoreboard players remove @s foo 1 ``` ```bolt execute as @a[scores={bar=1..}] run scoreboard players remove @s bar 1 ``` ```bolt scoreboard players set @p tmp -8 ``` ```bolt setblock ~12 ~23 ~34 stone ``` ```bolt setblock ~12 23 ~34 stone ``` ```bolt setblock 12 23 34 stone ``` ```bolt setblock ~12 ~23 ~34 stone ``` ```bolt setblock ^12 ^23 ^34 stone ``` ```bolt setblock -12 -23 -34 stone ``` ```bolt setblock ~-12 ~-23 ~-34 stone ``` ```bolt setblock ^-12 ^-23 ^-34 stone ``` ```bolt say 0 a ``` ```bolt say 1 b ``` ```bolt say 2 c ``` ```bolt say 1 ``` ```bolt say 2 ``` ```bolt say 3 ``` ```bolt say 0 ``` ```bolt say 1 ``` ```bolt say 2 ``` ```bolt say 10 ``` ```bolt execute as @p run function #demo:yolo_funcs ``` -------------------------------- ### Execute Function Demo Foo Stuff Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_custom_execute_destination__0.pack.md Executes the 'demo:foo/stuff/generated/0x0' function for all players. This is used to call a function within a sub-directory. ```mcfunction execute as @a run function demo:foo/stuff/generated/0x0 ``` -------------------------------- ### Empty Loot Table Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_json__0.pack.md An example of an empty loot table, which will not drop any items. ```json { "pools": [] } ``` -------------------------------- ### Mcfunction AST Representation with Location (demo:bar) Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_debug__0.pack.md Shows the AST for a 'say hello' command, including detailed source location information for each node. ```mcfunction location: SourceLocation(pos=0, lineno=1, colno=1) end_location: SourceLocation(pos=10, lineno=2, colno=1) commands: location: SourceLocation(pos=0, lineno=1, colno=1) end_location: SourceLocation(pos=9, lineno=1, colno=10) identifier: 'say:message' arguments: location: SourceLocation(pos=4, lineno=1, colno=5) end_location: SourceLocation(pos=9, lineno=1, colno=10) fragments: location: SourceLocation(pos=4, lineno=1, colno=5) end_location: SourceLocation(pos=9, lineno=1, colno=10) value: 'hello' ``` -------------------------------- ### Demo Function Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/messaging__build_2__0.pack.md A simple Minecraft function that displays a message in chat. ```mcfunction say hello4 ``` -------------------------------- ### Beet Project Configuration Source: https://github.com/mcbeet/beet/blob/main/docs/quick-start/get-started.md This JSON file configures a basic data pack, specifying its name, description, source directory, and output location. ```json { "name": "My First Pack", "description": "Learning beet!", "data_pack": { "load": ["src"] }, "output": "build" } ``` -------------------------------- ### Prepend Modifier Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/README.md The `prepend` modifier adds the fragment before the already-existing content. ```mcfunction say This is added before. ``` -------------------------------- ### Configure Beet Plugin with beet.json Source: https://github.com/mcbeet/beet/blob/main/docs/overview.md This JSON configuration file sets up the Beet project. It specifies the project name, output directory, and the pipeline of plugins to execute. ```json { "name": "greeting", "output": "out", "pipeline": ["my_plugins.add_greeting"] } ``` -------------------------------- ### Demo Function Loop Entry Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_loop__0.pack.md The main entry point for the demo function loop. It sets up initial variables and calls nested functions. ```mcfunction tellraw @a {text: "0"} tellraw @a {text: "1"} tellraw @a {text: "2"} tellraw @a {text: "3"} scoreboard players set b global 0 function demo:foo/loop0 ``` -------------------------------- ### Felx Function Tag Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_basic__0.pack.md Example of a function tag used in the Felx system. ```json { "values": [ "demo:foo", "demo:foo" ] } ``` -------------------------------- ### Python Function Definition Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/bolt__parse_146__0.txt Defines a simple Python function used in the example. ```python def f(): pass ``` -------------------------------- ### Gather Objectives Function Example Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_gather_objectives__0.pack.md A Minecraft function that logs specific objective names. ```mcfunction say foo, thing, wat, wow ``` -------------------------------- ### Basic Commands Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_basic__0.pack.md Demonstrates various basic commands like say, execute if, and scoreboard operations. ```mcfunction say [False, False, True, False, False, False, True, False, False, False, True, False, True, True, True, True] say hello say hello say hello say hello say thing == 1 say thing == 2 say thing == 3 say thing == 99 say thing == hello say thing == world execute if score @s foo matches 1 run function demo:foo/nested_execute_1 execute if score @s foo matches 0 run say no scoreboard players operation global bolt_basic.tmp0 = global is_cool execute unless score global is_cool matches 0 run scoreboard players operation global bolt_basic.tmp0 = global is_nice scoreboard players operation global is_awesome = global bolt_basic.tmp0 scoreboard players set global bolt_basic.tmp1 1 execute unless score global is_awesome matches 0 run scoreboard players set global bolt_basic.tmp1 0 scoreboard players operation global bolt_basic.tmp2 = global is_awesome execute unless score global bolt_basic.tmp1 matches 0 run scoreboard players operation global bolt_basic.tmp2 = global force_awesomeness execute unless score global bolt_basic.tmp2 matches 0 run say hello say this is from demo:utils execute if data storage demo:random_data {value: 42} run say json loaded successfully give @s bow{CustomModelData: 7} give @s stone{CanPlaceOn: ["minecraft:dirt", "minecraft:gravel"], CustomModelData: 7} tellraw @p ["", {text: "hey", color: "red"}, "minecraft:dirt", "r", "e", "d"] say 1 say 2 say ['demo:abc', 'demo:def'] say inner dummy say dummy say dummy say dummy say AstCommand(identifier='tellraw:targets:message', arguments=AstChildren((AstSelector(variable='p', arguments=AstChildren(())), AstNbtValue(value=String('hello'))))) say tellraw @p "hello" execute as 00000001-0002-0003-0405-000000000006 run function test:test whitelist add bdd640fb-0667-1ad1-1c80-317fa3b1799d attribute @s minecraft:generic.attack_speed modifier add demo:double 0.5 add_multiplied_total ``` -------------------------------- ### Build the Data Pack Source: https://github.com/mcbeet/beet/blob/main/docs/quick-start/get-started.md Run this command in your project's root directory to build the data pack. ```sh beet build ``` -------------------------------- ### Mcfunction Example: Say World Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_nested_resources__0.pack.md A simple mcfunction that makes the player say 'world'. ```mcfunction say world ``` -------------------------------- ### Demo Function Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_chained_comp__0.pack.md A Minecraft function demonstrating scoreboard operations and conditional execution. ```mcfunction say 1 say 2 scoreboard players set global tmp0 0 execute if score global seven = global seven run scoreboard players set global tmp0 1 scoreboard players operation global tmp1 = global tmp0 execute unless score global tmp0 matches 0 run function demo:foo/nested_execute_0 scoreboard players operation global tmp3 = global tmp1 execute unless score global tmp1 matches 0 run function demo:foo/nested_execute_1 execute unless score global tmp3 matches 0 run say 1 scoreboard players set global tmp5 0 execute if score global seven = global seven run scoreboard players set global tmp5 1 scoreboard players operation global tmp6 = global tmp5 execute unless score global tmp5 matches 0 run function demo:foo/nested_execute_2 scoreboard players operation global tmp8 = global tmp6 execute unless score global tmp6 matches 0 run function demo:foo/nested_execute_3 execute unless score global tmp8 matches 0 run say 2 scoreboard players set global tmp10 0 execute if score global foo = global bar run scoreboard players set global tmp10 1 scoreboard players set global tmp11 0 execute if score global tmp10 matches 1 run scoreboard players set global tmp11 1 scoreboard players operation global tmp12 = global tmp11 execute unless score global tmp11 matches 0 run function demo:foo/nested_execute_4 execute unless score global tmp12 matches 0 run say 3 # # check 123, 456 say True say False say False say False say False say False say False say False say False say False say False say False say False say False say False say True # ``` -------------------------------- ### Basic mcfunction Commands Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_prelude__0.pack.md A simple mcfunction file demonstrating basic commands like 'say' and 'summon'. ```mcfunction say !!! say hello anonymous summon minecraft:squid say !!! say ok ok say hello steve say AstResourceLocation(is_tag=False, namespace='minecraft', path='becomeduck') say !!! ``` -------------------------------- ### Base64 Modifier Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/README.md The `base64` modifier decodes the content of the code fragment as base64. ```json ewogICJ2YWx1ZXMiOiBbInR1dG9yaWFsOnN0cmlwcGVkIl0KfQ== ``` -------------------------------- ### Build Data Pack with Beet CLI Source: https://github.com/mcbeet/beet/blob/main/docs/overview.md This command-line instruction executes the Beet build process, utilizing the configuration in `beet.json` to generate the data pack. ```bash $ beet Building project... Done! ``` -------------------------------- ### Hidden mcfunction Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/examples__markdown_README_md__0.pack.md An mcfunction that is not intended to be rendered in markdown. Use for internal logic. ```mcfunction say This will not appear in the rendered markdown. ``` -------------------------------- ### mcfunction Example with Bolt Runtime Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_debug__0.pack.md An mcfunction file demonstrating the use of Bolt's runtime helpers and scope for defining and calling a function. ```mcfunction _bolt_lineno = [1, 7], [1, 4] _bolt_helper_children = _bolt_runtime.helpers['children'] _bolt_helper_replace = _bolt_runtime.helpers['replace'] with _bolt_runtime.scope() as __bolt_var1: def say_hello(): _bolt_runtime.commands.extend(_bolt_refs[0].commands) __bolt_var0 = say_hello __bolt_var0 = __bolt_var0() __bolt_var2 = _bolt_helper_replace(_bolt_refs[1], commands=_bolt_helper_children(__bolt_var1)) ``` -------------------------------- ### Empty Utility Function Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_proc_macro__0.pack.md An example of an empty utility function. The `strip_final_newline` attribute is used. ```mcfunction ``` -------------------------------- ### Mcfunction Example: Say Hello Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_load_command_tree__0.pack.md A simple mcfunction that prints 'hello' to the chat and includes a valid command. This demonstrates basic command execution within Minecraft functions. ```mcfunction say hello this_is_valid_now ``` -------------------------------- ### Minecraft Function Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_enum__0.pack.md A Minecraft function that uses the 'say' command with color codes. ```mcfunction say (, , , ) ``` -------------------------------- ### Mcfunction AST Representation (demo:foo) Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_debug__0.pack.md Represents the Abstract Syntax Tree (AST) for a simple 'say hello' command in mcfunction. ```mcfunction commands: identifier: 'say:message' arguments: fragments: value: 'hello' ``` -------------------------------- ### Create a Data Pack with a Greeting Function Source: https://github.com/mcbeet/beet/blob/main/docs/overview.md This script creates a data pack with a function that says 'hello' five times when loaded. It's a starting point for understanding data pack generation. ```python from beet import DataPack, Function with DataPack(path="out/greeting_data_pack") as data: data["greeting:hello"] = Function(["say hello"] * 5, tags=["minecraft:load"]) ``` -------------------------------- ### Demo Function Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_circular__0.pack.md A simple Minecraft function that prints two messages to the chat. ```mcfunction say 33 say 42 ``` -------------------------------- ### Demo Function Initialization Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_loop__0.pack.md Initializes the 'global' scoreboard objective. This function should be called once at the start. ```mcfunction scoreboard objectives add global dummy ``` -------------------------------- ### Beet Toolchain Help Source: https://github.com/mcbeet/beet/blob/main/README.md Display the help message for the Beet toolchain, showing available commands and options. This is useful for understanding the CLI's capabilities. ```console $ beet --help ``` -------------------------------- ### Function with Before and After Logic Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_nesting__0.pack.md Executes commands before and after a core action. Useful for setup and teardown operations. ```mcfunction say before say aaaaa say after ``` -------------------------------- ### Main Function Call Source: https://github.com/mcbeet/beet/blob/main/packages/mecha/tests/snapshots/examples__build_basic_bake_macros__0.pack.md The demo:foo function serves as an entry point, executing a baked version of another function. This demonstrates indirect function calls. ```mcfunction execute as @p at @s run function demo:beep/baked_6d6t4i675b87w ``` -------------------------------- ### Bolt AST Root Command Example Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/bolt__parse_175__1.txt Details the structure of the root command in the AST, including its location and the list of commands it contains. This serves as the entry point for the parsed command structure. ```python _bolt_refs[4] location: SourceLocation(pos=76, lineno=2, colno=1) end_location: SourceLocation(pos=132, lineno=2, colno=57) identifier: 'execute:subcommand' arguments: ``` -------------------------------- ### Minecraft Language Translations Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_basic__0.pack.md Example of language translation entries for Minecraft, including different cases. ```json { "menu.singleplayer": "AAAA", "something.else": "bonjour", "yaml.key1": "BONJOUR", "yaml.key2": "Bonjour" } ``` -------------------------------- ### Function Definition Examples Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/examples__markdown_examples_escaped_fragment_txt__0.pack.md Illustrates different ways to define and call functions in Lectern's mcfunction syntax. Use @@ for special syntax. ```mcfunction @function demo:foo @@blah demo:foo @function(@@) demo:bar @@function(@@@) demo:bar @function demo:bar ``` -------------------------------- ### Conditional Execution Examples Source: https://github.com/mcbeet/beet/blob/main/packages/bolt/tests/snapshots/examples__build_bolt_basic__0.pack.md Demonstrates conditional execution based on score values and block presence. ```bolt execute if score @s loop_again matches 1 run function demo:foo ``` ```bolt execute if block ^ ^1 ^ #planks run say 42 ``` ```bolt execute if block ~ ~ ~ #planks run say 42 ``` ```bolt execute if score @s thingy matches 0..3 run function demo:foo/small_tree/0_3 ``` ```bolt execute if score @s thingy matches 4..7 run function demo:foo/small_tree/4_7 ``` ```bolt execute if score @s thingy matches 10..14 run function demo:foo/tree_1/10_14 ``` ```bolt execute if score @s thingy matches 15..19 run function demo:foo/tree_1/15_19 ``` ```bolt execute at @s if block ~ ~ ~ #minecraft:beds run teleport @s ~ ~0.5625 ~ ``` ```bolt execute if data storage some:path/to/storage some.foo.path ``` ```bolt execute if data storage some:path/to/storage some.foo.path run say hi ``` ```bolt execute if data storage some:path/to/storage some.foo.path{my: "compound"} ``` ```bolt execute if data storage some:path/to/storage some.foo.path{my: "compound"} run say hi ``` ```bolt execute if data storage some:path/to/storage some.bar.path ``` ```bolt execute if data storage some:path/to/storage some.bar.path run say hi ``` ```bolt execute if data storage some:path/to/storage some.bar.path{my: "compound"} ``` ```bolt execute if data storage some:path/to/storage some.bar.path{my: "compound"} run say hi ``` ```bolt execute if data storage some:path/to/storage some.bar.path[{my: "subscript"}] ``` ```bolt execute if data storage some:path/to/storage some.bar.path[{my: "subscript"}] run say hi ``` ```bolt execute if data storage some:path/to/storage some.foo.path{my: "compound"}.stuff[42].beep.bar[{my: "subscript"}].boop run say hi ``` ```bolt execute if data storage some:path/to/storage foo.bar ``` ```bolt execute if data storage some:path/to/storage "some.foo.path" ``` ```bolt execute if data storage some:path/to/storage something.cool[3].foo ``` ```bolt execute if score some_fake_player some_objective matches 0 run say yes ``` ```bolt execute if score 00000000-0000-0000-0000-000000000001 some_objective matches 0 run say yes ``` ```bolt execute if score 12345678-1234-5678-1234-567812345678 some_objective matches 0 run say yes ``` ```bolt execute if block ~ ~6 ~ air if block ~ ~5 ~ air if block ~ ~4 ~ air if block ~ ~3 ~ air if block ~ ~2 ~ air if block ~ ~1 ~ air run say nothing above! ``` ```bolt execute if score #temp abc matches 1.. run say foo ``` -------------------------------- ### Create BinaryFile Source: https://github.com/mcbeet/beet/blob/main/docs/overview.md Creates a BinaryFile handle with initial byte content. This file handle is lazy and does not perform filesystem operations until content is accessed. ```python from beet import BinaryFile BinaryFile(b"\x00\x01\x02\x03") ``` -------------------------------- ### Embedded mcfunction Example Source: https://github.com/mcbeet/beet/blob/main/packages/lectern/tests/snapshots/examples__markdown_examples_code_fragments_md__0.pack.md An mcfunction that is embedded within another context, possibly for inline execution. ```mcfunction say embedded foo ```