chunk

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubChunkVersion = 9

	CurrentBlockVersion int32 = 18040335
)

Variables

View Source
var (
	DiskEncoding diskEncoding

	NetworkEncoding networkEncoding

	BiomePaletteEncoding biomePaletteEncoding
)
View Source
var (
	SkyLight skyLight

	BlockLight blockLight
)

Functions

func EncodeBiomes

func EncodeBiomes(c *Chunk, e Encoding) []byte

func EncodeSubChunk

func EncodeSubChunk(c *Chunk, e Encoding, ind int) []byte

func LightArea

func LightArea(c []*Chunk, baseX, baseZ int) *lightArea

Types

type BlockEntity

type BlockEntity struct {
	Pos  cube.Pos
	Data map[string]any
}

type BlockPaletteEncoding

type BlockPaletteEncoding struct {
	Blocks BlockRegistry
}

func (BlockPaletteEncoding) DecodeBlockState

func (bpe BlockPaletteEncoding) DecodeBlockState(m map[string]any) (uint32, error)

func (BlockPaletteEncoding) EncodeBlockState

func (bpe BlockPaletteEncoding) EncodeBlockState(v uint32) blockEntry

type BlockRegistry

type BlockRegistry interface {
	BlockCount() int

	AirRuntimeID() uint32

	RuntimeIDToState(runtimeID uint32) (name string, properties map[string]any, found bool)

	StateToRuntimeID(name string, properties map[string]any) (runtimeID uint32, found bool)

	FilteringBlock(rid uint32) uint8

	LightBlock(rid uint32) uint8

	RandomTickBlock(rid uint32) bool

	NBTBlock(rid uint32) bool

	LiquidDisplacingBlock(rid uint32) bool

	LiquidBlock(rid uint32) bool

	HashToRuntimeID(hash uint32) (rid uint32, ok bool)

	RuntimeIDToHash(runtimeID uint32) (hash uint32, ok bool)
}

type Chunk

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

func DiskDecode

func DiskDecode(br BlockRegistry, data SerialisedData, r cube.Range) (*Chunk, error)

func NetworkDecode

func NetworkDecode(br BlockRegistry, data []byte, count int, r cube.Range) (*Chunk, error)

func NetworkDecodeBuffer

func NetworkDecodeBuffer(br BlockRegistry, buf *bytes.Buffer, count int, r cube.Range) (*Chunk, error)

func New

func New(br BlockRegistry, r cube.Range) *Chunk

func (*Chunk) Biome

func (chunk *Chunk) Biome(x uint8, y int16, z uint8) uint32

func (*Chunk) Block

func (chunk *Chunk) Block(x uint8, y int16, z uint8, layer uint8) uint32

func (*Chunk) Clone

func (chunk *Chunk) Clone() *Chunk

func (*Chunk) Compact

func (chunk *Chunk) Compact()

func (*Chunk) Equals

func (chunk *Chunk) Equals(c *Chunk) bool

func (*Chunk) HeightMap

func (chunk *Chunk) HeightMap() HeightMap

func (*Chunk) HighestBlock

func (chunk *Chunk) HighestBlock(x, z uint8) int16

func (*Chunk) HighestFilledSubChunk

func (chunk *Chunk) HighestFilledSubChunk() uint16

func (*Chunk) HighestLightBlocker

func (chunk *Chunk) HighestLightBlocker(x, z uint8) int16

func (*Chunk) Light

func (chunk *Chunk) Light(x uint8, y int16, z uint8) uint8

func (*Chunk) Range

func (chunk *Chunk) Range() cube.Range

func (*Chunk) SetBiome

func (chunk *Chunk) SetBiome(x uint8, y int16, z uint8, biome uint32)

func (*Chunk) SetBlock

func (chunk *Chunk) SetBlock(x uint8, y int16, z uint8, layer uint8, block uint32)

func (*Chunk) SkyLight

func (chunk *Chunk) SkyLight(x uint8, y int16, z uint8) uint8

