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 encoding (without BOM) for function files to prevent any problems.

Usage

To utilize functions, the text files must first be placed into a top-level folder within [WORLD_NAME]/datapacks/[DATA_PACK_NAME]/data/[NAMESPACE]/functions. For single player, the world folders can be found in .minecraft/saves. For multiplayer, functions must be placed in every world folder that wants to utilize them (In 1.12 you MUST place the functions inside the main world folder (the one specified in the server.properties, level-name=(world-name here)), otherwise it will NOT work.). The name of the new top-level folder will be the namespace used when running the functions inside. Functions can also be placed into subfolders within the top-level 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. Functions will use the command environment of whatever called the function. This includes command sender, position, rotation, etc.

Changes to the command environment that happen within a function will not affect the command environment used by the other commands within that same function (or within its child functions) until the next iteration, regardless of the order of commands. The /execute command is an exception and will update the command environment.

For example:

1.12

execute @a ~ ~ ~ function foo:bar

foo:bar

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

1.13

execute as @a at @s run function foo:bar

foo:bar

teleport @s ~ ~5 ~
setblock ~ ~-1 ~ emerald_block
execute at @s run 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 target selector arguments.

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 coordinates from which the "server" executes commands are (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>
  • To stop the loop just point gameLoopFunction to a non-existing function: /gamerule gameLoopFunction -, this value is also the default.

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"
    }
}

Tags

Functions can be grouped together using tags in data packs. These tags can then be called to run all the functions inside that tag with /function #(namespace):tag.

Functions tagged in minecraft:tick will automatically run every tick at the beginning of the tick. Functions tagged in minecraft:load will run after (re)loading the datapack.

History

release
1.12
{{Extension DPL}}<ul><li>[[Chalkboard|Chalkboard]]<br/>{{Education feature}}
{{unobtainable|edition=be}}{{Block
|image=<gallery>
Chalkboard Slate.png|Slate
Chalkboard Poster.png|Poster
Chalkboard Board.png|Board
</gallery>
|invimage=Slate
|invimage2=Poster
|invimage3=Board
|transparent=Yes
|renewable=No
|light=No
|tool=None
|stackable=Yes (16)
|flammable=No
}}
A '''chalkboard''' is a [[block]] that can display more text than a [[sign]].<ref>https://education.minecraft.net/support/knowledge-base/using-slates-posters-boards/</ref> Three sizes are available: 1×1 (slate), 2×1 (poster), and 3×2 (board).

== Obtaining ==
In ''[[Education Edition]]'', chalkboards can be obtained in the [[Creative inventory]] or through the {{cmd|give}} command.
In ''[[Bedrock Edition]]'', chalkboards cannot be obtained by commands or the creative inventory, and can only be obtained by using glitches or inventory editors.

== Usage ==
A chalkboard can be used similarly to a [[sign]], to display text. Once placed, select the chalkboard and enter the desired text and click the "OK" button. The "×" in the upper right corner of the board closes the edit screen.

=== Placement ===
Chalkboards may be placed on the top or side of other blocks (including non-solid blocks like [[fence]]s, [[glass]], [[rail]]s, and other chalkboards). To place a chalkboard, {{control|use}} a chalkboard item while pointing at the block the chalkboard should be attached to. To place a chalkboard on a block that can be interacted with by the {{control|use}} control (for example, [[chest]]s, [[note block]]s, etc.), {{control|sneak}} while placing the chalkboard.

1×1 slates placed on the top of a block stand on a short post, facing in the direction of the player who placed it, in any of 16 different directions. 2×1 posters and 2×3 boards can be placed in any of 4 different directions. Chalkboards placed on the side of a block simply float there, even if the block doesn't make contact with the chalkboards.

=== Text ===
When entering text, six lines of text are available for the slates and posters, while fifteen lines of text are available for the 2×3 boards. To switch between lines, the player can press Enter or the up/down arrow keys. The location of text currently selected has a flashing cursor.

While editing, typing and backspacing can occur at any point in the line by moving the cursor using the left and right arrow keys. Once the end of the line has been reached, the word is hyphenated and is continued on the next line.

After the editing window is closed, right-clicking on a chalkboard reopens the editing menu. Copy and paste can be performed, and no more than the basic/shifted keyboard characters may be entered.

=== Interaction ===
Chalkboards act as though they have a {{control|use}} action, so {{control|sneaking}} is required to place blocks or use items while the cursor is pointed at them.

Unlike signs, boards block a [[piston]] from moving.

Boards have no collision box (they are completely non-solid), so [[item]]s and [[mob]]s can move through boards blocks. Other blocks (including other boards) can be placed on any edge of a board.

[[Water]] and [[lava]] flow around boards. Lava can create [[fire]] in [[air]] blocks next to boards as if the boards were flammable, but the boards do not burn.

== Sounds ==
{{Sound table/Block/Stone/BE}}

== Data values ==
=== ID ===
{{ID table
|edition=bedrock
|shownumericids=y
|showforms=y
|generatetranslationkeys=y
|displayname=Block
|spritename=chalkboard
|spritetype=block
|nameid=chalkboard
|id=230
|form=block
|translationkey=tile.chalkboard.oneByOne.name, tile.chalkboard.twoByOne.name, tile.chalkboard.threeByTwo.name}}
{{ID table
|displayname=Item
|spritename=board
|spritetype=item
|nameid=board
|translationkey=tile.chalkboard.oneByOne.name, tile.chalkboard.twoByOne.name, tile.chalkboard.threeByTwo.name
|id=454
|form=item
|foot=1}}

