region

package
v0.0.0-...-c10fe95 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSector             = errors.New("sector does not exist")
	ErrNoData               = errors.New("data is missing")
	ErrSectorNegativeLength = errors.New("declared length of data is negative")
	ErrTooLarge             = errors.New("data too large")
)

Functions

func At

func At(cx, cz int) (int, int)

At calculate the region's coordinates where the chunk in 计算chunk在哪一个region中

func In

func In(cx, cz int) (int, int)

In calculate chunk's coordinates relative to region 计算chunk在region中的相对坐标。即,除以32并取余。

Types

type Region

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

Region contain 32*32 chunks in one .mca file

func Create

func Create(name string) (*Region, error)

Create open .mca file with os.O_CREATE|os. O_EXCL, and init the region

func CreateWriter

func CreateWriter(f io.ReadWriteSeeker) (r *Region, err error)

CreateWriter create Region by an io.ReadWriteSeeker

func Load

func Load(f io.ReadWriteSeeker) (r *Region, err error)

Load works like Open but read from an io.ReadWriteSeeker.

func Open

func Open(name string) (r *Region, err error)

Open a .mca file and read the head. Close the Region after used.

func (*Region) Close

func (r *Region) Close() error

Close the region file if possible. The responsibility for Close the file with who Open it. If you made the Region with Load(), this method close the file only if your io.ReadWriteSeeker implement io.Close

func (*Region) ExistSector

func (r *Region) ExistSector(x, z int) bool

ExistSector return if a sector is existed

func (*Region) PadToFullSector

func (r *Region) PadToFullSector() error

PadToFullSector writes zeros to the end of the file to make size a multiple of 4096 Legacy versions of Minecraft require this Need to be called right before Close

func (*Region) ReadSector

func (r *Region) ReadSector(x, z int) (data []byte, err error)

ReadSector find and read the Chunk data from region

func (*Region) WriteSector

func (r *Region) WriteSector(x, z int, data []byte) error

WriteSector write Chunk data into region file

Jump to

Keyboard shortcuts

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