func (*Chunk) Sub

func (chunk *Chunk) Sub() []*SubChunk

func (*Chunk) SubChunk

func (chunk *Chunk) SubChunk(y int16) *SubChunk

func (*Chunk) SubIndex

func (chunk *Chunk) SubIndex(y int16) int16

func (*Chunk) SubY

func (chunk *Chunk) SubY(index int16) int16

type Column

type Column struct {
	Chunk           *Chunk
	Entities        []Entity
	BlockEntities   []BlockEntity
	Tick            int64
	ScheduledBlocks []ScheduledBlockUpdate
}

type Encoding

type Encoding interface {
	// contains filtered or unexported methods
}

type Entity

type Entity struct {
	ID   int64
	Data map[string]any
}

type HeightMap

type HeightMap []int16

func (HeightMap) At

func (h HeightMap) At(x, z uint8) int16

func (HeightMap) HighestNeighbour

func (h HeightMap) HighestNeighbour(x, z uint8) int16

func (HeightMap) Set

func (h HeightMap) Set(x, z uint8, val int16)

type Palette

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

func (*Palette) Add

func (palette *Palette) Add(v uint32) (index int16, resize bool)

func (*Palette) Clone

func (palette *Palette) Clone() *Palette

func (*Palette) Index

func (palette *Palette) Index(runtimeID uint32) int16

func (*Palette) Len

func (palette *Palette) Len() int

func (*Palette) Replace

func (palette *Palette) Replace(f func(v uint32) uint32)

func (*Palette) Value

func (palette *Palette) Value(i uint16) uint32

type PalettedStorage

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

func (*PalettedStorage) At

func (storage *PalettedStorage) At(x, y, z byte) uint32

func (*PalettedStorage) Clone

func (storage *PalettedStorage) Clone() *PalettedStorage

func (*PalettedStorage) Equal

func (storage *PalettedStorage) Equal(other *PalettedStorage) bool

func (*PalettedStorage) Palette

func (storage *PalettedStorage) Palette() *Palette

func (*PalettedStorage) PaletteIndex

func (storage *PalettedStorage) PaletteIndex(x, y, z byte) uint16

func (*PalettedStorage) Set

func (storage *PalettedStorage) Set(x, y, z byte, v uint32)

type ScheduledBlockUpdate

type ScheduledBlockUpdate struct {
	Pos   cube.Pos
	Block uint32
	Tick  int64
}

type SerialisedData

type SerialisedData struct {
	SubChunks [][]byte

	Biomes []byte
}

func Encode

func Encode(c *Chunk, e Encoding) SerialisedData

type SubChunk

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

func NewSubChunk

func NewSubChunk(air uint32) *SubChunk

func (*SubChunk) Block

func (sub *SubChunk) Block(x, y, z byte, layer uint8) uint32

func (*SubChunk) BlockLight

func (sub *SubChunk) BlockLight(x, y, z byte) uint8

func (*SubChunk) Clone

func (sub *SubChunk) Clone() *SubChunk

func (*SubChunk) Empty

func (sub *SubChunk) Empty() bool

func (*SubChunk) Equals

func (sub *SubChunk) Equals(s *SubChunk) bool

func (*SubChunk) Layer

func (sub *SubChunk) Layer(layer uint8) *PalettedStorage

func (*SubChunk) Layers

func (sub *SubChunk) Layers() []*PalettedStorage

func (*SubChunk) SetBlock

func (sub *SubChunk) SetBlock(x, y, z byte, layer uint8, block uint32)

func (*SubChunk) SetBlockLight

func (sub *SubChunk) SetBlockLight(x, y, z byte, level uint8)

func (*SubChunk) SetSkyLight

func (sub *SubChunk) SetSkyLight(x, y, z byte, level uint8)

func (*SubChunk) SkyLight

func (sub *SubChunk) SkyLight(x, y, z byte) uint8

Jump to

Keyboard shortcuts

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