minecraft.wiki-mirror/wiki_backup/Anvil file format.txt
2024-12-24 06:17:34 -05:00

72 lines
5.5 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{for|the block|Anvil}}
{{exclusive|java}}
{{Merge|Region file format|reason=The apparent differences are in the chunk format, not the binary file itself.|discussPage=Talk:Region file format|discussAnchor=Merging with Anvil file format}}
'''Anvil'''<ref name="Anvil">https://web.archive.org/web/20120302221152/https://www.mojang.com/2012/02/new-minecraft-map-format-anvil/</ref> is a file storage format. It brings a list of changes and improvements over from the previous file format, [[Region file format|Region]]. It was implemented in snapshot [[12w07a]] for release in [[Java Edition 1.2.1]].
== Changes from MCRegion ==
[[File:Anvil Conversion.png|200px|thumb|right|Converting a world from [[MCRegion]] format to Anvil.]]
The only changes from MCRegion to Anvil were in the [[Chunk format]]; the [[Region file format]] is still used, but labeled as Anvil. The Anvil format introduced these changes to the Chunk format:
* Maximum build height has been increased to 256 (from 128).
* Empty sections of the world are not loaded into memory or saved to disk.
* The maximum Block ID has been increased to 4096 (was 256) by adding a 4-bit data layer (similar to how metadata is stored). The rest of Minecraft's code was not prepared to take advantage of this, however mods made use of this.
* Block ordering has been changed from XZY to YZX in order to improve compression.
* Packets for sending [[chunks]] have been optimized (a chunk without [[air]] is smaller than in the same chunk in the old format, and a chunk with lots of air is even smaller).
* [[Biome]]s are saved per X,Z column, rather than being calculated on the fly, which means they can be altered by tools; this is useful for [[Programs and editors/Mapping|map makers]]. It also prevents issues where features within previously generated chunks don't match the biome after the way biomes generate change, usually due to updates or mods. (Also known as "Biome shifting")
=== Further information ===
Versions from [[Java Edition 12w07a|12w07a]] to [[Java Edition 1.17.1|1.17.1]] automatically convert worlds to the new format, but a copy of the world files is created in the previous formats for compatibility with older game versions. Previously generated chunks have not been changed, so there is an additional 128 blocks of air above existing terrain, making 192 blocks from sea level to the height limit.
* The 16×128×16 "Blocks", "Data", "SkyLight" and "BlockLight" tags were moved and repurposed. (see below)
* A "Sections" List tag containing Compound tags has been added with up to 16 Compound tags.
* Each section has 16×16×16 "Blocks", "Data", "SkyLight" and "BlockLight" tags.
* Each section has a "Y" Byte tag saying which section it is (note that some Y positions can be skipped). 0 is at the bottom of the world and 15 is the topmost section.
* Each section also has an optional "Add" tag, which is a DataLayer byte array just like "Data". The "Add" tag is not included in the converter since the old format never had block ids above 255. This extra tag is created whenever a block requires it, so the {{code|getTile()}} method needs to check if the array exists and then combine it with the default block data. In other words, {{code|blockId {{=}} (add << 8) + baseId}}.
* Each chunk has a 16×16 byte array with [[Java Edition data values/Pre-flattening#Biome IDs|biome IDs]] called "Biomes". If this array is missing it is filled when the game starts, as well any -1 values in the array. The converter source provided for developers doesn't include any biome sources, however.
* Note that the old format is XZY ({{code|(x * 16 + z) * 128 + y}}) and the new format is YZX ({{code|(y * 16 + z) * 16 + x}}) (see the difference between DataLayer and OldDataLayer).
* The new format uses the extension ".mca" instead of ".mcr" (the old format is kept for safety, with the level.dat backed up as "level.dat_mcr").
* A new NBT tag type called IntArray was added to the [[NBT Format]] (With ID 11) and is used by the "Heightmap" tag.
Additional information may be found on the [[Chunk format]] page.
== World size reduction post-conversion ==
Anvil world data uses a <code>.mca</code> file extension, while McRegion uses <code>.mcr</code>. The game leaves the old McRegion files after converting a world to Anvil, despite the game never using them again. To reduce the file size of backups, the old McRegion files may be deleted. To do this, perform the following steps:
* Windows:
*# Open the command prompt (press {{key|win}} and {{key|R}} together, type {{kbd|cmd}}, and press {{key|Enter}})
*# Run the following command: {{kbd|del /f /q "[path to world folder]\region\*.mcr"}}
* Linux and macOS:
*# Open the terminal
*# Run the following command: {{kbd|rm -f "[path to world folder]"/region/*.mcr}}
== History ==
{{HistoryTable
|{{HistoryLine|java}}
|{{HistoryLine||1.2.1|dev=12w07a|Added the Anvil File Format.}}
|{{HistoryLine||1.16|dev=20w14a|Files in this format are now opened in synchronous mode to prevent data loss and corruption after crash.}}
|{{HistoryLine||1.20.5|dev=24w04a|Added [[wikipedia:LZ4_(compression_algorithm)|lz4]] compression option that can be enabled in [[server.properties]].}}
}}
== See also ==
*[[Java Edition level format]]
*[[Chunk format]]
*[[Region file format]]
== References ==
{{Reflist}}
== Navigation ==
{{Navbox Java Edition technical|general}}
[[Category:Development]]
[[de:Spielstand-Speicherung/Anvil Format]]
[[es:Formato de archivo Anvil]]
[[fr:Anvil]]
[[ja:Anvilファイルフォーマット]]
[[nl:Anvil bestandsformaat]]
[[pt:Anvil (formato de arquivo)]]
[[ru:Anvil (формат карт)]]
[[zh:Anvil文件格式]]