Documentation
¶
Index ¶
- Constants
- type CompressionLevel
- type Provider
- func (p *Provider) ChunkCount() int
- func (p *Provider) Close() error
- func (p *Provider) DimensionChunkCount(dim world.Dimension) int
- func (p *Provider) DisableBackgroundSaves()
- func (p *Provider) EnableBackgroundSaves()
- func (p *Provider) IsDirty() bool
- func (p *Provider) IsReadOnly() bool
- func (p *Provider) LoadColumn(pos world.ChunkPos, dim world.Dimension) (*chunk.Column, error)
- func (p *Provider) LoadPlayerSpawnPosition(id uuid.UUID) (cube.Pos, bool, error)
- func (p *Provider) Save() error
- func (p *Provider) SaveAsync()
- func (p *Provider) SavePlayerSpawnPosition(id uuid.UUID, pos cube.Pos) error
- func (p *Provider) SaveSettings(s *world.Settings)
- func (p *Provider) SetCompressionLevel(level CompressionLevel)
- func (p *Provider) SetStreamingSaves(enabled bool)
- func (p *Provider) Settings() *world.Settings
- func (p *Provider) StoreColumn(pos world.ChunkPos, dim world.Dimension, col *chunk.Column) error
- type Settings
Constants ¶
const ( // CompressionLevelNone disables compression. CompressionLevelNone = format.CompressionLevelNone // CompressionLevelFast uses fast compression (level 1). CompressionLevelFast = format.CompressionLevelFast // CompressionLevelDefault uses default compression (level 3). CompressionLevelDefault = format.CompressionLevelDefault // CompressionLevelBest uses best compression (level 9). CompressionLevelBest = format.CompressionLevelBest )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompressionLevel ¶
type CompressionLevel = format.CompressionLevel
CompressionLevel represents the compression level for saving worlds.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements world.Provider for the Pile world format. Pile is a single-file world format designed for small worlds. Note: Pile loads the entire world into memory, so it's only suitable for small worlds.
func New ¶
New creates a new Pile provider in the given directory. If no world files exist, new ones will be created on first save.
func NewReadOnly ¶
NewReadOnly creates a new read-only Pile provider in the given directory. All modification operations (StoreColumn, SaveSettings, SavePlayerSpawnPosition) will be silently ignored. The provider will not create any files if they don't exist.
func NewReadOnlyWithCompression ¶
func NewReadOnlyWithCompression(dir string, compressionLevel CompressionLevel) (*Provider, error)
NewReadOnlyWithCompression creates a new read-only Pile provider with a specific compression level. The compression level is only used if the provider is later converted to read-write mode.
func NewWithCompression ¶
func NewWithCompression(dir string, compressionLevel CompressionLevel) (*Provider, error)
NewWithCompression creates a new Pile provider with a specific compression level.
func (*Provider) ChunkCount ¶
ChunkCount returns the total number of chunks across all dimensions.
func (*Provider) Close ¶
Close saves all pending changes and closes the provider. Does nothing if the provider is read-only.
func (*Provider) DimensionChunkCount ¶
DimensionChunkCount returns the number of chunks in a specific dimension.
func (*Provider) DisableBackgroundSaves ¶
func (p *Provider) DisableBackgroundSaves()
DisableBackgroundSaves stops the background save goroutine.
func (*Provider) EnableBackgroundSaves ¶
func (p *Provider) EnableBackgroundSaves()
EnableBackgroundSaves starts a background goroutine that coalesces save requests and writes the world to disk asynchronously.
func (*Provider) IsReadOnly ¶
IsReadOnly returns true if the provider is in read-only mode.
func (*Provider) LoadColumn ¶
LoadColumn loads a chunk column from the appropriate dimension.
func (*Provider) LoadPlayerSpawnPosition ¶
LoadPlayerSpawnPosition loads a player's spawn position.
func (*Provider) Save ¶
Save forces a save of all worlds. Does nothing if the provider is read-only.
func (*Provider) SaveAsync ¶
func (p *Provider) SaveAsync()
SaveAsync schedules a background save and returns immediately. If the background saver is not enabled, this is a no-op.
func (*Provider) SavePlayerSpawnPosition ¶
SavePlayerSpawnPosition saves a player's spawn position. Silently ignores the operation if the provider is read-only.
func (*Provider) SaveSettings ¶
SaveSettings saves the world settings. Silently ignores the operation if the provider is read-only.
func (*Provider) SetCompressionLevel ¶
func (p *Provider) SetCompressionLevel(level CompressionLevel)
SetCompressionLevel sets the compression level for future saves.
func (*Provider) SetStreamingSaves ¶
SetStreamingSaves enables or disables streaming saves (chunk-by-chunk). When enabled, the provider streams chunks to disk instead of buffering the entire world.
type Settings ¶
type Settings struct {
Name string
Spawn cube.Pos
Time int64
TimeCycle bool
RainTime int64
Raining bool
ThunderTime int64
Thundering bool
WeatherCycle bool
CurrentTick int64
DefaultGameMode int32
Difficulty int32
}
Settings is an internal representation of world settings for serialization.