=== Metadata ===
{{see also|Data values}}
Chalkboards uses the following data values:

*Slate: 1
*Board: 2
*Poster: 3
<!--{{/DV}}-->

=== Block states ===
{{see also|Block states}}
{{info needed}}
<!--{{/BS}}-->

== History ==
{{History|pocket alpha}}
{{History||v0.16.0|snap=build 1|[[File:Chalkboard Slate.png|32px]] [[File:Chalkboard Poster.png|32px]] [[File:Chalkboard Board.png|32px]]<br>[[File:Chalkboard_Slate_(item)_BE1.png|32px]] [[File:Chalkboard_Poster_(item)_BE1.png|32px]] [[File:Chalkboard_Board_(item)_BE1.png|32px]] Added chalkboards, likely as an accidental addition.
|Chalkboards can be obtained and placed using the {{cmd|give}} and {{cmd|setblock}} [[command]]s respectively. However, they serve no purpose.}}
{{History|||snap=build 2|Chalkboards have now been removed. However, the textures still exist.}}
{{History|bedrock}}
{{History||1.11.0|snap=beta 1.11.0.1|Re-added chalkboards. They still exist as entities, but can't be spawned. The items can't be spawned either.}}
{{h||1.17.30|snap=beta 1.17.30.20|Chalkboards can now be placed consistently.}} 

