Documentation
¶
Index ¶
- type BedrockWorld
- func (db *BedrockWorld) CloseWorld() error
- func (db *BedrockWorld) LevelDat() *leveldat.Data
- func (b *BedrockWorld) LoadBiomes(dm define.Dimension, position define.ChunkPos) ([]byte, error)
- func (b *BedrockWorld) LoadChunk(dm define.Dimension, position define.ChunkPos) (c *chunk.Chunk, exists bool, err error)
- func (b *BedrockWorld) LoadChunkPayloadOnly(dm define.Dimension, position define.ChunkPos) (subchunksBytes [][]byte, exists bool, err error)
- func (b *BedrockWorld) LoadDeltaUpdate(dm define.Dimension, position define.ChunkPos) ([]byte, error)
- func (b *BedrockWorld) LoadDeltaUpdateTimeStamp(dm define.Dimension, position define.ChunkPos) (timeStamp int64)
- func (b *BedrockWorld) LoadFullSubChunkBlobHash(dm define.Dimension, position define.ChunkPos) (result []define.HashWithPosY)
- func (b *BedrockWorld) LoadNBT(dm define.Dimension, position define.ChunkPos) ([]map[string]any, error)
- func (b *BedrockWorld) LoadNBTPayloadOnly(dm define.Dimension, position define.ChunkPos) []byte
- func (b *BedrockWorld) LoadSubChunk(dm define.Dimension, position define.SubChunkPos) *chunk.SubChunk
- func (b *BedrockWorld) LoadSubChunkBlobHash(dm define.Dimension, position define.SubChunkPos) (hash uint64, found bool)
- func (b *BedrockWorld) LoadTimeStamp(dm define.Dimension, position define.ChunkPos) (timeStamp int64)
- func (b *BedrockWorld) SaveBiomes(dm define.Dimension, position define.ChunkPos, payload []byte) error
- func (b *BedrockWorld) SaveChunk(dm define.Dimension, position define.ChunkPos, c *chunk.Chunk) error
- func (b *BedrockWorld) SaveChunkPayloadOnly(dm define.Dimension, position define.ChunkPos, subchunksBytes [][]byte) error
- func (b *BedrockWorld) SaveDeltaUpdate(dm define.Dimension, position define.ChunkPos, payload []byte) error
- func (b *BedrockWorld) SaveDeltaUpdateTimeStamp(dm define.Dimension, position define.ChunkPos, timeStamp int64) error
- func (b *BedrockWorld) SaveFullSubChunkBlobHash(dm define.Dimension, position define.ChunkPos, newHash []define.HashWithPosY) error
- func (b *BedrockWorld) SaveNBT(dm define.Dimension, position define.ChunkPos, data []map[string]any) error
- func (b *BedrockWorld) SaveNBTPayloadOnly(dm define.Dimension, position define.ChunkPos, data []byte) error
- func (b *BedrockWorld) SaveSubChunk(dm define.Dimension, position define.SubChunkPos, c *chunk.SubChunk) error
- func (b *BedrockWorld) SaveSubChunkBlobHash(dm define.Dimension, position define.SubChunkPos, hash uint64) error
- func (b *BedrockWorld) SaveTimeStamp(dm define.Dimension, position define.ChunkPos, timeStamp int64) error
- func (db *BedrockWorld) UpdateLevelDat() error
- type Config
- type CustomBedrockWorld
- type LevelDB
- type StandardBedrockWorld
- type World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BedrockWorld ¶
type BedrockWorld struct {
LevelDB
// contains filtered or unexported fields
}
BedrockWorld implements a world provider for the Minecraft world format, which is based on a leveldb database.
func Open ¶
func Open(dir string, key []byte) (*BedrockWorld, error)
Open creates a new provider reading and writing from/to files under the path passed using default options. If a world is present at the path, Open will parse its data and initialise the world with it. If the data cannot be parsed, an error is returned.
key is used to encrypt the payload of the leveldb key. The encrypt way is AES+ECB+PKCS7Padding. Given a key that is nil or 0 length will disable encrypt.
Note that the length of given key must be 16, otherwise return an error.
func (*BedrockWorld) CloseWorld ¶
func (db *BedrockWorld) CloseWorld() error
CloseWorld closes the provider, saving any file that might need to be saved, such as the level.dat.
func (*BedrockWorld) LevelDat ¶
func (db *BedrockWorld) LevelDat() *leveldat.Data
LevelDat return the level dat of this world.
func (*BedrockWorld) LoadBiomes ¶
func (*BedrockWorld) LoadChunk ¶
func (b *BedrockWorld) LoadChunk(dm define.Dimension, position define.ChunkPos) (c *chunk.Chunk, exists bool, err error)
LoadChunk loads a chunk at the position passed from the leveldb database. If it doesn't exist, exists is false. If an error is returned, exists is always assumed to be true.
func (*BedrockWorld) LoadChunkPayloadOnly ¶
func (b *BedrockWorld) LoadChunkPayloadOnly(dm define.Dimension, position define.ChunkPos) (subchunksBytes [][]byte, exists bool, err error)
LoadChunkPayloadOnly loads a chunk at the position passed from the leveldb database. If it doesn't exist, exists is false. If an error is returned, exists is always assumed to be true. Note that we here don't decode chunk data and just return the origin payload.
func (*BedrockWorld) LoadDeltaUpdate ¶
func (*BedrockWorld) LoadDeltaUpdateTimeStamp ¶
func (*BedrockWorld) LoadFullSubChunkBlobHash ¶
func (b *BedrockWorld) LoadFullSubChunkBlobHash(dm define.Dimension, position define.ChunkPos) (result []define.HashWithPosY)
LoadFullSubChunkBlobHash load the blob hash of a chunk.
func (*BedrockWorld) LoadNBT ¶
func (b *BedrockWorld) LoadNBT(dm define.Dimension, position define.ChunkPos) ([]map[string]any, error)
LoadNBT loads all block entities from the chunk position passed.
func (*BedrockWorld) LoadNBTPayloadOnly ¶
LoadNBTPayloadOnly loads payload of all block entities from the chunk position passed.
func (*BedrockWorld) LoadSubChunk ¶
func (b *BedrockWorld) LoadSubChunk(dm define.Dimension, position define.SubChunkPos) *chunk.SubChunk
LoadSubChunk loads a sub chunk at the position from the leveldb database.
func (*BedrockWorld) LoadSubChunkBlobHash ¶
func (b *BedrockWorld) LoadSubChunkBlobHash(dm define.Dimension, position define.SubChunkPos) (hash uint64, found bool)
LoadSubChunkBlobHash load the blob hash of a sub chunk that in position and in dm dimension.
func (*BedrockWorld) LoadTimeStamp ¶
func (*BedrockWorld) SaveBiomes ¶
func (*BedrockWorld) SaveChunk ¶
func (b *BedrockWorld) SaveChunk(dm define.Dimension, position define.ChunkPos, c *chunk.Chunk) error
SaveChunk saves a chunk at the position passed to the leveldb database. Its version is written as the version in the chunkVersion constant.
func (*BedrockWorld) SaveChunkPayloadOnly ¶
func (b *BedrockWorld) SaveChunkPayloadOnly(dm define.Dimension, position define.ChunkPos, subchunksBytes [][]byte) error
SaveChunkPayloadOnly saves a serialized chunk at the position passed to the leveldb database. Its version is written as the version in the chunkVersion constant.
func (*BedrockWorld) SaveDeltaUpdate ¶
func (*BedrockWorld) SaveDeltaUpdateTimeStamp ¶
func (*BedrockWorld) SaveFullSubChunkBlobHash ¶
func (b *BedrockWorld) SaveFullSubChunkBlobHash(dm define.Dimension, position define.ChunkPos, newHash []define.HashWithPosY) error
SaveFullSubChunkBlobHash update the blob hash of a chunk. Note that:
- If len(newHash) is 0, then the blob hash data of this chunk will be delete.
- Zero hash is allowed.
func (*BedrockWorld) SaveNBT ¶
func (b *BedrockWorld) SaveNBT(dm define.Dimension, position define.ChunkPos, data []map[string]any) error
SaveNBT saves all block NBT data to the chunk position passed.
func (*BedrockWorld) SaveNBTPayloadOnly ¶
func (b *BedrockWorld) SaveNBTPayloadOnly(dm define.Dimension, position define.ChunkPos, data []byte) error
SaveNBTPayloadOnly saves a serialized NBT data to the chunk position passed.
func (*BedrockWorld) SaveSubChunk ¶
func (b *BedrockWorld) SaveSubChunk(dm define.Dimension, position define.SubChunkPos, c *chunk.SubChunk) error
SaveSubChunk saves a sub chunk at the position passed to the leveldb database. Its version is written as the version in the chunkVersion constant.
func (*BedrockWorld) SaveSubChunkBlobHash ¶
func (b *BedrockWorld) SaveSubChunkBlobHash(dm define.Dimension, position define.SubChunkPos, hash uint64) error
SaveSubChunkBlobHash save the hash for sub chunk which in position and in dm dimension. Note that zero hash is allowed.
func (*BedrockWorld) SaveTimeStamp ¶
func (*BedrockWorld) UpdateLevelDat ¶
func (db *BedrockWorld) UpdateLevelDat() error
UpdateLevelDat update level dat immediately.
type Config ¶
type Config struct {
// Log is the Logger that will be used to log errors and debug messages to.
// If set to nil, Log is set to slog.Default().
Log *slog.Logger
// LDBOptions holds LevelDB specific default options, such as the block size
// or compression used in the database.
LDBOptions *opt.Options
}
Config holds the optional parameters of a DB.
func (Config) Open ¶
func (conf Config) Open(dir string, key []byte) (*BedrockWorld, error)
Open creates a new DB reading and writing from/to files under the path passed. If a world is present at the path, Open will parse its data and initialise the world with it. If the data cannot be parsed, an error is returned.
key is used to encrypt the payload of the leveldb key. The encrypt way is AES+ECB+PKCS7Padding. Given a key that is nil or 0 length will disable encrypt.
Note that the length of given key must be 16, otherwise return an error.
type CustomBedrockWorld ¶
type CustomBedrockWorld interface {
LoadDeltaUpdate(dm define.Dimension, position define.ChunkPos) ([]byte, error)
SaveDeltaUpdate(dm define.Dimension, position define.ChunkPos, payload []byte) error
LoadTimeStamp(dm define.Dimension, position define.ChunkPos) (timeStamp int64)
SaveTimeStamp(dm define.Dimension, position define.ChunkPos, timeStamp int64) error
LoadDeltaUpdateTimeStamp(dm define.Dimension, position define.ChunkPos) (timeStamp int64)
SaveDeltaUpdateTimeStamp(dm define.Dimension, position define.ChunkPos, timeStamp int64) error
LoadFullSubChunkBlobHash(dm define.Dimension, position define.ChunkPos) (result []define.HashWithPosY)
SaveFullSubChunkBlobHash(dm define.Dimension, position define.ChunkPos, newHash []define.HashWithPosY) error
LoadSubChunkBlobHash(dm define.Dimension, position define.SubChunkPos) (hash uint64, found bool)
SaveSubChunkBlobHash(dm define.Dimension, position define.SubChunkPos, hash uint64) error
}
CustomBedrockWorld is the function that bedrock world implements, but for custom used purpose, and are not minecraft standard.
type LevelDB ¶
type LevelDB interface {
Close() error
Delete(key []byte) error
Get(key []byte) (value []byte, err error)
Has(key []byte) (has bool, err error)
Put(key []byte, value []byte) error
}
LevelDB represent to a level database that implements some basic funtions.
type StandardBedrockWorld ¶
type StandardBedrockWorld interface {
LevelDat() *leveldat.Data
UpdateLevelDat() error
CloseWorld() error
LoadBiomes(dm define.Dimension, position define.ChunkPos) ([]byte, error)
SaveBiomes(dm define.Dimension, position define.ChunkPos, payload []byte) error
LoadChunkPayloadOnly(dm define.Dimension, position define.ChunkPos) (subchunksBytes [][]byte, exists bool, err error)
LoadChunk(dm define.Dimension, position define.ChunkPos) (c *chunk.Chunk, exists bool, err error)
SaveChunkPayloadOnly(dm define.Dimension, position define.ChunkPos, subchunksBytes [][]byte) error
SaveChunk(dm define.Dimension, position define.ChunkPos, c *chunk.Chunk) error
LoadSubChunk(dm define.Dimension, position define.SubChunkPos) *chunk.SubChunk
SaveSubChunk(dm define.Dimension, position define.SubChunkPos, c *chunk.SubChunk) error
LoadNBTPayloadOnly(dm define.Dimension, position define.ChunkPos) []byte
LoadNBT(dm define.Dimension, position define.ChunkPos) ([]map[string]any, error)
SaveNBTPayloadOnly(dm define.Dimension, position define.ChunkPos, data []byte) error
SaveNBT(dm define.Dimension, position define.ChunkPos, data []map[string]any) error
}
StandardBedrockWorld is the function that bedrock world implements, but only for standard minecraft.
type World ¶
type World interface {
LevelDB
StandardBedrockWorld
CustomBedrockWorld
}
World is a interface that implements standard bedrock world and some custom features.