anvil

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DataVersion = 4189

DataVersion for Minecraft 1.21.10

Variables

This section is empty.

Functions

func ChunkToNBT

func ChunkToNBT(chunk *world.Chunk, reg *world.BlockStateRegistry) nbt.Tag

ChunkToNBT converts a world.Chunk into the Anvil NBT compound format.

func NBTToChunk

func NBTToChunk(tag nbt.Tag, reg *world.BlockStateRegistry) (*world.Chunk, error)

NBTToChunk converts Anvil NBT data into a world.Chunk.

Types

type AnvilStorage

type AnvilStorage struct {
	// contains filtered or unexported fields
}

AnvilStorage implements world.Storage using the Anvil region file format. Region files are cached in memory and flushed on Close.

func NewAnvilStorage

func NewAnvilStorage(dir string, reg *world.BlockStateRegistry) (*AnvilStorage, error)

NewAnvilStorage creates an AnvilStorage backed by the given directory. The directory will be created if it does not exist.

func (*AnvilStorage) Close

func (s *AnvilStorage) Close() error

Close closes all open region files.

func (*AnvilStorage) LoadChunk

func (s *AnvilStorage) LoadChunk(pos world.ChunkPos) (*world.Chunk, error)

LoadChunk reads a chunk from the Anvil region files.

func (*AnvilStorage) SaveChunk

func (s *AnvilStorage) SaveChunk(pos world.ChunkPos, chunk *world.Chunk) error

SaveChunk writes a chunk to the Anvil region files.

type RegionFile

type RegionFile struct {
	// contains filtered or unexported fields
}

RegionFile manages a single .mca region file. It provides read/write access to chunks stored in the Anvil format.

func OpenRegion

func OpenRegion(path string) (*RegionFile, error)

OpenRegion opens an existing region file or creates a new one.

func (*RegionFile) Close

func (rf *RegionFile) Close() error

Close closes the underlying file.

func (*RegionFile) HasChunk

func (rf *RegionFile) HasChunk(localX, localZ int) bool

HasChunk reports whether a chunk exists in this region.

func (*RegionFile) ReadChunkNBT

func (rf *RegionFile) ReadChunkNBT(localX, localZ int) (nbt.Tag, error)

ReadChunkNBT reads and decompresses a chunk's NBT data.

func (*RegionFile) WriteChunkNBT

func (rf *RegionFile) WriteChunkNBT(localX, localZ int, tag nbt.Tag) error

WriteChunkNBT compresses and writes chunk NBT data to the region file.

type RegionPos

type RegionPos struct {
	X, Z int32
}

RegionPos identifies a region file by its coordinates.

func RegionPosFromChunk

func RegionPosFromChunk(chunkX, chunkZ int32) RegionPos

RegionPosFromChunk returns the region containing the given chunk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL