Skip to content

named

named<F>(id, fn): F

Give a function a fixed name, so players and other packs can run it: a path under your function prefix ("tools/reset" is mypack:generated/tools/reset), or a full id. Use a full id to put the functions people should run where they’re easy to find, outside the generated folder:

named("mypack:api/reset", () => {
$.kill("@e[tag=mypack]");
});
// /function mypack:api/reset

It’s written to the pack even if nothing calls it, like @mcfunction. Inside a loop or a helper, give each copy its own name (named(`mypack:api/give/${item}`, ...)); the same name twice is only allowed when both have the same commands. Returns fn.

F extends FnRef & Function

string

F

F