Minecraft Wiki
Advertisement
Information icon
This feature is exclusive to Java Edition. 

Functions allow players to run lists of commands using text files with the extension .mcfunction. It is recommended to use UTF-8 (without BOM) encoding on function files to prevent any problems.

Usage

To utilize functions, the text files must first be placed into a top-level folder within .minecraft/saves/[WORLD_NAME]/data/functions. The name of this top-level folder will be the namespace used when running functions inside this folder. Functions can also be placed into subfolders within the folder.

For example, running the function custom:example/test will refer to the file located at functions/custom/example/test.mcfunction. If the namespace is left out when trying to call a function, it will default to the minecraft: namespace. Using a custom namespace is recommended in order to prevent unintended behavior in the case of future additions to the default namespace.[1]

Functions, being text files, are easily modifiable and less likely than command blocks to induce lag when used in large quantities. If a function is modified or added, using the /reload command will reload the function files from disk. This allows Minecraft to recognize any changes to the function files, without the need to quit and re-enter the world.

Upon successfully running a function, a message will display in the chat: Executed [amount] command(s) from function '[function file directory]'. The successful output of the commands inside a function cannot be measured with a comparator (although the same effect could be accomplished with the use of /stats and /scoreboard commands).

Function syntax

TestingFunctions

Testing the function system. Three /tellraw messages and one /give command were used in this simple function.

Within the .mcfunction file, one valid command is placed per line, without the usual forward slash (/). Players can add comments within the function text file by preceding them with a #.

Individual commands in functions can be longer than the 32 500 character limit in command blocks but the total number of commands run inside a function will still obey /gamerule maxCommandChainLength, which is 65 536 commands by default; any commands beyond this limit will be ignored.

Running a function

Functions will run all of their commands in a single tick and functions called from within other functions will also run their commands in the same tick as their parent.

Position changes that happen within a function will not affect the relative coordinates used in other commands within that function (or within its child functions) until the next iteration, regardless of the order of commands. The /execute command circumvents this.

For example:

tp @s ~ ~5 ~
setblock ~ ~-1 ~ emerald_block
execute @s ~ ~ ~ setblock ~ ~-1 ~ diamond_block

When called through a player this function will teleport that player 5 blocks up, place an emerald block one block below their original position before the teleport, and place a diamond block one block below their new position after the teleport. This behavior does not affect position arguments within selectors, which will always test for the current position at the time of execution.

There are several methods of running a function file in-game:

Commands

/function
  • Allows players to run a function once.
  • The commands in the function are run through the entity or command block that ran the /function command.
  • The optional arguments if and unless will make the function only run when the selector was found or not found in the world respectively.
  • Usage: /function <name>
/gamerule gameLoopFunction
  • Runs a function every tick.
  • The commands in the function are run through the server.
  • The coordinate of the "server" is (0, 0, 0).
  • If multiple functions need to be looped, it is possible to insert function commands into this looped function file, put function commands in those functions, etc.
  • Usage: /gamerule gameLoopFunction <namespace:path/to/function/file>

Advancements

Advancements can run a function once as a reward for completing them. The commands in the function are run through the player who completed the advancement.

Reward functions are called within advancement JSON files using the following format:

{
    "rewards": {
        "function": "namespace:path/to/function/file"
    }
}

History

release
1.12
{{Extension DPL}}<ul><li>[[Cooked Rabbit|Cooked Rabbit]]<br/>{{Item
| title = Cooked Rabbit
| image = Cooked Rabbit.png
| heals = {{hunger|5}}
| renewable = Yes
| stackable = Yes (64)
}}

'''Cooked rabbit''' is a [[food]] item that can be eaten by the [[player]].

== Obtaining ==

=== Mob loot ===

{{IN|Bedrock}}, adult [[rabbit]]s drop 0–1 cooked rabbit if killed while on fire. The maximum amount is increased by 1 per level of [[Looting]], for a maximum of 0–4 with Looting III.

{{IN|Java}}, adult [[rabbit]]s drop 1 cooked rabbit if killed while on fire. The maximum amount is increased by 1 per level of [[Looting]], for a maximum of 1–4 with Looting III.

=== Cooking ===

Cooked rabbit can be obtained by cooking [[raw rabbit]] in a [[furnace]], [[smoker]], or [[campfire]].
{{Smelting
  |showname=1
  |Raw Rabbit
  |Cooked Rabbit
  |0,35
}}

=== Villagers ===
{{IN|java}}, butcher villagers may give players with the [[Hero of the Village]] effect cooked rabbit.

