polar

package module
v0.0.0-...-868a218 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 5 Imported by: 0

README

Warning This implementation is still a heavy work in progress. It is not ready for use.

go-polar

license

Go implementation of Polar. Polar is a world format designed for simpler and smaller handling of small worlds, particularly for user generated content where size matters.

Polar generally should not be used for large worlds, since it stores worlds in a single file and does not allow random access of chunks (the entire world must be loaded to read chunks). As a general rule of thumb, Polar should only be used for worlds small enough that they are OK being completely kept in memory.

The Polar format is described in detail here

Features

todo k

Install

go get -u github.com/hollow-cube/go-polar

Usage

todo

Comparison to others

todo

Contributing

Contributions via PRs and issues are always welcome.

License

This project is licensed under the MIT License.

Documentation

Index

Constants

View Source
const LatestVersion int16 = 3
View Source
const MagicNumber = 0x506F6C72 // `Polr`

Variables

This section is empty.

Functions

func ChunkPosFromXYZ

func ChunkPosFromXYZ(x, y, z int) int32

func ChunkPosToXYZ

func ChunkPosToXYZ(chunkPos int32) (int, int, int)

func Write

func Write(world *World) ([]byte, error)

Types

type BlockEntity

type BlockEntity struct {
	ChunkPos int32
	ID       string                 // Can be empty string if missing
	Data     map[string]interface{} // NBT data, or nil if not present. todo type here
}

func (*BlockEntity) Pos

func (b *BlockEntity) Pos() (int, int, int)

type Chunk

type Chunk struct {
	X int32
	Z int32

	Sections      []*Section
	BlockEntities []*BlockEntity
}

type ChunkIndex

type ChunkIndex int64

func ChunkIndexFromXZ

func ChunkIndexFromXZ(x, z int) ChunkIndex

func (ChunkIndex) X

func (c ChunkIndex) X() int

func (ChunkIndex) Z

func (c ChunkIndex) Z() int

type Compression

type Compression int8
const (
	CompressionNone Compression = iota
	CompressionZstd
)

type Section

type Section struct {
	BlockPalette []string
	BlockStates  []uint64

	BiomePalette []string
	BiomeStates  []uint64

	BlockLight []byte // 2048 bytes, or nil
	SkyLight   []byte // 2048 bytes, or nil
}

func (*Section) IsEmpty

func (s *Section) IsEmpty() bool

type World

type World struct {
	Version     int16
	Compression Compression

	MinSection int8
	MaxSection int8
	// contains filtered or unexported fields
}

func (*World) GetChunk

func (w *World) GetChunk(x, z int) *Chunk

func (*World) SectionCount

func (w *World) SectionCount() int

func (*World) SetChunk

func (w *World) SetChunk(chunk *Chunk)

Jump to

Keyboard shortcuts

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