https://wiki.vg/api.php?action=feedcontributions&user=Frogstair&feedformat=atomwiki.vg - User contributions [en]2024-03-28T21:17:02ZUser contributionsMediaWiki 1.34.4https://wiki.vg/index.php?title=Map_Format&diff=17331Map Format2022-02-08T12:48:09Z<p>Frogstair: Add warning that article may be outdated</p>
<hr />
<div>This page covers the world information as of 1.2.5 to the present. See [[Alpha Map Format]] for Alpha information.<br />
<br />
<!--Page may be outdated, since new versions changed how the world is generated--><br />
<br />
{{Box<br />
|BORDER = #BF880D<br />
|BACKGROUND = #F7B217<br />
|WIDTH = 100%<br />
|ICON = <br />
|HEADING = Heads up!<br />
|CONTENT = Some information in this article may be outdated due to the new world generation introduced in the 1.17 update.<br />
}}<br />
<br />
==General Information==<br />
Worlds are represented as a series of regions, within which are a number of columns, and chunks. Each region is 32x1x32 columns, each column is 1x16x1 chunks, and each chunk is 16x16x16 blocks. The overall block height of a column is 256. Each chunk stores four (or five) things - block IDs (8-bit), block metadata (4-bit), block light (4-bit), and sky light (4-bit). The optional fifth value is "add" data, which is four bits to be added to block IDs for additional block ID support (not used in vanilla Minecraft). Block light is light cast by things like torches and glowstone, and is calculated with a 3D [http://en.wikipedia.org/wiki/Flood_fill Flood Fill] algorithm. Sky light is the light cast by the sky, and is calculated by starting at the top and working your way down. As you pass through semi-transparent blocks, you decrease the lighting value until you hit an opaque block. The opaque block is the last block whose skylight has a nonzero value. Lighting starts at 0xF (brightest) and works down to 0x0 (dimmest). Columns store biome information. Each 1x256x1 cuboid of blocks has the same biome value, for a total of 256 possible biome values per chunk (16x16). Biome values are stored as bytes.<br />
<br />
===Biome Values===<br />
<br />
{| class="wikitable"<br />
|-<br />
! Name<br />
! Value<br />
|-<br />
| Ocean<br />
| 0<br />
|-<br />
| Plains<br />
| 1<br />
|-<br />
| Desert<br />
| 2<br />
|-<br />
| Extreme Hills<br />
| 3<br />
|-<br />
| Forest<br />
| 4<br />
|-<br />
| Taiga<br />
| 5<br />
|-<br />
| Swampland<br />
| 6<br />
|-<br />
| River<br />
| 7<br />
|-<br />
| Hell<br />
| 8<br />
|-<br />
| Sky<br />
| 9<br />
|-<br />
| Frozen Ocean<br />
| 10<br />
|-<br />
| Frozen River<br />
| 11<br />
|-<br />
| Ice Plains<br />
| 12<br />
|-<br />
| Ice Mountains<br />
| 13<br />
|-<br />
| Mushroom Island<br />
| 14<br />
|-<br />
| Mushroom Island Shore<br />
| 15<br />
|-<br />
| Beach<br />
| 16<br />
|-<br />
| Desert Hills<br />
| 17<br />
|-<br />
| Forest Hills<br />
| 18<br />
|-<br />
| Taiga Hills<br />
| 19<br />
|-<br />
| Extreme Hills Edge<br />
| 20<br />
|-<br />
| Jungle<br />
| 21<br />
|-<br />
| Jungle Hills<br />
| 22<br />
|}<br />
<br />
==Storage==<br />
<br />
This section documents the Anvil format for servers.<br />
<br />
Maps are stored as a specific directory structure with several [[NBT]] files within. For the sake of examples, the world we'll be working with is stored in a folder called "/world".<br />
<br />
===Directory Structure===<br />
<br />
* /world/data: Unused<br />
* /world/DIM-1: Nether world<br />
* /world/DIM-1/region: Nether world regions<br />
* /world/DIM1: End world<br />
* /world/DIM1/region: End world regions<br />
* /world/players: Player data<br />
* /world/region: Overworld regions<br />
<br />
===level.dat===<br />
<br />
In the root directory is a level.dat file. The structure of that file is this:<br />
<br />
* NBTCompound(Data)<br />
** NBTByte(hardcore)<br />
** NBTByte(MapFeatures): Set to 1 if structures are generated, such as villages<br />
** NBTByte(raining): Set to 1 if currently raining<br />
** NBTByte(thundering): Set to 1 if currently thundering (only if there is potential for thunder, not if a thunderbolt is currently in progress)<br />
** NBTInt(GameType)<br />
** NBTInt(generatorVersion): 0 for 1.2.5<br />
** NBTInt(rainTime): The ticks remaining until rain stops?<br />
** NBTInt(SpawnX)<br />
** NBTInt(SpawnY)<br />
** NBTInt(SpawnZ)<br />
** NBTInt(thunderTime)<br />
** NBTInt(version): 19133 for 1.2.5<br />
** NBTLong(LastPlayed)<br />
** NBTLong(RandomSeed)<br />
** NBTLong(SizeOnDisk): Always 0 for 1.2.5<br />
** NBTLong(Time)<br />
** NBTString(generatorName)<br />
** NBTString(LevelName)<br />
<br />
===[playeruuid].dat===<br />
<br />
Each player that has ever connected is given a [playeruuid].dat file.<br />
<br />
* NBTCompound<br />
** NBTByte(OnGround)<br />
** NBTByte(Sleeping)<br />
** NBTShort(Air)<br />
** NBTShort(AttackTime)<br />
** NBTShort(DeathTime)<br />
** NBTShort(Fire): Ticks until the player is no longer on fire, or zero<br />
** NBTShort(Health)<br />
** NBTShort(HurtTime)<br />
** NBTShort(SleepTimer)<br />
** NBTInt(Dimension)<br />
** NBTInt(foodLevel)<br />
** NBTInt(foodTickTimer)<br />
** NBTInt(playerGameType)<br />
** NBTInt(XpLevel)<br />
** NBTInt(XpTotal)<br />
** NBTFloat(FallDistance)<br />
** NBTFloat(foodExhastionLevel)<br />
** NBTFloat(foodSaturationLevel)<br />
** NBTFloat(XpP)<br />
** NBTCompound(Inventory)<br />
*** NBTCompound<br />
**** NBTByte(Count)<br />
**** NBTByte(Slot)<br />
**** NBTShort(Damage): Damage -or- metadata<br />
**** NBTShort(id)<br />
** NBTList(Motion)<br />
*** NBTDouble<br />
*** NBTDouble<br />
*** NBTDouble<br />
** NBTList(Pos)<br />
*** NBTDouble<br />
*** NBTDouble<br />
*** NBTDouble<br />
** NBTList(Rotation)<br />
*** NBTFloat<br />
*** NBTFloat<br />
<br />
===[region].mca===<br />
<br />
Each region file is named "r.x.z.mca", where x and z are the coordinates. These coordinates are relative to each region. Given chunk column coordinates, divide them by 32 to get the region coordinates. [https://wiki.vg/Region_Files Region files] are not raw NBT files and must therefore be parsed differently see [https://wiki.vg/Region_Files Region files].<br />
Every generated chunk has a 5-byte header with the first four bytes as the length of the compressed chunk in bytes and the fifth byte as the compression scheme.<br />
<br />
{| class="wikitable"<br />
|-<br />
!<br />
!Length of the compressed<br />chunk in bytes<br />
!Compression Scheme<br />
|-<br />
!Decoded<br />
|5033<br />
|zlib<br />
|-<br />
!On Disk(in hex)<br />
| <code>00 13 A9</code><br />
| <code>02</code><br />
|}<br />
<br />
The compression scheme can have two value:<br />
{| class="wikitable"<br />
|-<br />
!Compression<br />Scheme<br />
!Value<br />
|-<br />
|zlib<br />
|<code>2</code><br />
|-<br />
|gzip<br />
|<code>1</code><br />
|}<br />
<br />
The notchian implementation will '''never''' compress with gzip but can read if provided.<br />
<br />
Note: The following example is outdated. It is accurate for (at least) 1.4, but at some point the format has been changed. However, you will still need to support this version if you want reverse compatibility with old save files.<br />
<br />
<pre><br />
TAG_Compound(''): 2 entries<br />
{<br />
TAG_Compound('Level'): 11 entries<br />
{<br />
TAG_List('Entities'): List of entities in the chunk column<br />
{<br />
TAG_Compound(): Each entity has a Tag_Compound<br />
{<br />
...<br />
}<br />
}<br />
TAG_List('Sections'): 5 entries<br />
{<br />
TAG_Compound(''): 5 entries<br />
{<br />
TAG_Byte('Y'): 0<br />
TAG_Byte_Array('BlockLight'): 2048 bytes<br />
TAG_Byte_Array('Blocks'): 4096 bytes<br />
TAG_Byte_Array('Data'): 2048 bytes<br />
TAG_Byte_Array('SkyLight'): 2048 bytes<br />
}<br />
TAG_Compound(''): 5 entries<br />
{<br />
TAG_Byte('Y'): 1<br />
TAG_Byte_Array('BlockLight'): 2048 bytes<br />
TAG_Byte_Array('Blocks'): 4096 bytes<br />
TAG_Byte_Array('Data'): 2048 bytes<br />
TAG_Byte_Array('SkyLight'): 2048 bytes<br />
}<br />
...<br />
}<br />
TAG_List('TileEntities'):<br />
TAG_Long('InhabitedTime'): 16<br />
TAG_Long('LastUpdate'): Last time a block changed in this column<br />
TAG_Byte('LightPopulated'): Is the light calculated<br />
TAG_Byte('TerrainPopulated'): Has the terrain been generated<br />
TAG_Int('xPos'): X position of the region. Each single increment to x is 512 blocks<br />
TAG_Int('zPos'): Z position of the region. Each single increment to z is 512 blocks<br />
TAG_Byte_Array('Biomes'): 256 bytes. Biomes affect blocks in 1x256x1 columns<br />
TAG_Int_Array('HeightMap'): 256 bytes<br />
}<br />
TAG_Int('DataVersion'): 1343<br />
}<br />
</pre><br />
<br />
=== See also ===<br />
[https://wiki.vg/Region_Files Region Files]<br />
[https://minecraft.gamepedia.com/Chunk_format#Tile_entity_format Tile entity format]<br />
[[Category:Minecraft_Modern]]</div>Frogstairhttps://wiki.vg/index.php?title=Protocol_FAQ&diff=16668Protocol FAQ2021-06-07T17:39:08Z<p>Frogstair: fix broken link</p>
<hr />
<div>People very, very often have questions regarding the Minecraft Modern [[Protocol]], so we'll try to address some of the most common ones on this document. If you're still having trouble, join us on IRC, channel [irc://irc.freenode.net/mcdevs #mcdevs on irc.freenode.net].<br />
<br />
== Is the protocol documentation complete? ==<br />
Depending on your definition, ''yes''! All packet types are known and their layout documented. Some finer details are missing, but everything you need to make functional programs is present. We also collect information on the [[pre-release protocol]] changes, allowing us to quickly document new releases.<br />
<br />
== What's the normal login sequence for a client? ==<br />
See [[Authentication]] for communication with Mojang's servers.<br />
<br />
The recommended login sequence looks like this, where '''C''' is the client and '''S''' is the server:<br />
# Client connects to server<br />
# '''C'''→'''S''': [[Protocol#Handshake|Handshake]] State=2<br />
# '''C'''→'''S''': [[Protocol#Login Start|Login Start]]<br />
# '''S'''→'''C''': [[Protocol#Encryption Request|Encryption Request]]<br />
# Client auth<br />
# '''C'''→'''S''': [[Protocol#Encryption Response|Encryption Response]]<br />
# Server auth, both enable encryption<br />
# '''S'''→'''C''': [[Protocol#Set Compression|Set Compression]] (Optional, enables compression)<br />
# '''S'''→'''C''': [[Protocol#Login Success|Login Success]]<br />
# '''S'''→'''C''': [[Protocol#Join Game|Join Game]]<br />
# '''S'''→'''C''': [[Protocol#Plugin Message (clientbound) |Plugin Message]]: [[Plugin channel#minecraft%3Abrand|<code>minecraft:brand</code>]] with the server's brand (Optional)<br />
# '''S'''→'''C''': [[Protocol#Server Difficulty|Server Difficulty]] (Optional)<br />
# '''S'''→'''C''': [[Protocol#Player Abilities (clientbound)|Player Abilities]] (Optional)<br />
# '''C'''→'''S''': [[Protocol#Plugin Message (serverbound)|Plugin Message]]: [[Plugin channel#minecraft%3Abrand|<code>minecraft:brand</code>]] with the client's brand (Optional)<br />
# '''C'''→'''S''': [[Protocol#Client Settings|Client Settings]]<br />
# '''S'''→'''C''': [[Protocol#Held Item Change (clientbound)|Held Item Change]]<br />
# '''S'''→'''C''': [[Protocol#Declare Recipes|Declare Recipes]]<br />
# '''S'''→'''C''': [[Protocol#Tags|Tags]]<br />
# '''S'''→'''C''': [[Protocol#Entity Status|Entity Status]]<br />
# '''S'''→'''C''': [[Protocol#Declare Commands|Declare Commands]]<br />
# '''S'''→'''C''': [[Protocol#Unlock Recipes|Unlock Recipes]]<br />
# '''S'''→'''C''': [[Protocol#Player Position And Look (clientbound)|Player Position And Look]]<br />
# '''S'''→'''C''': [[Protocol#Player Info|Player Info]] (Add Player action)<br />
# '''S'''→'''C''': [[Protocol#Player Info|Player Info]] (Update latency action)<br />
# '''S'''→'''C''': [[Protocol#Update View Position|Update View Position]]<br />
# '''S'''→'''C''': [[Protocol#Update Light|Update Light]] (One sent for each chunk in a square centered on the player's position)<br />
# '''S'''→'''C''': [[Protocol#Chunk Data|Chunk Data]] (One sent for each chunk in a square centered on the player's position)<br />
# '''S'''→'''C''': [[Protocol#World Border|World Border]] (Once the world is finished loading)<br />
# '''S'''→'''C''': [[Protocol#Spawn Position|Spawn Position]] (“home” spawn, not where the client will spawn on login)<br />
# '''S'''→'''C''': [[Protocol#Player Position And Look (clientbound)|Player Position And Look]] (Required, tells the client they're ready to spawn)<br />
# '''C'''→'''S''': [[Protocol#Teleport Confirm|Teleport Confirm]]<br />
# '''C'''→'''S''': [[Protocol#Player Position And Look (serverbound)|Player Position And Look]] (to confirm the spawn position)<br />
# '''C'''→'''S''': [[Protocol#Client Status|Client Status]] (sent either before or while receiving chunks, further testing needed, server handles correctly if not sent)<br />
# '''S'''→'''C''': inventory, entities, etc<br />
<br />
== Offline mode ==<br />
If the server is in offline mode, it will not send the [[Protocol#Encryption Request|Encryption Request]] packet, and likewise, the client should not send [[Protocol#Encryption Response|Encryption Response]]. In this case, encryption is never enabled, and no authentication is performed.<br />
<br />
Clients can tell that a server is in offline mode if the server sends a [[Protocol#Login Success|Login Success]] without sending [[Protocol#Encryption Request|Encryption Request]].<br />
<br />
== I think I've done everything right, but… ==<br />
=== …my player isn't spawning! ===<br />
After sending the common-sense packets ([[Protocol#Handshake|Handshake]], [[Protocol#Login Start|Login Start]], [[Protocol#Window Items|inventory]], [[Protocol#Spawn Position|compass]], and [[Protocol#Chunk Data|chunks]]), you need to finally send the player their [[Protocol#Player Position And Look|initial position]] for them to leave the “Loading Map” screen.<br />
<br />
''Note that if the following steps are taken, a Minecraft client will spawn the player:''<br />
# Do Handshake (see [[Protocol Encryption]])<br />
# Send [[Protocol#Spawn Position|Spawn Position]] packet<br />
# Send [[Protocol#Player Position And Look (clientbound)|Player Position And Look (clientbound)]] packet<br />
<br />
While the above steps are sufficient for Minecraft 1.4.5, it is good form to send packets that inform the client about the world around the player before allowing the player to spawn.<br />
<br />
=== …my client isn't receiving complete map chunks! ===<br />
''Main article: [[How to Write a Client]]''<br />
<br />
The standard Minecraft server sends full chunks only when your client is sending player status update packets (any of [[Protocol#Player|Player (0x03)]] through [[Protocol#Player Position And Look|Player Position And Look (0x06)]]).<br />
<br />
=== …all connecting clients spasm and jerk uncontrollably! ===<br />
For newer clients, your server needs to send 49 chunks ahead of time, not just one. Send a 7×7 square of chunks, centered on the connecting client's position, ''before'' spawning them.<br />
<br />
=== …the client is trying to send an invalid packet that begins with 0xFE01 ===<br />
The client is attempting a [[Server_List_Ping#1.6|legacy ping]], this happens if your server did not respond to the [[Server List Ping]] properly, including if it sent malformed JSON.<br />
<br />
=== …the client disconnects after some time with a "Timed out" error ===<br />
The server is expected to send a [[Protocol#Keep Alive (clientbound)|Keep Alive]] packet every second, and the client should respond with the serverbound version of that packet. If either party does not receive keep alives for some period of time, they will disconnect.<br />
<br />
== How do I open/save a command block? ==<br />
The process to actually open the command block window clientside is somewhat complex; the client actually uses the [[Protocol#Update Block Entity|Update Block Entity (0x09)]] packet to open it.<br />
<br />
First, the client must have at least an {{Minecraft Wiki|Server.properties#op-permission-level|OP permission level}} of 2, or else the client will refuse to open the command block. (The op permission level is set with the [[Protocol#Entity Status|Entity Status]] packet)<br />
<br />
To actually open the command block:<br />
<br />
# '''C'''→'''S''': [[Protocol#Player Block Placement|Player Block Placement (0x1C)]], with the position being the command block that was right-clicked.<br />
# '''S'''→'''C''': [[Protocol#Update Block Entity|Update Block Entity (0x09)]], with the NBT of the command block.<br />
<br />
And to save it, use the [[Plugin channels#MC.7CAutoCmd|<code>MC|AutoCmd</code> plugin channel]].<br />
<br />
[[Category:Protocol Details]]<br />
[[Category:Minecraft Modern]]</div>Frogstair