{{IN|bedrock}}, apprentice-level butcher villagers have 25% chance to sell 5 cooked rabbit for an emerald.

== Usage ==

=== Food ===

To eat a cooked rabbit, press and hold {{control|use}} while it is selected in the [[hotbar]]. Eating one restores {{hunger|5}} [[hunger]] and 6 hunger [[Hunger#Mechanics|saturation]].

=== Crafting ingredient ===
Cooked rabbit can be used to craft rabbit stew.

{{crafting usage}}

=== Wolves ===

Cooked rabbit can be used to [[breed]] and heal tamed [[wolves]], lead them around, and make baby tamed wolves grow up faster by 10% of the remaining time.

==Sounds==
{{Sound table/Entity/Food}}

== Data values ==
=== ID ===
{{edition|java}}:
{{ID table
|edition=java
|showforms=y
|generatetranslationkeys=y
|displayname=Cooked Rabbit
|spritetype=item
|nameid=cooked_rabbit
|form=item
|foot=1}}

{{edition|bedrock}}:
{{ID table
|edition=bedrock
|shownumericids=y
|showforms=y
|notshowbeitemforms=y
|generatetranslationkeys=y
|displayname=Cooked Rabbit
|spritetype=item
|nameid=cooked_rabbit
|id=289
|form=item
|foot=1}}

== Achievements ==

{{load achievements|Rabbit Season}}

== Advancements ==
{{load advancements|Husbandry;A Balanced Diet}}

== History ==

{{History|java}}
{{History||1.8|snap=June 30, 2014|slink=https://twitter.com/TheMogMiner/status/483636993780232192|[[Ryan Holtz]] tweeted images of cooked rabbits and some other new [[item]]s.}}
{{History|||snap=14w27a|[[File:Cooked Rabbit JE1.png|32px]] Added cooked rabbit. It is used to craft [[rabbit stew]].}}
{{History|||snap=14w33b|[[File:Cooked Rabbit JE2 BE1.png|32px]] The texture of cooked rabbit has been changed. The new texture was created by [[wikipedia:Reddit|Reddit]] user [http://www.reddit.com/u/zeldahuman zeldahuman].<ref>{{reddit|2bjzes/a_reminder_of_the_blocks_and_items_added_in_18_so|cj69zie|context=3}}</ref><ref>{{reddit|2c5f35/minecraft_snapshot_14w31a_has_been_released|cjct7gb}}</ref>}}
{{History||1.13|snap=17w47a|Prior to [[1.13/Flattening|''The Flattening'']], this [[item]]'s numeral ID was 412.}}
{{History||1.14|snap=18w43a|[[File:Cooked Rabbit JE3 BE2.png|32px]] The texture of cooked rabbit has been changed.}}
{{History|||snap=19w13a|Butcher [[villager]]s now give cooked rabbit to players under the [[Hero of the Village]] effect.}}
{{History||1.19.3|snap=22w42a|Rabbits now always drop at least 1 coooked rabbit when killed while on fire.}}

{{History|pocket alpha}}
{{History||v0.13.0|snap=build 1|[[File:Cooked Rabbit JE2 BE1.png|32px]] Added cooked rabbit.}}
{{History|bedrock}}
{{History||1.10.0|snap=beta 1.10.0.3|[[File:Cooked Rabbit JE3 BE2.png|32px]] The texture of cooked rabbit has been changed.}}
{{History||1.11.0|snap=beta 1.11.0.4|Cooked rabbit can now be [[trading|bought]] from butcher [[villager]]s.}}
{{History||1.12.0|snap=beta 1.12.0.3|The [[trading]] price of cooked rabbit has been lowered to one [[emerald]].}}

{{History|console}}
{{History||xbox=TU31|xbone=CU19|ps=1.22|wiiu=Patch 3|[[File:Cooked Rabbit JE2 BE1.png|32px]] Added cooked rabbit.}}
{{History|PS4}}
{{History||1.90|[[File:Cooked Rabbit JE3 BE2.png|32px]] The texture of cooked rabbit has been changed.}}

{{History|new 3ds}}
{{History||0.1.0|[[File:Cooked Rabbit JE2 BE1.png|32px]] Added cooked rabbit.}}
{{History|foot}}

== Issues ==

{{issue list}}

== Gallery ==
<gallery>
File:Rabbit Items 2 Ryan Holtz.png|First image of the item by [[Ryan Holtz]].
</gallery>

== References ==
{{reflist}}

{{items}}

[[Category:Food]]
[[Category:Renewable resources]]

[[de:Gebratenes Kaninchen]]
[[es:Conejo asado]]
[[it:Coniglio cotto]]
[[fr:Lapin cuit]]
[[ja:焼き兎肉]]
[[ko:익힌 토끼고기]]
[[nl:Gebraden konijnenvlees]]
[[pl:Pieczony królik]]
[[pt:Coelho assado]]
[[ru:Жареная крольчатина]]
[[zh:熟兔肉]]</li><li>[[Banner Pattern|Banner Pattern]]<br/>{{Item
| image = Banner Pattern.png
| rarity = 
* '''Flower Charge, Field Masoned, Bordure Indented, Globe, Snout'''
* Common
* '''Creeper Charge, Skull Charge'''
* Uncommon
* '''Thing'''
* Epic
| renewable = 
* '''Snout, Thing''': No
* '''All others''': Yes
| stackable = No
}}
'''Banner patterns''' are [[item]]s used to customize [[banner]]s inside [[loom]]s.
There are six patterns {{in|java}} and eight {{in|bedrock}}.

== Obtaining ==
[[File:Banner Patterns 20w15a.png|thumb|All six banner patterns {{in|java}} with their various sources.]]

=== Crafting ===
{{see also|Banner/Patterns|title1=List of patterned banners}}
4 out of 6 banner patterns {{only|JE}} and 2 more {{only|BE}} can be obtained by crafting. They are crafted by combining one [[paper]] along with a certain material.
{{Crafting
|head=1
|Paper
|Creeper Head
|Output=Banner Pattern Creeper
|type=Miscellaneous
|description=Creeper face
}}
{{Crafting
|Paper
|Wither Skeleton Skull
|Output=Banner Pattern Skull
|type=Miscellaneous
|description=Skeleton skull and crossbones
}}
{{Crafting
|Paper
|Oxeye Daisy
|Output=Banner Pattern Flower
|type=Miscellaneous
|description=Daisy
}}
{{Crafting
|Paper
|Enchanted Golden Apple
|Output=Banner Pattern Thing
|type=Miscellaneous
|showdescription=true
|description=Former [[Mojang Studios]] logo
}}
{{Crafting
|Paper
|Bricks
|Output=Banner Pattern Field Masoned
|type=Miscellaneous
|description={{only|bedrock}}
}}
{{Crafting
|Paper
|Vines
|Output=Banner Pattern Bordure Indented
|type=Miscellaneous
|description={{only|bedrock}}
|foot=1
}}

=== Trading ===
'''Globe banner pattern''' is obtained by trading with a master-level [[Trading#Cartographer|cartographer villager]] for a price of 8 emeralds.

=== Chest loot ===
'''Snout banner pattern''' is obtained in the [[Bastion Remnant]] as loot.
{{LootChestItem|snout-banner-pattern}}

== Usage ==
=== Loom ingredient ===
Banner patterns are used in [[loom]]s to add customization to [[banner]]s. The pattern must be combined with 1 banner and 1 [[dye]]. Upon usage in the loom, the banner pattern is not consumed.

{{Looming
|head=1
|showdescription=1
|name=[[Banner|Flower Charge Banner]]
|ingredients={{:Banner/recipe|ingredients}}
|{{:Banner/recipe|banner}}
|Matching Dye
|Banner Pattern Flower Charge
|Flower Charge
|{{:Banner/recipe|output|Flower Charge}}
|Blink=Banner
|Olink=Banner
|description=Emblazons a flower charge (flower icon)
}}

{{Looming
|name=[[Banner|Creeper Charge Banner]]
|ingredients={{:Banner/recipe|ingredients}}
|{{:Banner/recipe|banner}}
|Matching Dye
|Banner Pattern Creeper Charge
|Creeper Charge
|{{:Banner/recipe|output|Creeper Charge}}
|Blink=Banner
|Olink=Banner
|description=Emblazons a creeper charge (creeper face)
}}

{{Looming
|name=[[Banner|Skull Charge Banner]]
|ingredients={{:Banner/recipe|ingredients}}
|{{:Banner/recipe|banner}}
|Matching Dye
|Banner Pattern Skull Charge
|Skull Charge
|{{:Banner/recipe|output|Skull Charge}}
|Blink=Banner
|Olink=Banner
|description=Emblazons a skull charge (skull and crossbones)
}}

{{Looming
|name=[[Banner|Thing Banner]]
|ingredients={{:Banner/recipe|ingredients}}
|{{:Banner/recipe|banner}}
|Matching Dye
|Banner Pattern Thing
|Thing
|{{:Banner/recipe|output|Thing}}
|Blink=Banner
|Olink=Banner
|description=Emblazons a thing (old Mojang logo)}}

{{Looming
|name=[[Banner|Snout Banner]]
|ingredients={{:Banner/recipe|ingredients}}
|{{:Banner/recipe|banner}}
|Matching Dye
|Banner Pattern Snout
|Snout
|{{:Banner/recipe|output|Snout}}
|Blink=Banner
|Olink=Banner
|description=Emblazons a piglin snout
}}

{{Looming
|name=[[Banner|Globe Banner]]
|ingredients={{:Banner/recipe|ingredients}}
|{{:Banner/recipe|banner}}
|Matching Dye
|Banner Pattern Globe
|Globe
|{{:Banner/recipe|output|Globe}}
|Blink=Banner
|Olink=Banner
|description=Emblazons a globe (cube shaped earth)
}}

{{Looming
|name=[[Banner|Bordure Indented Banner]]
|ingredients={{:Banner/recipe|ingredients}}
|{{:Banner/recipe|banner}}
|Matching Dye
|Banner Pattern Bordure Indented
|Bordure Indented
|{{:Banner/recipe|output|Bordure Indented}}
|Blink=Banner
|Olink=Banner
|description=Emblazons a bordure indented (fancy border){{only|bedrock}}
}}

{{Looming
|name=[[Banner|Field Masoned Banner]]
|ingredients={{:Banner/recipe|ingredients}}
|{{:Banner/recipe|banner}}
|Matching Dye
|Banner Pattern Field Masoned
|Field Masoned
|{{:Banner/recipe|output|Field Masoned}}
|Blink=Banner
|Olink=Banner
|description=Emblazons a field masoned (brick pattern)‌{{only|bedrock}}
|foot=1
}}

== Data values ==
=== ID ===
{{edition|java}}:
{{ID table
|edition=java
|firstcolumnname=Banner Pattern
|showforms=y
|generatetranslationkeys=y
|displayname=Flower Charge
|spritename=banner-pattern
|spritetype=item
|nameid=flower_banner_pattern
|form=item}}
{{ID table
|displayname=Creeper Charge
|spritename=banner-pattern
|spritetype=item
|nameid=creeper_banner_pattern
|form=item}}
{{ID table
|displayname=Skull Charge
|spritename=banner-pattern
|spritetype=item
|nameid=skull_banner_pattern
|form=item}}
{{ID table
|displayname=Thing
|spritename=banner-pattern
|spritetype=item
|nameid=mojang_banner_pattern
|form=item}}
{{ID table
|displayname=Globe
|spritename=banner-pattern
|spritetype=item
|nameid=globe_banner_pattern
|form=item}}
{{ID table
|displayname=Snout
|spritename=banner-pattern
|spritetype=item
|nameid=piglin_banner_pattern
|form=item
|foot=1}}

{{edition|bedrock}}:
{{ID table
|edition=bedrock
|firstcolumnname=Banner Pattern
|showaliasids=y
|shownumericids=y
|showforms=y
|notshowbeitemforms=y
|generatetranslationkeys=y
|displayname=Creeper Charge
|spritename=banner-pattern
|spritetype=item
|nameid=creeper_banner_pattern
|aliasid=banner_pattern / 0
|id=582
|form=item
|translationkey=item.banner_pattern.name, item.banner_pattern.creeper}}
{{ID table
|displayname=Skull Charge
|spritename=banner-pattern
|spritetype=item
|nameid=skull_banner_pattern
|aliasid=banner_pattern / 1
|id=583
|form=item
|translationkey=item.banner_pattern.name, item.banner_pattern.skull}}
{{ID table
|displayname=Flower Charge
|spritename=banner-pattern
|spritetype=item
|nameid=flower_banner_pattern
|aliasid=banner_pattern / 2
|id=581
|form=item
|translationkey=item.banner_pattern.name, item.banner_pattern.flower}}
{{ID table
|displayname=Thing
|spritename=banner-pattern
|spritetype=item
|nameid=mojang_banner_pattern
|aliasid=banner_pattern / 3
|id=584
|form=item
|translationkey=item.banner_pattern.name, item.banner_pattern.thing}}
{{ID table
|displayname=Field Masoned
|spritename=banner-pattern
|spritetype=item
|nameid=field_masoned_banner_pattern
|aliasid=banner_pattern / 4
|id=585
|form=item
|translationkey=item.banner_pattern.name, item.banner_pattern.bricks}}
{{ID table
|displayname=Bordure Indented
|spritename=banner-pattern
|spritetype=item
|nameid=bordure_indented_banner_pattern
|aliasid=banner_pattern / 5
|id=586
|form=item
|translationkey=item.banner_pattern.name, item.banner_pattern.vines}}
{{ID table
|displayname=Snout
|spritename=banner-pattern
|spritetype=item
|nameid=piglin_banner_pattern
|aliasid=banner_pattern / 6
|id=587
|form=item
|translationkey=item.banner_pattern.name, item.banner_pattern.piglin}}
{{ID table
|displayname=Globe
|spritename=banner-pattern
|spritetype=item
|nameid=globe_banner_pattern
|aliasid=banner_pattern / 7
|id=588
|form=item
|translationkey=item.banner_pattern.name, item.banner_pattern.globe
|foot=1}}

== Achievements ==
{{load achievements|Fruit on the Loom}}

== History ==
{{History|java}}
{{History||1.14|snap=18w43a|[[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] Added banner patterns for flower charge, creeper charge, skull charge and thing patterns.}}
{{History|||snap=19w11a|[[File:Banner Pattern JE1 BE1.png|32px]] Added banner pattern for globe.
|The banner pattern for globe can be [[trading|bought]] from master-level cartographer [[villager]]s for 8 [[emerald]]s.}}
{{History||1.16|snap=20w15a|[[File:Banner Pattern JE1 BE1.png|32px]] Added the piglin banner pattern.}}
{{History|||snap=20w16a|The piglin banner pattern can now be found in [[chest]]s in [[bastion remnants]].}}
{{History|||snap=20w18a|The piglin pattern has now been renamed to "Snout".}}
{{History||1.16.2|snap=20w30a|The chance of finding the "Snout" banner pattern in bastion remnant chests has been increased from 5.5% to 10.1%.}}

{{History|bedrock}}
{{History||1.10.0|snap=beta 1.10.0.3|[[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] Added banner patterns for creeper charge, skull charge, flower charge, thing, field masoned and bordure indented patterns.}}
{{History||1.11.0|snap=beta 1.11.0.4|The banner patterns flower charge, field masoned and bordure indented can now be [[trading|bought]] from cartographer [[villager]]s.}}
{{History||1.16.0|snap=beta 1.16.0.57|[[File:Banner Pattern JE1 BE1.png|32px]] Added the piglin banner pattern.}}
{{History|||snap=beta 1.16.0.59|The piglin pattern has now been renamed to "Snout".}}
{{History||1.16.100|snap=beta 1.16.100.55|The "Thing" banner pattern can now be crafted at the [[loom]].}}
{{History||1.16.100|snap=beta 1.16.100.56|The ID of banner patterns have been changed from <code>banner_pattern</code> to <code><type>_banner_pattern</code>.}}
{{History||1.18.10|snap=beta 1.18.10.24|[[File:Banner Pattern JE1 BE1.png|32px]] Added banner pattern for globe. It is currently unobtainable in survival.}}
{{History|||snap=beta 1.18.10.26|The banner pattern for globe are now obtainable in survival and can be [[trading|bought]] from master-level cartographer [[villager]]s for 8 [[emerald]]s.
|Removed flower charge, field masoned and bordure indented banner pattern from villager trading.}}
{{History|PS4}}
{{History||1.90|[[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] [[File:Banner Pattern JE1 BE1.png|32px]] Added banner patterns for creeper charge, skull charge, flower charge, thing, field masoned and bordure indented patterns.}}
{{History|foot}}

== Issues ==
{{issue list}}

{{Items}}

[[de:Bannervorlage]]
[[es:Diseño de estandarte]]
[[fr:Motif de bannière]]
[[ja:旗の模様]]
[[ko:현수막 무늬]]
[[pl:Wzór sztandaru]]
[[pt:Desenho para estandarte]]
[[ru:Узор флага]]
[[th:ลวดลายธง]]
[[zh:旗帜图案]]</li></ul>
pre1Added functions.
pre3Commands are no longer allowed to begin with a / (forward slash)
Comments can now only be preceded with #; using // is no longer allowed
pre4Added new arguments to the /function command: [if|unless] [selector]
pre6Skipped functions (when a conditional fails) are now considered failures when used in commands.

Issues

Issues relating to "Function (Java Edition)" are maintained on the bug tracker. Report issues there.

References

Advertisement