Documentation ¶
Index ¶
- type Logger
- type Provider
- func (p *Provider) Close() error
- func (p *Provider) LoadBlockNBT(position world.ChunkPos, dim world.Dimension) ([]map[string]any, error)
- func (p *Provider) LoadChunk(position world.ChunkPos, dim world.Dimension) (c *chunk.Chunk, exists bool, err error)
- func (p *Provider) LoadEntities(pos world.ChunkPos, dim world.Dimension, reg world.EntityRegistry) ([]world.Entity, error)
- func (p *Provider) LoadPlayerSpawnPosition(id uuid.UUID) (pos cube.Pos, exists bool, err error)
- func (p *Provider) SaveBlockNBT(position world.ChunkPos, data []map[string]any, dim world.Dimension) error
- func (p *Provider) SaveChunk(position world.ChunkPos, c *chunk.Chunk, dim world.Dimension) error
- func (p *Provider) SaveEntities(pos world.ChunkPos, entities []world.Entity, dim world.Dimension) error
- func (p *Provider) SavePlayerSpawnPosition(id uuid.UUID, pos cube.Pos) error
- func (p *Provider) SaveSettings(s *world.Settings)
- func (p *Provider) Settings() *world.Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶ added in v0.8.4
Logger is a logger implementation that may be passed to the Log field of Config. World will send errors and debug messages to this Logger when appropriate.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements a world provider for the Minecraft world format, which is based on a leveldb database.
func New ¶
New creates a new provider reading and writing from/to files under the path passed. If a world is present at the path, New will parse its data and initialise the world with it. If the data cannot be parsed, an error is returned. A compression type may be passed which will be used for the compression of new blocks written to the database. This will only influence the compression. Decompression of the database will happen based on IDs found in the compressed blocks.
func (*Provider) Close ¶
Close closes the provider, saving any file that might need to be saved, such as the level.dat.
func (*Provider) LoadBlockNBT ¶
func (p *Provider) LoadBlockNBT(position world.ChunkPos, dim world.Dimension) ([]map[string]any, error)
LoadBlockNBT loads all block entities from the chunk position passed.
func (*Provider) LoadChunk ¶
func (p *Provider) LoadChunk(position world.ChunkPos, dim world.Dimension) (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 (*Provider) LoadEntities ¶
func (p *Provider) LoadEntities(pos world.ChunkPos, dim world.Dimension, reg world.EntityRegistry) ([]world.Entity, error)
LoadEntities loads all entities from the chunk position passed.
func (*Provider) LoadPlayerSpawnPosition ¶ added in v0.7.0
LoadPlayerSpawnPosition loads the players spawn position stored in the level.dat from their UUID.
func (*Provider) SaveBlockNBT ¶
func (p *Provider) SaveBlockNBT(position world.ChunkPos, data []map[string]any, dim world.Dimension) error
SaveBlockNBT saves all block NBT data to the chunk position passed.
func (*Provider) SaveChunk ¶
SaveChunk saves a chunk at the position passed to the leveldb database. Its version is written as the version in the chunkVersion constant.
func (*Provider) SaveEntities ¶
func (p *Provider) SaveEntities(pos world.ChunkPos, entities []world.Entity, dim world.Dimension) error
SaveEntities saves all entities to the chunk position passed.
func (*Provider) SavePlayerSpawnPosition ¶ added in v0.7.0
SavePlayerSpawnPosition saves the player spawn position passed to the levelDB database.
func (*Provider) SaveSettings ¶ added in v0.1.0
SaveSettings saves the world.Settings passed to the level.dat.