{{History|education}}
{{History||MinecraftEdu|link=MinecraftEdu|[[File:Oak Sign JE1 BE1.png|30px]] [[MinecraftEdu]], Education Edition's predecessor, had "[[Big Sign]]s", 3 block wide signs that served a similar purpose.}}
{{History||1.0|[[File:Chalkboard Slate.png|32px]] [[File:Chalkboard Poster.png|32px]] [[File:Chalkboard Board.png|32px]]<br>[[File:Chalkboard_Slate_(item)_BE1.png|32px]] [[File:Chalkboard_Poster_(item)_BE1.png|32px]] [[File:Chalkboard_Board_(item)_BE1.png|32px]] Added chalkboards.}}
{{History||1.0.2|The UI of chalkboards now has a locked option.
|[[Player|Students]] now can place their own chalkboards even without a worldbuilder ability.}}
{{History|foot}}

== Gallery ==
<gallery>
Education Edition Exclusive Features.png|The chalkboard placed in a world along with other Education Edition features.
Chalkboardsingamepe.png|The chalkboard in [[Pocket Edition v0.16.0 alpha build 1]].
</gallery>

== References ==
{{Reflist}}

{{Blocks|Utility}}
{{Items}}
{{Education Edition}}

[[Category:Utility blocks]]
[[Category:Block entities]]
[[Category:Education Edition blocks]]
[[Category:Education Edition items]]

[[pt:Lousa]]
[[de:Tafel]]
[[fr:Ardoise]]
[[ja:黒板]]
[[pl:Tablica kredowa]]
[[ru:Доска]]
[[uk:Дошка]]
[[zh:黑板]]</li><li>[[Emerald|Emerald]]<br/>{{About|the item|the currency in ''Minecraft Dungeons''|MCD:Emerald|the skin|MCD:Emerald (skin)|the ore|Emerald Ore|the mineral block|Block of Emerald}}
{{Item
| image = Emerald.png
| renewable =  Yes
| stackable = Yes (64)
| rarity = Common}}
'''Emeralds''' are rare minerals that are used primarily as the currency for [[trading]] with [[villager]]s and [[wandering trader]]s. Naturally-occurring emeralds are rarer than [[diamond]]s.

== Obtaining ==

=== Trading ===
{{main|Trading}}
Emeralds can be obtained by trading with [[villager]]s, since they are the currency that villagers use for trading. Villagers either buy or sell specific goods for emeralds.

=== Mining ===
[[Emerald ore]] drops one emerald when mined using an iron or better [[pickaxe]]. If the pickaxe is enchanted with [[Fortune]], it may drop an extra emerald per level of Fortune, up to a maximum of 4 emeralds with Fortune III. If the ore is mined using a pickaxe enchanted with [[Silk Touch]], it drops itself in ore form instead of an emerald.

=== Crafting ===

{{Crafting
|Block of Emerald
|Output= Emerald,9
|type= Material
}}

=== Smelting ===

{{Smelting
|Emerald Ore; Deepslate Emerald Ore
|Emerald
|1
}}

=== Natural generation ===
{{see also|Emerald Ore#Natural generation}}

Emeralds can generate in [[chest]]s in some [[village]] houses or other generated [[Generated structures|structures]].

{{needs update|inaccurate=1|section=1}}
{{LootChestItem|emerald}}

=== Drops ===
[[Vindicator]]s and [[evoker]]s drop 0–1 emeralds upon death. [[Looting]] increases the maximum emerald drop by one per level, for a maximum of 4 emeralds with Looting III.

[[Fox]]es that are holding emeralds also have a chance of 100% to drop the emerald they are holding upon death. Alternatively, the player can drop a food item to entice the fox to drop the emerald without killing it.

{{IN|bedrock}}, vindicators and [[pillager]]s spawned from [[raids]] can drop 0–1 emeralds. Depending on difficulty, vindicators and pillagers spawned from raids also have a chance of dropping additional emeralds. There is a 65% chance of dropping on easy and normal, and an 80% chance of dropping on hard. If this additional drop condition is met, different emerald counts can drop with different chances. There is a {{frac|10|39}} chance to drop an additional 0–1 emeralds, a {{frac|5|39}} chance to drop an additional 2–3, and a {{frac|2|39}} chance to drop an additional 4–5.

{{IN|bedrock}}, with Looting III, it is possible for a vindicator in a raid to drop up to 16 emeralds upon death (vindicator drops + raid drops + an additional drop<!-- emerald from 2/39 chance-->).

== Usage ==

=== Trading ===

{{main|Trading}}

Emeralds are primarily used as currency for [[trading]] with villagers and wandering traders. Trading is typically a faster way to obtain emeralds than by mining, as an emerald ore is rarer than a diamond ore.

=== Crafting ingredient ===
{{crafting usage}}

===Beacons===

Emeralds can be used to select powers from a [[beacon]]. The player must select one of the available powers and then insert an emerald into the item slot. 

An emerald can be substituted for an [[iron ingot]], a [[gold ingot]], a [[diamond]] or a [[netherite ingot]] in a beacon.

=== Smithing ingredient ===
{{Smithing
|head=1
|ingredients=Any Armor Trim +<br/>Any Armor Piece + <br/>Emerald
|Any Armor Trim Smithing Template
|Netherite Chestplate
|Emerald
|Emerald Trim Netherite Chestplate
|showdescription=1
|description = All armor types can be used in this recipe,<br/>a netherite chestplate is shown as an example.
|tail=1
}}

;Trim color palette
The following color palette is shown on the designs on trimmed armor:
*{{TrimPalette|emerald}}

== Achievements ==

{{load achievements|The Haggler;Buy Low;Master Trader}}

== Advancements ==
{{load advancements|What a Deal!}}

== Data values ==
=== ID ===
{{edition|java}}:
{{ID table
|edition=java
|showitemtags=y
|showforms=y
|generatetranslationkeys=y
|displayname=Emerald
|spritetype=item
|nameid=emerald
|itemtags=beacon_payment_items
|form=item
|foot=1}}

{{edition|bedrock}}:
{{ID table
|edition=bedrock
|shownumericids=y
|showforms=y
|notshowbeitemforms=y
|generatetranslationkeys=y
|displayname=Emerald
|spritetype=item
|nameid=emerald
|id=512
|form=item
|foot=1}}

== History ==

{{History|java indev}}
{{History||0.31|snap=20100129|Added [[diamond]]s, referred to as emeralds in the code.}}
{{History|java}}
{{History||May 21, 2012|link={{tweet|jeb_|204619936616808451}}|[[File:Ruby pJE20120521.png|32px]] [[Jens Bergensten|Jeb]] released a screenshot of himself testing the [[trading]] system. At this time, what would become emeralds were [[History_of_textures/Unused_textures#Ruby|rubies]].<ref>http://www.minecraftforum.net/topic/1621716-15-new-blocksitems/#entry19977082</ref>}}
{{History||1.3.1|snap=12w21a|[[File:Emerald JE1 BE1.png|32px]] Added emeralds and [[emerald ore]].
|Emeralds can be [[trading|traded]] with [[villager]]s in exchange for different [[item]]s.
|Added [[desert temple]]s, with a hidden [[chest]] room and loot containing emeralds.
|[[File:Ruby JE1 BE1.png|32px]] The texture of [[History_of_textures/Unused_textures#Ruby|rubies]] can be found in the (at this time unused) file {{cd|items.png}}.<ref name="en_US 12w21">Snapshot 12w21a/b ''lang/en_US.lang'': '''item.ruby.name=Ruby'''</ref>}}
{{History|||snap=12w22a|[[Block of emerald]] has now been added, which is [[crafting|crafted]] from nine emeralds and can be placed as a decorative [[block]].
|Added [[jungle temple]]s, which contain loot [[chest]]s with emeralds.}}
{{History||1.4.2|snap=12w32a|As [[zombie villager]]s can now spawn and be cured, emeralds can now still be obtained in [[trading|trades]] even if [[generated structures]] are disabled.}}
{{history||1.9|snap=15w31a|Emeralds now generate in [[end city]] ship [[chest]]s.}}
{{history|||snap=15w43a|Emeralds now generate in [[igloo]] basement chests.}}
{{history|||snap=15w44a|The average yield of emeralds in [[desert temple]] chests has now been increased.}}
{{History||1.11|snap=16w39a|Added [[vindicator]]s and [[evoker]]s, which drop emeralds if killed by a player.}}
{{History||1.13|snap=17w47a|Prior to [[1.13/Flattening|''The Flattening'']], this [[item]]'s numeral ID was 388.}}
{{History|||snap=18w09a|Emeralds can now generate in the loot [[chest]]s of [[underwater ruins]].}}
{{History|||snap=18w10a|Emeralds can now generate in [[buried treasure]] chests.}}
{{History|||snap=18w11a|Emeralds can now generate in the chests of [[shipwreck]]s.}}
{{History||1.14|snap=18w43a|[[File:Emerald JE2 BE2.png|32px]] The texture of emeralds has now been changed.
|Added [[pillager]]s, which can [[drops|drop]] emeralds.}}
{{History|||snap=18w46a|Pillagers no longer drop emeralds.}}
{{History|||snap=18w48a|Emeralds now generate in chests in [[village]] tanneries, fisher cottages and plains village houses.}}
{{History|||snap=18w49a|Emeralds now generate in chests in [[village]] shepherd houses, mason houses, butcher shops, and savanna and snowy village houses.}}
{{History|||snap=18w50a|Emeralds now generate in chests in [[village]] fletcher houses, temples, and desert and taiga village houses.}}
{{History|||snap=19w07a|Added [[fox]]es, which sometimes spawn with emeralds in their mouths.}}
{{History|||snap=19w08a|[[File:Emerald JE3 BE3.png|32px]] The texture of emeralds has now been changed, once again and it looks smaller.}}
{{History||1.17|snap=21w13a|The unused [[History_of_textures/Unused_textures#Ruby|rubies]] texture was removed.}}
{{History||1.20<br>(Experimental)|link=1.19.4|snap=23w04a|Emeralds can now be used as an armor trim material.}}
{{History|||snap=23w07a|Emeralds now drop when brushing [[suspicious sand]] in [[desert pyramid]]s or [[desert well]]s.}}
{{History||1.20|snap=23w12a|The probability for the emerald to generate in the [[suspicious sand]] in [[desert temple]] and in [[desert well]] has been changed from 1/7 to 1/8.|Emerald can now be found in [[suspicious gravel]] and [[suspicious sand]] in cold and warm [[ocean ruins]] and in [[trail ruins]].}}
{{History|||snap=23w16a|Emerald no longer generates in [[suspicious sand]] in [[trail ruins]].|Due to the split of the archaeological loot tables for the suspicious gravel within the [[trail ruins]]; emerald now is in the common loot.}}

{{History|pocket alpha}}
{{History||v0.9.0|snap=build 1|[[File:Emerald JE1 BE1.png|32px]] Added emeralds.}}
{{History|||snap=build 5|Emeralds can now be used to craft [[blocks of emerald]].}}
{{History||v0.13.0|snap=build 1|Emeralds can now be found inside [[desert temple]] [[chest]]s.}}
{{History||v0.15.0|snap=build 1|Added [[jungle temple]]s, which contain loot chests with emeralds.}}
{{History||v0.16.0|snap=build 1|Emeralds can now be used to power [[beacon]]s.}}
{{History|pocket}}
{{History||1.0.0|snap=alpha 0.17.0.1|Emeralds can now be found in [[end city]] ship [[chest]]s.
|Emeralds can now be found in [[igloo]] basement chests.}}
{{History||1.0.4|snap=alpha 1.0.4.0|Emeralds are now used as "currency" for [[villager]] [[trading]].}}
{{History||1.1.0|snap=alpha 1.1.0.0|Added [[evoker]]s and [[vindicator]]s, which [[drops|drop]] emeralds when killed.}}
{{History|bedrock}}
{{History||1.4.0|snap=beta 1.2.14.2|Emeralds can now be found in some [[shipwreck]] [[chest]]s.}}
{{History|||snap=beta 1.2.20.1|Emeralds can now be found inside [[underwater ruins]] chests.}}
{{History||1.10.0|snap=beta 1.10.0.3|Emeralds can now be used to [[trading|buy]] items from [[wandering trader]]s.
|Emeralds can now be found in [[plains]] [[village]] house and tannery [[chest]]s.
|[[File:Emerald JE2 BE2.png|32px]] The texture of emeralds has now been changed.}}
{{History||1.11.0|snap=beta 1.11.0.1|Emeralds can now be found in [[village]] [[chest]]s other than [[plains]].}}
{{History|||snap=beta 1.11.0.4|[[Vindicator]]s and [[pillager]]s that spawn from [[raid]]s can now [[drops|drop]] bonus emeralds.}}
{{History|||snap=beta 1.11.0.5|[[File:Emerald JE3 BE3.png|32px]] The texture of emeralds has now been changed, once again.}}
{{History||1.13.0|snap=beta 1.13.0.1|Added [[fox]]es, which can [[drops|drop]] emeralds.}}
{{History||Next Major Update<br>(Experimental)|link=Bedrock Edition 1.19.70|snap=beta 1.19.70.23|Emeralds now drop when brushing [[suspicious sand]] in [[desert pyramid]]s or [[desert well]]s.}}
{{History|||snap=beta 1.19.80.21|Emeralds can now be used as an armor trim material.}}

{{History|console}}
{{History||xbox=TU14|xbone=CU1|ps=1.04|wiiu=Patch 1|switch=1.0.1|[[File:Emerald JE1 BE1.png|32px]] Added emeralds.}}
{{History|Ps4}}
{{History||1.90|[[File:Emerald JE2 BE2.png|32px]] The texture of emeralds has now been changed.}}

{{History|new3DS}}
{{History||0.1.0|[[File:Emerald JE1 BE1.png|32px]] Added emeralds.}}
{{History|foot}}

== Issues ==

{{issue list}}

== Gallery ==

<gallery>
Villager trading preview.png|The first image of the trading system released by [[Jeb]]. What would become emeralds can be seen in the [[inventory]] space.
Emerald Ore 12w21a.png|A wall of [[emerald ore]] utilizing a previous texture in snapshot [[12w21a]].
Room of Emeralds.png|All forms of emeralds in one photo: emerald (in the form of [[emerald block|block]], [[emerald ore|ore]] and the emerald itself).
</gallery>

==Trivia==

*The [[History_of_textures/Unused_textures#Ruby|ruby]] was going to be the [[villager]] currency but was changed to emeralds before the update's release.

== References ==

{{Reflist}}

{{Items}}

[[Category:Renewable resources]]

[[cs:Smaragd]]
[[de:Smaragd]]
[[es:Esmeralda]]
[[fr:Émeraude]]
[[hu:Smaragd]]
[[it:Smeraldo]]
[[ja:エメラルド]]
[[ko:에메랄드]]
[[nl:Smaragd]]
[[pl:Szmaragd]]
[[pt:Esmeralda]]
[[ru:Изумруд]]
[[th:มรกต]]
[[tr:Zümrüt]]
[[uk:Смарагд]]
[[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.
1.13
{{Extension DPL}}<ul><li>[[Coal|Coal]]<br/>{{About|the fuel item that can be mined|the ore|Coal Ore|the block|Block of Coal|the smelted wood|Charcoal}}
{{Item
| image = Coal.png
|type=
| renewable = Yes
| stackable = Yes (64)
}}
'''Coal''' is a mineral [[item]] mainly obtained from [[Coal Ore|coal ore]]. It is primarily used for crafting [[torches]] and [[Campfire|campfires]], as well as [[fuel]].

== Obtaining ==

=== Chest loot ===
{{see also|Coal Ore#Natural generation}}
{{LootChestItem|coal}}

=== Mining ===

[[Coal ore]] are mined using a [[pickaxe]] and drops 1 piece of coal. If the pickaxe is enchanted with [[Fortune]], it may drop an extra piece per level of Fortune, up to a maximum of 4 with Fortune III.

=== Mob loot ===

[[Wither skeleton]]s have a {{Frac|1|3}} chance of dropping a single coal upon death. The maximum amount of coal is increased by 1 per level of [[Looting]]. The chance of a wither skeleton ''not'' dropping any coal can be found using the formula <code>2 / (Looting Level + 3)</code>. For example, Looting III gives a {{frac|1|3}} chance of not dropping any coal. All other amounts have an equal chance of occurring.

=== Crafting ===

{{Crafting
 |showname=1
 |Block of Coal
 |Output=Coal,9
 |type=Material
}}

=== Smelting ===

{{Smelting
 |head=1
 |Coal Ore

 |Coal
 |0,1
|foot=1
}}

== Usage ==

=== Crafting ingredient ===

{{crafting usage|Coal}}

=== Fuel ===

When used in a [[furnace]] as a fuel, a piece of coal lasts 80 seconds (smelting up to 8 items), like [[charcoal]]. Coal used as fuel lasts more than 5 times longer than [[wood planks]] or [[wood]] logs used as fuel, being more efficient than any other use of wood for smelting {{in|je}}, but outstripped by [[wooden slabs]] {{in|be}}. 

Coal and charcoal are also the only fuels accepted by [[Minecart with Furnace|furnace minecart]]s. They provide approximately four minutes of transit each.

=== Trading ===

Novice-level fisherman [[villager]]s have a 50% chance to buy 10 coal for one [[emerald]].

{{IN|java}}, novice-level armorer and toolsmith villagers have a 40% chance of offering to buy 15 coal for one emerald. Novice-level weaponsmith villagers and apprentice-level butcher villagers have {{frac|2|3}} chance of offering to buy 15 coal for one emerald.

{{IN|bedrock}}, novice-level armorer, toolsmith, and weaponsmith villagers and apprentice-level butcher villagers buy 15 coal for one emerald.

[[trading|Trade]]s that involve coal cannot be substituted by [[charcoal]].

== Data values ==
=== ID ===
{{edition|java}}:
{{ID table
|edition=java
|showitemtags=y
|showforms=y
|generatetranslationkeys=y
|displayname=Coal
|spritetype=item
|nameid=coal
|itemtags=coals
|form=item
|foot=1}}

{{edition|bedrock}}:
{{ID table
|edition=bedrock
|showitemtags=y
|showaliasids=y
|shownumericids=y
|showforms=y
|notshowbeitemforms=y
|generatetranslationkeys=y
|displayname=Coal
|spritetype=item
|nameid=coal
|aliasid=coal / 0
|id=302
|itemtags=minecraft:coals
|form=item
|foot=1}}

== History ==

{{History|java classic}}
{{History||May 21, 2009|link=https://web.archive.org/web/0/http://notch.tumblr.com/post/110762705/my-list-on-tile-types-so-far|[[Notch]] shows interest in adding coal, commenting that it might be combined with [[iron ore]] to make steel.}}
{{History|java indev}} 
{{History||0.31|snap=20100128|[[File:Coal JE1.png|32px]] Added coal. 
|Mining [[coal ore]] blocks [[drops]] 2-5 pieces of coal.}}
{{History||0.31|snap=20100129|Coal can be used to craft [[torch]]es.}}
{{History||?|Mining [[coal ore]] now drops 1 piece of coal (down from 2-5).}}
{{History||20100219|[[File:Coal JE2 BE1.png|32px]] The texture of coal has been changed. It is now more centered.}}
{{History|java beta}}
{{History||1.8|snap=Pre-release|Coal can now be found in the new [[mineshaft]] [[chest]]s and [[stronghold]] storeroom chests.}}
{{History|java}}
{{History||1.0.0|snap=?|Coal can be now obtained by [[smelting]] [[coal ore]].}}
{{History||1.2.1|snap=12w04a|Coal can now be used to craft [[fire charge]]s.}}
{{History||1.3.1|snap=12w21a|Blacksmith and butcher [[villager]]s now [[trading|buy]] 16–23 of either coal or charcoal for 1 [[emerald]].}}
{{History|||snap=1.3|[[File:Coal JE3 BE2.png|32px]] The texture of coal has been changed.}}
{{History||1.4.2|snap=12w36a|Coal is now dropped by [[wither skeleton]]s, making it [[renewable resource|renewable]].}}
{{History||1.6.1|snap=13w18a|Coal can now be used to craft [[block of coal|coal block]]s.}}
{{History||1.8|snap=14w02a|Fisherman, armorer, tool smith, weapon smith and butcher [[villager]]s now [[trading|buy]] 16–24 coal for 1 [[emerald]].}}
{{History||1.9|snap=15w43a|Coal may now be found in [[igloo]] basement [[chest]]s.}}
{{History|||snap=15w44a|The average yield of coal from [[mineshaft]] chests has been decreased, and added to [[dungeon]] chests.}}
{{History||1.11|snap=16w39a|Coal can now be found in the new [[woodland mansion]] [[chest]]s.}}
{{History||1.13|snap=17w47a|The different data values for the <code>coal</code> ID have been split up into their own IDs.
|Prior to [[1.13/Flattening|''The Flattening'']], this [[item]]'s numeral ID was 263.}}
{{History|||snap=18w09a|Coal can now be found in the loot [[chest]]s of [[underwater ruins]].}}
{{History|||snap=18w11a|Coal now generates in [[shipwreck]] [[chest]]s.}}
{{History||1.14|snap=18w43a|[[File:Coal JE4 BE3.png|32px]] The texture of coal has been changed.}}
{{History|||snap=18w48a|Coal can now be found in [[chest]]s in [[village]] fishing cottages.}}
{{History|||snap=18w49a|Coal can now be found in [[chest]]s in [[village]] butcher shops and [[snowy tundra|snowy]] village houses.}}
{{History|||snap=18w50a|Coal can now be found in [[chest]]s in [[village]] toolsmith houses.}}
{{History|||snap=19w02a|Coal can now be used to craft [[campfire]]s. Destroying a campfire returns 2 charcoal.}}
{{History||1.16|snap=20w06a|Coal can now be used to craft [[torch|soul torches]].}}
{{History||1.19|snap=22w13a|Coal may now be found in [[ancient city]] [[chest]]s.}}
{{History||1.20|snap=23w12a|Coal can now be found in [[suspicious gravel]] and [[suspicious sand]] in cold and warm [[ocean ruins]] and in [[trail ruins]].}}
{{History|||snap=23w16a|Coal no longer generates in [[suspicious sand]] in [[trail ruins]].|Due to the split of the archaeological loot tables for the suspicious gravel within the [[trail ruins]]; coal now is in the common loot.}}

{{History|pocket alpha}}
{{History||v0.3.0|[[File:Coal JE2 BE1.png|32px]] Added coal.
|Coal can be used to craft [[torch]]es.}}
{{History||v0.8.0|snap=build 1|[[File:Coal JE3 BE2.png|32px]] The texture of coal has been changed.
|Coal can now be crafted to make a [[block of coal]].}}
{{History||v0.12.1|snap=build 1|Coal is now [[drops|dropped]] by [[wither skeleton]]s.}}
{{History||v0.14.0|snap=build 1|Coal can now be found inside [[minecart with chest|chest minecarts]] in [[mineshaft]]s.}}
{{History||v0.15.0|snap=build 1|Coal is now used to craft [[fire charge]]s.}}
{{History|pocket}}
{{History||1.0.0|snap=alpha 0.17.0.1|Coal can now be found in the [[stronghold]] storeroom [[chest]]s.
|Coal may now be found in [[igloo]] basement chests.}}
{{History||1.0.4|snap=alpha 1.0.4.0|Fisherman, armorer, toolsmith, weaponsmith and butcher [[villager]]s now [[trading|buy]] 16–24 coal for 1 [[emerald]].}}
{{History||1.1.0|snap=alpha 1.1.0.0|Coal is now found in [[woodland mansion]] [[chest]]s.}}
{{History|bedrock}}
{{History||1.4.0|snap=beta 1.2.14.2|Coal can now be found inside [[shipwreck]] [[chest]]s.}}
{{History|||snap=beta 1.2.20.1|Coal can now be found inside [[underwater ruins]] [[chest]]s.}}
{{History||1.10.0|snap=beta 1.10.0.3|Coal can now be used to craft [[campfire]]s. Destroying a campfire returns 2 charcoal.
|[[File:Coal JE4 BE3.png|32px]] The texture of coal has been changed.}}
{{History||1.11.0|snap=beta 1.11.0.1|Coal can now be found in [[snowy tundra]] [[village]] house [[chest]]s and in village butcher and toolsmith chests.}}
{{History|||snap=beta 1.11.0.4|Armorer, weaponsmith, toolsmith, and butcher [[villager]]s now [[trading|buy]] 15 coal for an [[emerald]].
|Fishermen villagers now have a 50% chance to buy 10 coal for an emerald as part of their first tier [[trading|trade]].}}
{{History||1.16.0|snap=beta 1.16.0.51|Coal can now used to craft [[soul torch]]es.}}

{{History|console}}
{{History||xbox=TU1|xbone=CU1|ps=1.0|wiiu=Patch 1|switch=1.0.1|[[File:Coal JE2 BE1.png|32px]] Added coal.}}
{{History||?|[[File:Coal JE3 BE2.png|32px]] The texture of coal has been changed.}}
{{History||xbox=none|xbone=none|ps=1.90|wiiu=none|switch=none|[[File:Coal JE4 BE3.png|32px]] The texture of coal has been changed.}}

{{History|New 3DS}}
{{History||0.1.0|[[File:Coal JE3 BE2.png|32px]] Added coal.}}
{{History|foot}}

== Issues ==
{{issue list|Coal}}

{{Items}}

[[Category:Renewable resources]]

[[cs:Uhlí]]
[[de:Kohle]]
[[es:Carbón]]
[[fr:Charbon]]
[[hu:Szén]]
[[it:Carbone]]
[[ja:石炭]]
[[ko:석탄]]
[[nl:Steenkool]]
[[pl:Węgiel]]
[[pt:Carvão]]
[[ru:Уголь]]
[[th:ถ่าน]]
[[tr:Kömür]]
[[uk:Вугілля]]
[[zh:煤炭]]</li><li>[[Egg|Egg]]<br/>{{About|chicken eggs|the similar item that spawns mobs|Spawn egg|other uses}}
{{ItemEntity
|image=Egg.png
|renewable=Yes
|stackable=Yes (16)
|size=Height: 0.25 Blocks<br>Width: 0.25 Blocks
}}

An '''egg''' is an [[item]] that can be used to craft [[food]] items, or thrown for a chance to spawn [[chick]]s on impact.

== Obtaining ==
=== Mob loot ===
{{see also|Tutorials/Egg farming}}
A [[chicken]] drops an egg item every 5–10 minutes. The theoretical average would be expected at 1 egg every 7.5 minutes, or 0.1333 eggs per minute.

A [[fox]] sometimes spawns holding an egg, which it always drops upon death. Alternatively, a player dropping a food item causes the fox to drop the egg.

=== Chest loot ===
{{LootChestItem|egg}}

== Usage ==

=== Crafting ingredient ===
{{crafting usage}}

=== Combat ===
Players are able to throw eggs and deal knockback to [[mob]]s (but not other players{{only|JE|short=1}}<ref>{{bug|MC-3179|||WAI}}</ref>{{until|JE Combat Tests}}), but no damage is dealt, similar to a [[snowball]]. Likewise, throwing eggs at [[neutral mobs]] provokes them. Eggs can also be fired from [[dispenser]]s and are affected by gravity.

=== Spawning chickens ===
When thrown by a dispenser or by pressing the {{control|use}} button, an egg has a {{fraction|1|8}} (12.5%) chance of spawning a [[chick]]. If this occurs, there is a {{fraction|1|32}} (3.125%) chance of spawning three additional chicks (on average, 1 out of every 256 eggs spawns 4 chicks). In other words, whenever an egg is thrown, there is a {{fraction|31|256}} chance of spawning 1 chick and a {{fraction|1|256}} chance of spawning four chicks.

The expected value of the number of chicks an egg produces is {{fraction|35|256}} or 13.7%. This means that on average, a chick is spawned every 7.3 eggs, a stack of 16 eggs spawns 2.188 chicks, and a full inventory including the hotbar and off-hand (<code>37 * 16 = 592</code> eggs) is expected to spawn approximately 81 chicks.

== Sounds ==
{{Edition|Java}}:<br>
Thrown eggs use the Friendly Creatures sound category for entity-dependent sound events.
{{Sound table
|rowspan=2
|sound=Bow shoot.ogg
|subtitle=Egg flies
|source=player
|description=When an egg is thrown
|id=entity.egg.throw
|translationkey=subtitles.entity.egg.throw
|volume=0.5
|pitch={{frac|1|3}}-0.5
|distance=16}}
{{Sound table
|subtitle=Dispensed item
|source=block
|description=When a dispenser shoots an egg
|id=block.dispenser.launch
|translationkey=subtitles.block.dispenser.dispense
|volume=1.0
|pitch=1.2
|distance=16}}
{{Sound table
|sound=Chicken plop.ogg
|subtitle=Chicken plops
|source=Friendly Creatures
|description=When an egg is laid by a chicken
|id=entity.chicken.egg
|translationkey=subtitles.entity.chicken.egg
|volume=1.0
|pitch=0.8-1.2
|distance=16
|foot=1}}

{{Edition|Bedrock}}:
{{Sound table
|type=bedrock
|rowspan=2
|sound=Bow shoot.ogg
|source=player
|description=When an egg is thrown
|id=random.bow
|volume=0.5
|pitch=0.33-0.5}}
{{Sound table
|source=player
|description=When a dispenser shoots an egg
|id=random.bow
|volume=1.0
|pitch=0.83-1.25}}
{{Sound table
|sound=Chicken plop.ogg
|source=neutral
|description=When an egg is laid by a chicken
|id=mob.chicken.plop
|volume=1.0
|pitch=0.8-1.2
|foot=1}}

== Data values ==
=== ID ===
{{edition|java}}:
{{ID table
|edition=java
|showforms=y
|generatetranslationkeys=y
|displayname=Egg
|spritetype=item
|nameid=egg
|form=item
|foot=1}}
{{ID table
|edition=java
|showentitytags=y
|generatetranslationkeys=y
|displayname=Thrown Egg
|spritetype=entity
|spritename=Egg
|nameid=egg
|entitytags=impact_projectiles
|foot=1}}
{{edition|bedrock}}:
{{ID table
|edition=bedrock
|shownumericids=y
|showforms=y
|notshowbeitemforms=y
|generatetranslationkeys=y
|displayname=Egg
|spritetype=item
|nameid=egg
|id=390
|form=item
|foot=1}} 
{{ID table
|edition=bedrock
|shownumericids=y
|generatetranslationkeys=y
|displayname=Egg
|spritetype=entity
|nameid=egg
|id=82
|foot=1}}

=== Entity Data ===

Thrown eggs have entity data that define various properties of the entity.

{{el|java}}:
{{main|Entity format}}
{{/ED}}

{{el|bedrock}}:
: See [[Bedrock Edition level format/Entity format]].

== Achievements ==
{{load achievements|The Lie}}

==Advancements==
{{Load advancements|Bullseye}}

== Video ==
<div style="text-align:center">{{yt|8rDbF8UYuTc}}</div>

== History ==
{{History|java alpha}}
{{History||v1.0.14|[[File:Egg JE1 BE1.png|32px]] Added eggs.
|Eggs currently have no purpose.}}
{{History|java beta}}
{{History||1.0|Eggs are now throwable at the request of a fan as the result of a [[wikipedia:Twitter|Twitter]] conversation about a man eating his [[wikipedia:USB|USB]], if [[Notch]] added egg throwing.<ref>{{tweet|notch|11773078791000065}}</ref>}}
{{History||1.2|Eggs are now used to craft [[cake]]s.
|Eggs can now be thrown by [[dispenser]]s.}}
{{History|java}}
{{History||1.0.0|snap=Beta 1.9 Prerelease 2|[[Breeding]] has been added, making eggs easier to obtain.}}
{{History|||snap=RC1|Thrown eggs now hatch chicks instead of adult chickens.
|The egg's throw [[sound]] has been changed.}}
{{History||1.4.2|snap=12w37a|Eggs are now used to craft [[pumpkin pie]]s.}}
{{History||1.9|snap=15w32a|Eggs no longer [[damage]] the [[ender dragon]].}}
{{History|||snap=15w36b|Eggs now produce particles when thrown at an entity.}}
{{History|||snap=15w49a|Eggs, like all throwable projectiles, now take the thrower's motion into account when fired.}}
{{History||1.11|snap=16w32a|The [[entity]] ID has now been changed from <code>ThrownEgg</code> to <code>egg</code>.}}
{{History||1.13|snap=17w47a|Prior to [[1.13/Flattening|''The Flattening'']], this [[item]]'s numeral ID was 344.}}
{{History||1.14|snap=18w43a|[[File:Egg JE2 BE2.png|32px]] The texture of eggs has been changed.}}
{{History|||snap=18w50a|Eggs can now be found in [[chest]]s in [[village]] fletcher houses.
|Therefore, chickens are no longer the only source of eggs.}}
{{History|||snap=19w07a|Added [[fox]]es, which sometimes spawn with eggs in their mouths.}}
{{History||1.16.2|snap=Pre-Release 1|Eggs are now affected by [[bubble column]]s.}}

{{History|pocket alpha}}
{{History||v0.4.0|[[File:Egg JE1 BE1.png|32px]] Added eggs. They are currently unobtainable.
|Eggs are throwable, but are unable to spawn chickens.}}
{{History||v0.7.0|[[Chicken]]s now occasionally lay eggs.
|Eggs can be used to craft [[cake]].
|Thrown eggs now have a chance of spawning adult chickens.}}
{{History||v0.8.0|snap=build 1|Eggs are now used to craft [[pumpkin pie]]s.}}
{{History|||snap=build 3|Thrown eggs now have a chance of spawning chicks instead of adult chickens.}}
{{History|pocket}}
{{History||1.1.0|snap=alpha 1.1.0.0|The [[entity]] ID has now been changed from <code>thrownegg</code> to <code>egg</code>.}}
{{History|bedrock}}
{{History||1.2.0|Eggs now deal knockback to [[player]]s.}}
{{History||1.10.0|snap=beta 1.10.0.3|[[File:Egg.png|32px]] The texture of eggs has been changed.}}
{{History||1.11.0|snap=beta 1.11.0.1|Eggs can now be found in [[village]] fletcher [[chest]]s.}}
{{History|||snap=beta 1.11.0.4|Eggs can now be [[trading|sold]] to farmer [[villager]]s.}}
{{History||1.13.0|snap=beta 1.13.0.1|Added [[fox]]es, which can [[drops|drop]] eggs.}}
{{History||1.16.0|snap=beta 1.16.0.57|[[Trading]] has now been changed, eggs can no longer be [[trading|sold]] to farmer [[villager]]s.}}

{{History|console}}
{{History||xbox=TU1|xbone=CU1|ps=1.0|wiiu=Patch 1|[[File:Egg JE1 BE1.png|32px]] Added eggs.}}
{{History|PS4}}		
{{History||1.90|[[File:Egg JE2 BE2.png|32px]] The texture of eggs has been changed.}}

{{History|New 3DS}}
{{History||0.1.0|[[File:Egg JE1 BE1.png|32px]] Added eggs.}}
{{History|foot}}

== Issues ==
{{issue list}}

== Trivia ==
* Eggs break mid-fall if hit by another projectile; the chance of spawning a chick is not affected.
* Throwing an egg at a [[nether portal]] breaks the egg when it hits the portal.
* A thrown egg faces toward the [[player]] in first-person view, while it appears rotated horizontally in third-person view. This is the case for all throwable [[item]]s ([[ender pearl]]s, eggs, [[snowball]]s, and all throwable [[potion]]s).

== References ==
{{Reflist}}

{{Items}}
{{entities}}

[[Category:Combat]]

[[cs:Vajíčko]]
[[de:Ei]]
[[es:Huevo]]
[[fr:Œuf]]
[[hu:Tojás]]
[[it:Uovo]]
[[ja:卵]]
[[ko:달걀]]
[[nl:Ei]]
[[pl:Jajko]]
[[pt:Ovo]]
[[ru:Яйцо]]
[[th:ไข่ไก่]]
[[uk:Яйце]]
[[zh:鸡蛋]]
<br /></li></ul>
17w43aCustom functions have been moved into data packs.
17w45aFunctions are now completely parsed and cached on load.
17w49bFunction can now be tagged.
Functions tagged in minecraft:tick now run every tick in the beginning of the tick.

Issues

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

References

Advertisement