Documentation
¶
Index ¶
- func ChunkToSave(c *Chunk, dst *save.Chunk) (err error)
- type BiomesState
- type BitStorage
- func (b *BitStorage) Fix(bits int) error
- func (b *BitStorage) Get(i int) int
- func (b *BitStorage) Len() int
- func (b *BitStorage) Raw() []uint64
- func (b *BitStorage) ReadFrom(r io.Reader) (int64, error)
- func (b *BitStorage) Set(i, v int)
- func (b *BitStorage) Swap(i, v int) (old int)
- func (b *BitStorage) WriteTo(w io.Writer) (int64, error)
- type BlockEntity
- type BlocksState
- type Chunk
- type ChunkPos
- type ChunkStatus
- type HeightMaps
- type PaletteContainer
- func NewBiomesPaletteContainer(length int, defaultValue BiomesState) *PaletteContainer[BiomesState]
- func NewBiomesPaletteContainerWithData(length int, data []uint64, pat []BiomesState) *PaletteContainer[BiomesState]
- func NewStatesPaletteContainer(length int, defaultValue BlocksState) *PaletteContainer[BlocksState]
- func NewStatesPaletteContainerWithData(length int, data []uint64, pat []BlocksState) *PaletteContainer[BlocksState]
- type Section
- type State
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BiomesState ¶ added in v1.18.2
type BitStorage ¶
type BitStorage struct {
// contains filtered or unexported fields
}
BitStorage implement the compacted data array used in chunk storage and heightmaps. You can think of this as a []intN whose N is indicated by "bits". For more info, see: https://wiki.vg/Chunk_Format This implementation is compatible with the format since Minecraft 1.16
func NewBitStorage ¶
func NewBitStorage(bits, length int, data []uint64) (b *BitStorage)
NewBitStorage create a new BitStorage.
The "bits" is the number of bits per value, which can be calculated by math/bits.Len() The "length" is the number of values. The "data" is optional for initializing. It will panic if data != nil && len(data) != calcBitStorageSize(bits, length).
Example (Heightmaps) ¶
// Create a BitStorage
bs := NewBitStorage(bits.Len(256), 16*16, nil)
// Fill your data
for i := 0; i < 16; i++ {
for j := 0; j < 16; j++ {
bs.Set(i*16+j, 0)
}
}
// Encode as NBT, and this is ready for packet.Marshal
type HeightMaps struct {
MotionBlocking []uint64 `nbt:"MOTION_BLOCKING"`
}
_ = pk.NBT(HeightMaps{bs.Raw()})
func (*BitStorage) Fix ¶ added in v1.19.0
func (b *BitStorage) Fix(bits int) error
Fix recalculate BitStorage internal values for given bits. Typically, you should call this method after ReadFrom is called, which cause internal data is changed.
func (*BitStorage) Raw ¶
func (b *BitStorage) Raw() []uint64
Raw return the underling array of uint64 for encoding/decoding.
func (*BitStorage) Swap ¶
func (b *BitStorage) Swap(i, v int) (old int)
Swap sets v into [i], and return the previous [i] value.
type BlockEntity ¶ added in v1.18.2
type BlockEntity struct {
XZ int8
Y int16
Type block.EntityType
Data nbt.RawMessage
}
func (*BlockEntity) PackXZ ¶ added in v1.19.3
func (b *BlockEntity) PackXZ(X, Z int) bool
func (*BlockEntity) ReadFrom ¶ added in v1.18.2
func (b *BlockEntity) ReadFrom(r io.Reader) (n int64, err error)
func (BlockEntity) UnpackXZ ¶ added in v1.18.2
func (b BlockEntity) UnpackXZ() (X, Z int)
type BlocksState ¶ added in v1.18.2
type Chunk ¶
type Chunk struct {
Sections []Section
HeightMaps HeightMaps
BlockEntity []BlockEntity
Status ChunkStatus
}
func ChunkFromSave ¶
ChunkFromSave convert save.Chunk to level.Chunk.
func EmptyChunk ¶
type ChunkStatus ¶ added in v1.19.0
type ChunkStatus string
const ( StatusEmpty ChunkStatus = "empty" StatusStructureStarts ChunkStatus = "structure_starts" StatusStructureReferences ChunkStatus = "structure_references" StatusBiomes ChunkStatus = "biomes" StatusNoise ChunkStatus = "noise" StatusSurface ChunkStatus = "surface" StatusCarvers ChunkStatus = "carvers" StatusLiquidCarvers ChunkStatus = "liquid_carvers" StatusFeatures ChunkStatus = "features" StatusLight ChunkStatus = "light" StatusSpawn ChunkStatus = "spawn" StatusHeightmaps ChunkStatus = "heightmaps" StatusFull ChunkStatus = "full" )
type HeightMaps ¶
type HeightMaps struct {
WorldSurfaceWG *BitStorage // test = NOT_AIR
WorldSurface *BitStorage // test = NOT_AIR
OceanFloorWG *BitStorage // test = MATERIAL_MOTION_BLOCKING
OceanFloor *BitStorage // test = MATERIAL_MOTION_BLOCKING
MotionBlocking *BitStorage // test = BlocksMotion or isFluid
MotionBlockingNoLeaves *BitStorage // test = BlocksMotion or isFluid
}
type PaletteContainer ¶
type PaletteContainer[T State] struct { // contains filtered or unexported fields }
func NewBiomesPaletteContainer ¶
func NewBiomesPaletteContainer(length int, defaultValue BiomesState) *PaletteContainer[BiomesState]
func NewBiomesPaletteContainerWithData ¶
func NewBiomesPaletteContainerWithData(length int, data []uint64, pat []BiomesState) *PaletteContainer[BiomesState]
func NewStatesPaletteContainer ¶
func NewStatesPaletteContainer(length int, defaultValue BlocksState) *PaletteContainer[BlocksState]
func NewStatesPaletteContainerWithData ¶
func NewStatesPaletteContainerWithData(length int, data []uint64, pat []BlocksState) *PaletteContainer[BlocksState]
func (*PaletteContainer[T]) Get ¶
func (p *PaletteContainer[T]) Get(i int) T
func (*PaletteContainer[T]) Palette ¶ added in v1.19.4
func (p *PaletteContainer[T]) Palette() []T
Palette export the raw palette values for @maxsupermanhd. Others shouldn't call this because this might be removed after max doesn't need it anymore.
func (*PaletteContainer[T]) ReadFrom ¶
func (p *PaletteContainer[T]) ReadFrom(r io.Reader) (n int64, err error)
func (*PaletteContainer[T]) Set ¶
func (p *PaletteContainer[T]) Set(i int, v T)
type Section ¶
type Section struct {
BlockCount int16
States *PaletteContainer[BlocksState]
Biomes *PaletteContainer[BiomesState]
// Half a byte per light value.
// Could be nil if not exist
SkyLight []byte // len() == 2048
BlockLight []byte // len() == 2048
}
func (*Section) GetBlock ¶
func (s *Section) GetBlock(i int) BlocksState
func (*Section) SetBlock ¶
func (s *Section) SetBlock(i int, v BlocksState)
Directories
¶
| Path | Synopsis |
|---|---|
|
generator/blockentities
command
|
|
|
generator/blocks
command
|
|
|
generator/properties
command
|