Editing
Server level.dat
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== General information == The file is compressed using [[Wikipedia:Gzip|gzip]] to save space (as the files can end up being reasonably large due to everything, even [[air]] being considered a [[block]]). ''(Note: in this example, a default server_level.dat is being used, with the size of 256Γ256Γ64. Level files with bigger dimensions may differ in the amount of bytes.)'' The server level.dat file is where the ''Minecraft'' [[Server]] dumps the level information for permanent storage. As this file is primarily raw level data, it can be quite large: a regular 256Γ256Γ64 sized level is 4 megabytes in size. The file is compressed using gzip, however. Most of the block values are 0 (empty space), so, therefore, the size is reduced considerably by the compression, usually down to a few hundred kilobytes. After un-gzipping the datafile (the [[player]] may simply decompress the file itself using a tool, which can decompress gzipped files), sequentially the datafile consists of the number 656127880 as 32-bit integer (0x27 0x1B 0xB7 0x88 in HEX), followed by the number 2 as a byte (0x02 in HEX), then followed by serialized Level Java classfile instance. The level's block values (material type, such as stone) are stored inside of a byte array inside of this class. The first 65536 sequential bytes of the array make up the top-most 256Γ256 "sliver" of the level, with the north-most row of bytes, from left to right, being at locations 0 ... 255, the row below that at, from left to right, locations 256 ... 511, and so on. The default maps are 64 "slivers" deep. === File format === When uncompressed, the format of the file is as follows: {| border="1" class="wikitable" data-description="File format" ! Position ! Size (bytes) ! Name ! Description |- | 0 | 4 | Magic ID | A magic ID is a constant number used to identify the Minecraft file format. The current value is '''0x271bb788'''. |- | 4 | 1 | Version Number | The version number represents the current format used to save the level. The current value is '''2'''. |- | 5 | Variable | Serialized Java ''com.mojang.minecraft.level.Level'' Class | More information about the serialization format used by Java is available in the [http://java.sun.com/developer/technicalArticles/Programming/serialization/ manual], however, the easiest way to edit the file is to use the [[Development resources/Example Minecraft Classic Level Editing Class|classes]] already provided with the official <span class="plainlinks">[http://minecraft.net/servers.jsp minecraft-server.jar file]</span>. |} === Accessing the array of bytes === One generally has two options for accessing the byte array of blocks: The [[player]] could deserialize the compressed .dat file directly back into an instance of a Level object inside of Java, thus having access to the instance of the Level object in exactly the same way the Minecraft Server does. This would allow the player to set the blocks, dimensions, spawn point and other aspects of the map directly by calling the methods on the instantiated Level object. Manual decompression is not needed before loading, because Java can compress and decompress gzipped files on the fly. To load the datafile back into an instance of the Level class, the player would need the class definition for the Level class. This is included with the minecraft-server.jar file. An example of this can be seen in the [[Development resources/Example Minecraft Classic Level Editing Class]]. Others have read and modified the map's data by simply accessing the raw byte array in the datafile file. To do this, the player would decompress it, make changes to the bytes where the byte array is stored, and then compress it again. Since the player is editing it raw, the player must keep the first 344 (14E in HEX) bytes intact. The next 256Γ256Γ64 bytes are where the byte array is stored. Additionally, it is also possible to alter the spawn location coordinates this way if the player knows where to look: there are 3 integer values starting at byte 284 and thus overwriting the next 12 bytes (3 integers) allow the player to change the spawn location. {{Java Edition}} [[Category:Server]] [[pt:server level.dat]] [[zh:server level.dat]]
Summary:
Please note that all contributions to Kiiw may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Kiiw:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information