RegionFile

class RegionFile @JvmOverloads() constructor(dataSource: DataSource, regionX: Int, regionZ: Int, minY: Int, maxY: Int) : Closeable

Constructs a Region linked to the given file. Will initialize file contents if the file is not big enough. That means it is valid to pass a newly created and empty file to this constructor, and RegionFile will start filling it.

The RandomAccessFile is ALWAYS sought to the beginning of the file during construction.

Code based on Mojang source codealso based on the Minecraft Wiki "Region File format page"

Constructors

RegionFile
Link copied to clipboard
fun RegionFile(file: RandomAccessFile, regionX: Int, regionZ: Int, minY: Int = VanillaMinY, maxY: Int = VanillaMaxY)
RegionFile
Link copied to clipboard
fun RegionFile(dataSource: DataSource, regionX: Int, regionZ: Int, minY: Int = VanillaMinY, maxY: Int = VanillaMaxY)

Types

Companion
Link copied to clipboard
object Companion

Functions

close
Link copied to clipboard
open override fun close()
Closes the given RandomAccessFile, and clears the column cache at the same time.
flushCachedChunks
Link copied to clipboard
fun flushCachedChunks()
Writes all cached chunks to the disk, empties the cache.
forget
Link copied to clipboard
fun forget(column: ChunkColumn)
Unloads from memory the given column.
getBiome
Link copied to clipboard
fun getBiome(x: Int, y: Int, z: Int): String
Returns the biome present at the given position.
getBlockState
Link copied to clipboard
fun getBlockState(x: Int, y: Int, z: Int): BlockState
Returns the block state present at the given position.
getChunk
Link copied to clipboard
fun getChunk(x: Int, z: Int): ChunkColumn?
Gets the chunk inside this RegionFile.
getChunkData
Link copied to clipboard
fun getChunkData(x: Int, z: Int): NBTCompound?
Gets the NBT representation of the chunk inside this RegionFile.
getOrCreateChunk
Link copied to clipboard
fun getOrCreateChunk(x: Int, z: Int): ChunkColumn
Gets the chunk inside this RegionFile.
hasChunk
Link copied to clipboard
fun hasChunk(x: Int, z: Int): Boolean
Does this file contain the given chunk column?
hasLoadedChunk
Link copied to clipboard
fun hasLoadedChunk(x: Int, z: Int): Boolean
Does this region contain the given chunk column?
setBiome
Link copied to clipboard
fun setBiome(x: Int, y: Int, z: Int, biomeID: String)
Sets the biome at the given position.
setBlockState
Link copied to clipboard
fun setBlockState(x: Int, y: Int, z: Int, blockState: BlockState)
Sets the block state at the given position.
writeColumn
Link copied to clipboard
fun writeColumn(column: ChunkColumn, version: SupportedVersion = SupportedVersion.Latest)
Writes a column to the file.

Properties

dataSource
Link copied to clipboard
val dataSource: DataSource
logicalHeight
Link copied to clipboard
val logicalHeight: Int
maxY
Link copied to clipboard
val maxY: Int
minY
Link copied to clipboard
val minY: Int
regionX
Link copied to clipboard
val regionX: Int
regionZ
Link copied to clipboard
val regionZ: Int