world

package
v0.0.0-...-05212bf Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrChunkNotExist sentinel = "chunk does not exist"
	// ErrChunkNotGenerated indicates that the requested chunk has not been generated yet.
	ErrChunkNotGenerated sentinel = "chunk not generated"
)

Variables

View Source
var (
	Decompressor = [4]func(io.Reader) (io.Reader, error){
		func(_ io.Reader) (io.Reader, error) {
			return nil, fmt.Errorf("unknown compression 0x00")
		},
		func(in io.Reader) (io.Reader, error) {
			return gzip.NewReader(in)
		},
		func(in io.Reader) (io.Reader, error) {
			return zlib.NewReader(in)
		},
		func(in io.Reader) (io.Reader, error) {
			return in, nil
		},
	}
)

Functions

func ChunkHeightmap

func ChunkHeightmap(ch Chunk) []int64

Types

type CarvingMasks

type CarvingMasks struct {
	Air    []int8
	Liquid []int8
}

type Chunk

type Chunk interface {
	Pos() voxel.V2

	BlockAt(voxel.V3) block.Block
	SetBlockAt(voxel.V3, block.Block)
}

type CompressionType

type CompressionType byte
const (
	CompressionGZip         CompressionType = iota + 1 // GZip
	CompressionZlib                                    // Zlib
	CompressionUncompressed                            // uncompressed
)

func (CompressionType) String

func (i CompressionType) String() string

type Heightmapper

type Heightmapper interface {
	Chunk
	MotionBlocking() []int64
}

type Heightmaps

type Heightmaps struct {
	MotionBlocking         []int64
	MotionBlockingNoLeaves []int64
	OceanFloor             []int64
	OceanFloorWG           []int64
	WorldSurface           []int64
	WorldSurfaceWG         []int64
}

func (Heightmaps) ToNBT

func (h Heightmaps) ToNBT() nbt.Tag

type Section

type Section interface {
	Palette() []block.Block
	Blocks() [16 * 16 * 16]int16
}

Section is a 16x16x16 cube, which is part of a chunk. A chunk consists of multiple sections, where the actual block data is stored.

func ChunkSection

func ChunkSection(ch Chunk, sec int) Section

ChunkSection returns the section with the given section index from the given chunk. The section index is zero based, where 0 stands for the section from y=0 to y=15. A section index of -1 is not supported. If the given chunk implements the Sectioner interface, it will be used to extract the respective section. If not, the computation will be most expensive and will not be cached.

type Sectioner

type Sectioner interface {
	Chunk
	Sections() []Section
}

type Status

type Status string
const (
	StatusEmpty               Status = "empty"
	StatusStructureStarts     Status = "structure_starts"
	StatusStructureReferences Status = "structure_references"
	StatusBiomes              Status = "biomes"
	StatusNoise               Status = "noise"
	StatusSurface             Status = "surface"
	StatusCarvers             Status = "carvers"
	StatusLiquidCarvers       Status = "liquid_carvers"
	StatusFeatures            Status = "features"
	StatusLight               Status = "light"
	StatusSpawn               Status = "spawn"
	StatusHeightmaps          Status = "heightmaps"
	StatusFull                Status = "full"
)

type TileTick

type TileTick struct {
	ID                   id.ID
	TicksUntilProcessing int
	Priority             int
	Pos                  *voxel.V3
}

type World

type World interface {
	// Chunk returns and if necessary also loads the chunk on the
	// given voxel.
	Chunk(voxel.V2) (Chunk, error)
	// IsChunkLoaded determines whether the chunk on the given
	// voxel is already loaded.
	IsChunkLoaded(voxel.V2) bool
	// Unload unloads the chunk on the given voxel. If there is
	// no such chunk loaded, this is a no-op.
	Unload(voxel.V2)

	Seed() int64
}

func LoadVanilla

func LoadVanilla(fs afero.Fs) (World, error)

Jump to

Keyboard shortcuts

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