Skip to content

__ Namespace Prefix

antD97 edited this page May 18, 2022 · 1 revision

__ Prefix

It is common to use a namespace as a prefix to scoreboard objective names. To keep objective names short, all occurrences of double underscores get replaced with the namespace of the current function followed by an _.

This:

# File: data/my_example_datapack/functions/load.mcfunction

scoreboard players set @a __cool 100

Turns into this:

# File: data/my_example_datapack/functions/load.mcfunction

scoreboard players set @a my_example_datapack_cool 100

__: Prefix

It's also common to repeat the namespace of a function. To keep function calls short and readable, all __: get replaced with the namespace of the current function followed by an :.

This:

# File: data/my_example_datapack/functions/load.mcfunction

function __:some/function

Turns into this:

# File: data/my_example_datapack/functions/load.mcfunction

function my_example_datapack:some/function

Additional Details

  • The namespace that will replace the __ is determined by the function definition it is used within. This means that, for function definitions that use a different namespace than the file it resides in, any __ inside that definition will match that function's namespace. See this page for more information on function definitions.

This:

# File: data/some_namespace/tick.mcfunction

execute as @a run function different_namespace:say_hi {
    scoreboard players add @s __num_times_said_hi 1
    say Hi!
    say I'm @s!
}

Turns into this:

# File: data/some_namespace/tick.mcfunction

execute as @a run function different_namespace:say_hi
# File: data/different_namespace:say_hi.mcfunction

scoreboard players add @s different_namespace_num_times_said_hi 1
say Hi!
say I'm @s!
Clone this wiki locally