github.com/df-mc/dragonfly@v0.9.13/server/world/settings.go (about)

     1  package world
     2  
     3  import (
     4  	"github.com/df-mc/atomic"
     5  	"github.com/df-mc/dragonfly/server/block/cube"
     6  	"sync"
     7  )
     8  
     9  // Settings holds the settings of a World. These are typically saved to a level.dat file. It is safe to pass the same
    10  // Settings to multiple worlds created using New, in which case the Settings are synchronised between the worlds.
    11  type Settings struct {
    12  	sync.Mutex
    13  	ref atomic.Int32
    14  
    15  	// Name is the display name of the World.
    16  	Name string
    17  	// Spawn is the spawn position of the World. New players that join the world will be spawned here.
    18  	Spawn cube.Pos
    19  	// Time is the current time of the World. It advances every tick if TimeCycle is set to true.
    20  	Time int64
    21  	// TimeCycle specifies if the time should advance every tick. If set to false, time won't change.
    22  	TimeCycle bool
    23  	// RainTime is the current rain time of the World. It advances every tick if WeatherCycle is set to true.
    24  	RainTime int64
    25  	// Raining is the current rain level of the World.
    26  	Raining bool
    27  	// ThunderTime is the current thunder time of the World. It advances every tick if WeatherCycle is set to true.
    28  	ThunderTime int64
    29  	// Thunder is the current thunder level of the World.
    30  	Thundering bool
    31  	// WeatherCycle specifies if weather should be enabled in this world. If set to false, weather will be disabled.
    32  	WeatherCycle bool
    33  	// CurrentTick is the current tick of the world. This is similar to the Time, except that it has no visible effect
    34  	// to the client. It can also not be changed through commands and will only ever go up.
    35  	CurrentTick int64
    36  	// DefaultGameMode is the GameMode assigned to players that join the World for the first time.
    37  	DefaultGameMode GameMode
    38  	// Difficulty is the difficulty of the World. Behaviour of hunger, regeneration and monsters differs based on the
    39  	// difficulty of the world.
    40  	Difficulty Difficulty
    41  	// TickRange is the radius in chunks around a Viewer that has its blocks and entities ticked when the world is
    42  	// ticked. If set to 0, blocks and entities will never be ticked.
    43  	TickRange int32
    44  }
    45  
    46  // defaultSettings returns the default Settings for a new World.
    47  func defaultSettings() *Settings {
    48  	return &Settings{
    49  		Name:            "World",
    50  		DefaultGameMode: GameModeSurvival,
    51  		Difficulty:      DifficultyNormal,
    52  		TimeCycle:       true,
    53  		WeatherCycle:    true,
    54  		TickRange:       6,
    55  	}
    56  }