Documentation
¶
Index ¶
- Constants
- Variables
- func ToNibble(b []byte, index int) byte
- type Anvil
- func (lvl *Anvil) Chunk(x, y int, create bool) level.Chunk
- func (lvl *Anvil) Chunks() []level.Chunk
- func (lvl *Anvil) IsLoadedChunk(x, y int) bool
- func (lvl *Anvil) LoadChunk(x, y int, create bool) bool
- func (lvl *Anvil) SaveChunk(x, y int) bool
- func (lvl *Anvil) SaveChunks()
- func (lvl *Anvil) UnloadChunk(x, y int, safe bool) bool
- type BlockState
- type Chunk
- func (chunk *Chunk) AtSubChunk(y int) (*SubChunk, bool)
- func (chunk *Chunk) GetBlock(x, y, z int) (*block.Block, error)
- func (chunk *Chunk) GetSubChunk(y int) (*SubChunk, bool)
- func (chunk *Chunk) Save() (*nbt.Compound, error)
- func (chunk *Chunk) SubChunks() []*SubChunk
- func (chunk *Chunk) X() int
- func (chunk *Chunk) Y() int
- type ChunkFormat
- type ChunkFormatV112
- type ChunkFormatV113
- type Location
- type Region
- type RegionLoader
- type SubChunk
- func (SubChunk) At(x, y, z int) int
- func (sub *SubChunk) AtBlock(x, y, z int) (*BlockState, error)
- func (sub *SubChunk) AtBlockLight(x, y, z int) (byte, error)
- func (sub *SubChunk) AtSkyLight(x, y, z int) (byte, error)
- func (sub *SubChunk) BlockIndex(x, y, z int) (uint16, error)
- func (SubChunk) Vaild(x, y, z int) error
- type SubChunkFormat
- type SubChunkFormatV112
- type SubChunkFormatV113
Constants ¶
const ( // ChunkCount is the number of chunks in a region file ChunkCount = 32 * 32 // 1024 // Sector is a data sector for region format Sector = 4 * ChunkCount // LocationsBytes is a offset for chunks location in a region file LocationsBytes = Sector // 4 = (offset 3bytes, count 1byte) // TimestampsBytes is a offset for chunks's timestamp in a region file TimestampsBytes = Sector // 4 = timestamp 4 bytes // InformationSector is a information sector for chunk data InformationSector = LocationsBytes + TimestampsBytes )
const ( // CompressionGZip compresses chunk data with gzip for chunk data CompressionGZip = iota + 1 // CompressionZlib compresses chunk data with zlib for chunk data CompressionZlib )
Variables ¶
var ( // RegionFileMCRegion returns a region file name for mcregion RegionFileMCRegion = func(x, y int) string { return "r." + strconv.Itoa(x) + "." + strconv.Itoa(y) + ".mcr" } // RegionFileAnvil returns a region file name for mcregion RegionFileAnvil = func(x, y int) string { return "r." + strconv.Itoa(x) + "." + strconv.Itoa(y) + ".mca" } )
Functions ¶
Types ¶
type Anvil ¶
type Anvil struct {
// contains filtered or unexported fields
}
Anvil is a level format It often is used for minecraft java edition and server world
func (*Anvil) Chunk ¶
Chunk returns a chunk. If it's not loaded, loads the chunks. If create is true, generates a chunk.
func (*Anvil) IsLoadedChunk ¶
IsLoadedChunk returns weather a chunk is loaded.
type BlockState ¶
type BlockState struct { Name string Properties map[string]string IsOld bool OldID byte OldMeta byte }
func (*BlockState) Equal ¶
func (bs *BlockState) Equal(sub *BlockState) bool
func (*BlockState) ToBlockData ¶
func (bs *BlockState) ToBlockData() *block.Block
type Chunk ¶
type Chunk struct { ChunkFormat ChunkFormat // contains filtered or unexported fields }
Chunk is
func (*Chunk) AtSubChunk ¶
AtSubChunk returns a sub chunk at the y (chunk coordinate)
func (*Chunk) GetSubChunk ¶
GetSubChunk returns a sub chunk at the y index you can set 0-15 at y
type ChunkFormat ¶
ChunkFormat is a chunk format for a version
type Region ¶
Region is a section had 32x32 chunks
type RegionLoader ¶
type RegionLoader struct { ToRegionFile func(x, y int) string // contains filtered or unexported fields }
RegionLoader controls a region file on dir and pass Region to load a region
func NewRegionLoader ¶
func NewRegionLoader(path string, tofile func(x, y int) string) (*RegionLoader, error)
NewRegionLoader returns new RegionLoader You can set RegionFileMCRegion and RegionFileAnvil to tofile
func (*RegionLoader) LoadRegion ¶
func (rl *RegionLoader) LoadRegion(x, y int, create bool) (*Region, error)
LoadRegion loads a region
func (*RegionLoader) SaveRegion ¶
func (rl *RegionLoader) SaveRegion(reg *Region) error
SaveRegion saves a region as a file
type SubChunk ¶
type SubChunk struct { Y byte Palette []*BlockState Blocks []uint16 BlockLight []byte SkyLight []byte }
SubChunk is what is divided a chunk horizontally in sixteen
func (*SubChunk) AtBlock ¶
func (sub *SubChunk) AtBlock(x, y, z int) (*BlockState, error)
AtBlock returns block name at the subchunk coordinates
func (*SubChunk) AtBlockLight ¶
AtBlockLight returns a blocklight at the subchunk coordinates
func (*SubChunk) AtSkyLight ¶
AtSkyLight returns a skylight at the subchunk coordinates
func (*SubChunk) BlockIndex ¶
BlockIndex returns a index for block id
type SubChunkFormat ¶
SubChunkFormat is a subchunk format for a version
type SubChunkFormatV112 ¶
type SubChunkFormatV112 struct { }
SubChunkFormatV112 is a subchunk format for v1.12 and before
type SubChunkFormatV113 ¶
type SubChunkFormatV113 struct { }
SubChunkFormatV113 is a subchunk format for v1.13 and after