mcdb

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

func New(dir string) (*Provider, error)

New creates a new provider reading and writing files 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.

func (*Provider) Close

func (p *Provider) Close() error

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) ([]map[string]interface{}, error)

LoadBlockNBT loads all block entities from the chunk position passed.

func (*Provider) LoadChunk

func (p *Provider) LoadChunk(position world.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 (*Provider) LoadDefaultGameMode

func (p *Provider) LoadDefaultGameMode() gamemode.GameMode

LoadDefaultGameMode returns the default game mode stored in the level.dat.

func (*Provider) LoadDifficulty

func (p *Provider) LoadDifficulty() difficulty.Difficulty

LoadDifficulty loads the difficulty stored in the level.dat.

func (*Provider) LoadEntities

func (p *Provider) LoadEntities(world.ChunkPos) ([]world.Entity, error)

LoadEntities loads all entities from the chunk position passed.

func (*Provider) LoadTime

func (p *Provider) LoadTime() int64

LoadTime returns the time as it was stored in the level.dat of the world loaded.

func (*Provider) LoadTimeCycle

func (p *Provider) LoadTimeCycle() bool

LoadTimeCycle returns whether the time is cycling or not.

func (*Provider) SaveBlockNBT

func (p *Provider) SaveBlockNBT(position world.ChunkPos, data []map[string]interface{}) error

SaveBlockNBT saves all block NBT data to the chunk position passed.

func (*Provider) SaveChunk

func (p *Provider) SaveChunk(position world.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 (*Provider) SaveDefaultGameMode

func (p *Provider) SaveDefaultGameMode(mode gamemode.GameMode)

SaveDefaultGameMode changes the default game mode in the level.dat.

func (*Provider) SaveDifficulty

func (p *Provider) SaveDifficulty(d difficulty.Difficulty)

SaveDifficulty saves the difficulty passed to the level.dat.

func (*Provider) SaveEntities

func (p *Provider) SaveEntities(world.ChunkPos, []world.Entity) error

SaveEntities saves all entities to the chunk position passed.

func (*Provider) SaveTime

func (p *Provider) SaveTime(time int64)

SaveTime saves the time to the level.dat of the world.

func (*Provider) SaveTimeCycle

func (p *Provider) SaveTimeCycle(running bool)

SaveTimeCycle saves the state of the time cycle, either running or stopped, to the level.dat.

func (*Provider) SetWorldName

func (p *Provider) SetWorldName(name string)

SetWorldName sets the name of the world to the string passed.

func (*Provider) SetWorldSpawn

func (p *Provider) SetWorldSpawn(pos world.BlockPos)

SetWorldSpawn sets the spawn of the world to a new one.

func (*Provider) WorldName

func (p *Provider) WorldName() string

WorldName returns the name of the world that the provider provides data for.

func (*Provider) WorldSpawn

func (p *Provider) WorldSpawn() world.BlockPos

WorldSpawn returns the spawn of the world as present in the level.dat.

Jump to

Keyboard shortcuts

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