<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sasgaming.net/index.php?action=history&amp;feed=atom&amp;title=Minecraft%3ACommands%2Ffunction</id>
	<title>Minecraft:Commands/function - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sasgaming.net/index.php?action=history&amp;feed=atom&amp;title=Minecraft%3ACommands%2Ffunction"/>
	<link rel="alternate" type="text/html" href="https://wiki.sasgaming.net/index.php?title=Minecraft:Commands/function&amp;action=history"/>
	<updated>2026-04-09T09:14:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.sasgaming.net/index.php?title=Minecraft:Commands/function&amp;diff=49646&amp;oldid=prev</id>
		<title>imported&gt;Kestrer: Add link</title>
		<link rel="alternate" type="text/html" href="https://wiki.sasgaming.net/index.php?title=Minecraft:Commands/function&amp;diff=49646&amp;oldid=prev"/>
		<updated>2025-12-14T23:14:03Z</updated>

		<summary type="html">&lt;p&gt;Add link&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox command&lt;br /&gt;
| name = function&lt;br /&gt;
| oplevel = &lt;br /&gt;
* 2 {{only|java|short=1}}&lt;br /&gt;
* 1 {{only|bedrock|short=1}}&lt;br /&gt;
| others = [[Minecraft:Cheat]] only{{only|bedrock|short=1}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Runs commands found in the corresponding function file(s) with command execution context (executor, execution position, angles, etc) of the /function command itself.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
{{IN|java}}, runs a [[Minecraft:Function (Java Edition)|function]] or all functions in a [[Minecraft:tags|tag]] from a [[Minecraft:data pack]].&lt;br /&gt;
&lt;br /&gt;
{{IN|bedrock}}, runs a [[Minecraft:Function (Bedrock Edition)|function]] from a [[Minecraft:behavior pack]].&lt;br /&gt;
&lt;br /&gt;
{{IN|java}}, the behavior of {{cmd|return run function ...}} (or {{cmd|return run execute ... run function ...}}) is different with a direct call to the {{cmd|link=none|function}} command. If {{cmd|return run function ...}} runs multiple functions, execution stops after first {{cmd|link=none|return}} in any of the functions. If a direct call to the {{cmd|function ...|link=none}} runs multiple functions, all of the functions are executed, and the return values are added up as the &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt; value of the {{cmd|function ...|link=none}} command.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Java Edition&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;lt;code&amp;gt;function &amp;lt;name&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
:: Runs a function or functions in a tag.&lt;br /&gt;
: &amp;lt;code&amp;gt;function &amp;lt;name&amp;gt; &amp;lt;arguments&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: &amp;lt;code&amp;gt;function &amp;lt;name&amp;gt; with (block &amp;lt;sourcePos&amp;gt;|entity &amp;lt;source&amp;gt;|storage &amp;lt;source&amp;gt;) [&amp;lt;path&amp;gt;]&amp;lt;/code&amp;gt;&lt;br /&gt;
:: Runs a function or functions in a tag, with arguments for [[Minecraft:Function (Java Edition)#Macros|macros]].&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Bedrock Edition&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;lt;code&amp;gt;function &amp;lt;name: filepath&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
:: Runs a function.&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
{{argument|name|function|name: filepath|CommandFilePath}}&lt;br /&gt;
: Specifies the function(s) to execute.&lt;br /&gt;
: {{arg desc|je=function|be=commandfilepath}}&lt;br /&gt;
&lt;br /&gt;
{{el|je|short=1}}: {{Argument|arguments|nbt_compound_tag}}&lt;br /&gt;
: Specifies arguments for macro functions in a compound NBT tag.&lt;br /&gt;
: {{Arg desc|je=nbt_compound_tag}}&lt;br /&gt;
&lt;br /&gt;
{{el|je|short=1}}: {{Argument|sourcePos|block_pos}}&lt;br /&gt;
: The position of the target [[Minecraft:block entity]] whose NBT is to be used.&lt;br /&gt;
: {{arg desc|je=block_pos}}&lt;br /&gt;
&lt;br /&gt;
{{el|je|short=1}}: {{Argument|source|entity}} (in &amp;lt;code&amp;gt;entity &amp;lt;target&amp;gt;&amp;lt;/code&amp;gt; mode)&lt;br /&gt;
: Specifies an entity whose NBT is to be used.&lt;br /&gt;
: {{arg desc|je=entity|amount=single|type=entitie}}&lt;br /&gt;
&lt;br /&gt;
{{el|je|short=1}}: {{Argument|source|resource_location}} (in &amp;lt;code&amp;gt;storage &amp;lt;target&amp;gt;&amp;lt;/code&amp;gt; mode)&lt;br /&gt;
: Specifies a [[Minecraft:Command storage format|storage]] whose NBT is to be used.&lt;br /&gt;
: {{arg desc|je=resource_location}}&lt;br /&gt;
&lt;br /&gt;
{{el|je|short=1}}: {{Argument|path|nbt_path}}&lt;br /&gt;
: Specifies the NBT path. Should be a path of a single compound tag.&lt;br /&gt;
: {{arg desc|je=nbt_path}}&lt;br /&gt;
&lt;br /&gt;
== Result ==&lt;br /&gt;
{{Result table}}&lt;br /&gt;
{{Result table|The command is incomplete, or any argument is not specified correctly.|unparseable|unparseable}}&lt;br /&gt;
{{Result table|The specified function or function tag does not exist.|fail|fail}}&lt;br /&gt;
{{Result table|There&amp;#039;s no function in the function tag.||N/A}}&lt;br /&gt;
{{Result table|cmd=/function &amp;lt;name&amp;gt;|There&amp;#039;s any macro line in the function(s).|fail}}&lt;br /&gt;
{{Result table|cmd=/... with block ...|&amp;lt;code&amp;gt;&amp;lt;sourcePos&amp;gt;&amp;lt;/code&amp;gt; is unloaded or out of the world.}}&lt;br /&gt;
{{Result table|The block at &amp;lt;code&amp;gt;&amp;lt;sourcePos&amp;gt;&amp;lt;/code&amp;gt; is not a block entity.}}&lt;br /&gt;
{{Result table|cmd=/... with entity ...|&amp;lt;code&amp;gt;&amp;lt;source&amp;gt;&amp;lt;/code&amp;gt; fails to resolve to an entity (named player must be online).}}&lt;br /&gt;
{{Result table|cmd=/... with ... &amp;lt;path&amp;gt;|There&amp;#039;s no tag at &amp;lt;code&amp;gt;&amp;lt;path&amp;gt;&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
{{Result table|More than one tag is selected by &amp;lt;code&amp;gt;&amp;lt;path&amp;gt;&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
{{Result table|The tag at &amp;lt;code&amp;gt;&amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is not a compound tag.}}&lt;br /&gt;
{{Result table|cmd=/... &amp;lt;arguments&amp;gt;&amp;lt;br&amp;gt;/... with ..|With the provided arguments, any macro line in the function(s) becomes an unparseable command.}}&lt;br /&gt;
{{Result table|cmd=|Only one function is specified, and in it there&amp;#039;s no {{cmd|return}} command being executed.|[[Minecraft:Commands#Result|Void]]}}&lt;br /&gt;
{{Result table|Only one function is specified, and in it there&amp;#039;s a {{cmd|return}} command being executed and returning a failure.|fail}}&lt;br /&gt;
{{Result table|Multiple functions are specified, and in all of the functions, there is no {{cmd|return}} command being executed.|Void}}&lt;br /&gt;
{{Result table|succeed}}&lt;br /&gt;
{{Result table}}&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
{{IN|java}}, for {{cmd|return run execute store ... run function ...}}:&lt;br /&gt;
{{Output table}}&lt;br /&gt;
{{Output table|edition=je|On fail|N/A|0|0}}&lt;br /&gt;
{{Output table|On void|N/A|unchanged|unchanged}}&lt;br /&gt;
{{Output table|On success|N/A|1|the return value of the first [[Minecraft:Function_(Java_Edition)#Returning|non-void]] function&amp;lt;br&amp;gt;(Execution stops after first {{cmd|link=none|return}} in any of the specified functions)}}&lt;br /&gt;
{{Output table}}&lt;br /&gt;
{{IN|java}}, otherwise:&lt;br /&gt;
{{Output table}}&lt;br /&gt;
{{Output table|edition=je|On fail|0|0|0}}&lt;br /&gt;
{{Output table|On void|0|unchanged|unchanged}}&lt;br /&gt;
{{Output table|On success|1|1|the sum of the return values of all the [[Minecraft:Function_(Java_Edition)#Return|non-void]] functions}}&lt;br /&gt;
{{Output table}}&lt;br /&gt;
{{IN|be}}:&lt;br /&gt;
{{Output table|onlybe=1}}&lt;br /&gt;
{{Output table|edition=be|On fail|0}}&lt;br /&gt;
{{Output table|On success|1}}&lt;br /&gt;
{{Output table}}&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
* {{IN|java}}: &lt;br /&gt;
** To run a function located at &amp;lt;code&amp;gt;data/custom/function/example/test.mcfunction&amp;lt;/code&amp;gt; in a loaded data pack: {{cmd|function custom:example/test|link=none}}&lt;br /&gt;
** To run all functions in a function [[Minecraft:tags|tag]] located at &amp;lt;code&amp;gt;data/custom/tags/function/example/test.json&amp;lt;/code&amp;gt;: {{cmd|function #custom:example/test|link=none}}&lt;br /&gt;
** To run a function if there is a sheep within a radius of 2 blocks: &amp;lt;code&amp;gt;/execute if entity @e[type=sheep,distance=..2] run function custom:example/test&amp;lt;/code&amp;gt;&lt;br /&gt;
** To run a function unless the executor is a player: &amp;lt;code&amp;gt;/execute unless entity @s[type=player] run function custom:example/test&amp;lt;/code&amp;gt;&lt;br /&gt;
** To run a function macro with arguments a=42, b=&amp;quot;example&amp;quot;: &amp;lt;code&amp;gt;/function custom:example/test {a: 42, b: &amp;quot;example&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
** To run a function macro with arguments from storage &amp;lt;code&amp;gt;custom:storage&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;/function custom:example/test with custom:storage&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
=== &amp;#039;&amp;#039;Java Edition&amp;#039;&amp;#039; ===&lt;br /&gt;
{{HistoryTable&lt;br /&gt;
|{{HistoryLine|java}}&lt;br /&gt;
|{{HistoryLine||1.12|dev=pre1|Added {{cmd|function|link=none}}.}}&lt;br /&gt;
|{{HistoryLine|||dev=pre4|Added new arguments to the {{cmd|function|link=none}} command: &amp;lt;code&amp;gt;[if{{!}}unless] [selector]&amp;lt;/code&amp;gt;}}&lt;br /&gt;
|{{HistoryLine|||dev=pre6|Skipped functions (when a conditional fails) are now considered failures when used in commands.}}&lt;br /&gt;
|{{HistoryLine||1.13|dev=17w49b|{{cmd|function|link=none}} now accept function [[Minecraft:tags]] as the argument.|Removed {{cd|[if{{!}}unless]}} arguments in favor of {{cmd|execute [if{{!}}unless]}}.}}&lt;br /&gt;
|{{HistoryLine||1.20.2|dev=23w31a|Added function macro arguments.}}&lt;br /&gt;
|{{HistoryLine||1.20.3|dev=23w41a|{{cmd|link=none|function}} command no longer returns the number of commands executed to better accommodate new {{cmd|return}} command.}}&lt;br /&gt;
|{{HistoryLine|||dev=23w44a|If {{cmd|link=none|function &amp;lt;&amp;#039;&amp;#039;function tag&amp;#039;&amp;#039;&amp;gt;}} runs multiple functions in combination with {{cmd|link=none|return run}}, execution stops after first {{cmd|link=none|return}} in any of the functions.|A single call to the {{cmd|link=none|function}} command always returns when run with {{cmd|link=none|return run}}. For example, {{cmd|link=none|return run execute &amp;#039;&amp;#039;[split context]&amp;#039;&amp;#039; run function &amp;#039;&amp;#039;&amp;lt;some function with conditional return&amp;gt;&amp;#039;&amp;#039;}} always returns after processing the first context.}}&lt;br /&gt;
|{{HistoryLine||1.20.5|dev=23w51a|Fixed a bug that &amp;lt;code&amp;gt;/function&amp;lt;/code&amp;gt; executing a function with &amp;lt;code&amp;gt;/return fail&amp;lt;/code&amp;gt; has a &amp;lt;code&amp;gt;success&amp;lt;/code&amp;gt; value of 1.&amp;lt;ref&amp;gt;{{bug|MC-267193|||fixed}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{bug|MC-268160}}&amp;lt;/ref&amp;gt;}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== &amp;#039;&amp;#039;Bedrock Edition&amp;#039;&amp;#039; ===&lt;br /&gt;
{{HistoryTable&lt;br /&gt;
|{{HistoryLine|bedrock}}&lt;br /&gt;
|{{HistoryLine||1.8.0|dev=beta 1.8.0.8|Added {{cmd|function|link=none}}.}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* {{cmd|tag}} – To run function in batch, every tick, or on server (re)load.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* {{Cite|url=https://learn.microsoft.com/en-us/minecraft/creator/commands/commands/function?view=minecraft-bedrock-stable|title=&amp;lt;code&amp;gt;/function&amp;lt;/code&amp;gt; Command|website=Microsoft Learn|date=October 11, 2023}}&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
{{Navbox commands}}&lt;br /&gt;
&lt;br /&gt;
[[Minecraft:de:Befehl/function]]&lt;br /&gt;
[[Minecraft:es:Comandos/function]]&lt;br /&gt;
[[Minecraft:ja:コマンド/function]]&lt;br /&gt;
[[Minecraft:ko:명령어/function]]&lt;br /&gt;
[[Minecraft:pt:Comandos/function]]&lt;br /&gt;
[[Minecraft:ru:Команды консоли/function]]&lt;br /&gt;
[[Minecraft:uk:Команди консолі/function]]&lt;br /&gt;
[[Minecraft:zh:命令/function]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Kestrer</name></author>
	</entry>
</feed>