classSource
public class RegionFile
    implements Closeable

Reads Anvil region files (.mca) Format: 8192-byte header followed by chunk payloads, each compressed individually

Implemented interfaces
Closeable, AutoCloseable

Methods

public void close() throws IOException
public static RegionFile create(File file) throws IOException
Creates a new, empty region file (a zeroed 8192-byte header, no chunks) and opens it. Use this instead of open() if the .mca file doesn't exist yet, e.g. the first time a chunk is written to a region that was not yet generated
Parameters
fileFile
Returns
RegionFile
Throws
IOException
public boolean hasChunk(int chunkX, int chunkZ)
Parameters
chunkXint
chunkZint
Returns
boolean
public static RegionFile open(File file) throws IOException
Parameters
fileFile
Returns
RegionFile
Throws
IOException
public NbtCompound readChunk(int chunkX, int chunkZ) throws IOException
Parameters
chunkXint
chunkZint
Returns
NbtCompound
Throws
IOException
public void writeChunk(int chunkX, int chunkZ, NbtCompound chunkData) throws IOException
Writes and serializes NBT data of the chunk into this region file, at the specified sector position, for the provided chunk coordinates. If the data is still able to fit in the chunk's previous sectors, then these sectors are reused. Otherwise, sectors are appended to the end of the file. Unused sectors, if the chunk is shrunk in size, remain in the file. (Vanilla Minecraft behavior, defragmentation is not implemented.) Data is always written with Zlib compression, even if the original chunk was read with different compression. Updates header fields with location and timestamp.
Parameters
chunkXint
chunkZint
chunkDataNbtCompound
Throws
IOExceptionIf the serialized+compressed chunk needs more than 255 sectors (~1MB compressed), the region file format's own hard limit