Documentation ¶
Index ¶
- func AddGenerator(name string, f func() Generator)
- func AddSystem(name string, f func() System)
- type Chunk
- func (c *Chunk) Block(x, y, z int) byte
- func (c *Chunk) BlockLight(x, y, z int) byte
- func (c *Chunk) Close() bool
- func (c *Chunk) Data(x, y, z int) byte
- func (c *Chunk) Init(world *World, gen Generator, system System)
- func (c *Chunk) Join(watcher Watcher)
- func (c *Chunk) Leave(watcher Watcher)
- func (c *Chunk) Location() (x, z int)
- func (c *Chunk) SetBlock(x, y, z int, b byte)
- func (c *Chunk) SetBlockLight(x, y, z int, l byte)
- func (c *Chunk) SetData(x, y, z int, d byte)
- func (c *Chunk) SetSkyLight(x, y, z int, l byte)
- func (c *Chunk) SkyLight(x, y, z int) byte
- type ChunkSection
- type Dimension
- type Entity
- type Generator
- type MsgpackSystem
- func (mw *MsgpackSystem) Chunk(x, z int) (*Chunk, bool)
- func (mw *MsgpackSystem) Close()
- func (mw *MsgpackSystem) CloseChunk(x, z int, chunk *Chunk)
- func (mw *MsgpackSystem) Init(path string)
- func (mw *MsgpackSystem) Read(key string, v interface{}) error
- func (mw *MsgpackSystem) SaveChunk(x, z int, chunk *Chunk)
- func (mw *MsgpackSystem) SystemName() string
- func (mw *MsgpackSystem) Write(key string, v interface{}) error
- type System
- type TryClose
- type Watcher
- type World
- func (world *World) AddEntity(x, z int, entity Entity, spawn []protocol.Packet, despawn []protocol.Packet)
- func (world *World) Block(x, y, z int) (block, data byte)
- func (world *World) Dimension() Dimension
- func (world *World) JoinChunk(x, z int, watcher Watcher)
- func (world *World) LeaveChunk(x, z int, watcher Watcher)
- func (world *World) Light(x, y, z int, sky bool) (level byte)
- func (world *World) QueuePacket(x, z int, uuid string, packet protocol.Packet)
- func (world *World) Read(key string, value interface{}) error
- func (world *World) RemoveEntity(x, z int, entity Entity)
- func (world *World) SetBlock(x, y, z int, block, data byte)
- func (world *World) TimeOfDay() int64
- func (world *World) UpdateSpawnData(x, z int, entity Entity, spawn bool, packets []protocol.Packet)
- func (world *World) Write(key string, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGenerator ¶
Add a generator to be used for gemerating worlds. Should only be called at init.
Types ¶
type Chunk ¶
type Chunk struct {
X, Z int
Sections [16]*ChunkSection
Biome [16 * 16]byte
HeightMap [16 * 16]byte
Entities map[string]Entity
// contains filtered or unexported fields
}
A chunk loaded locally in a flat byte arrays
func (*Chunk) BlockLight ¶
func (*Chunk) SetBlockLight ¶
func (*Chunk) SetSkyLight ¶
type ChunkSection ¶
type MsgpackSystem ¶
type MsgpackSystem struct { Name string // contains filtered or unexported fields }
func (*MsgpackSystem) Chunk ¶
func (mw *MsgpackSystem) Chunk(x, z int) (*Chunk, bool)
Returns the chunk at the coordinates, also returns if the chunk existed before this
func (*MsgpackSystem) Close ¶
func (mw *MsgpackSystem) Close()
func (*MsgpackSystem) CloseChunk ¶
func (mw *MsgpackSystem) CloseChunk(x, z int, chunk *Chunk)
Closes the chunk in the system
func (*MsgpackSystem) Read ¶
func (mw *MsgpackSystem) Read(key string, v interface{}) error
Reads key into the passed struct pointer
func (*MsgpackSystem) SaveChunk ¶
func (mw *MsgpackSystem) SaveChunk(x, z int, chunk *Chunk)
Saves the chunk back to storage.
func (*MsgpackSystem) SystemName ¶
func (mw *MsgpackSystem) SystemName() string
Gets the name of the system
func (*MsgpackSystem) Write ¶
func (mw *MsgpackSystem) Write(key string, v interface{}) error
Writes the passed struct/struct pointer to the data folder with the name key.nether.
type System ¶
type System interface { //Loads or creates the system Init(path string) //Gets the name of the system SystemName() string //Writes the passed struct/struct pointer to the system's storage //with the key 'name'. Write(name string, v interface{}) error //Reads 'name' into the passed struct pointer Read(name string, v interface{}) error //Returns the chunk at the coordinates, also returns if the chunk existed //before this Chunk(x, z int) (*Chunk, bool) //Saves the chunk back to storage. SaveChunk(x, z int, storage *Chunk) //Closes the chunk in the system CloseChunk(x, z int, storage *Chunk) //Closes the system Close() }
Systems are the underlying storage system for worlds. The Write/Read and Chunk methods write/read structs into the system. The methods should ignore fields tagged `ignore:"true"`
type World ¶
type World struct { Name string //The limiters were added because trying to send/save all the chunks //at once caused large amounts of memory usage SendLimiter chan cachedCompressor SaveLimiter chan struct{} RequestClose chan *Chunk // contains filtered or unexported fields }
func LoadWorld ¶
func LoadWorld(name string, system System, gen Generator, dimension Dimension, tryClose chan TryClose) *World
Loads the world by name using the passed system if the world doesn't exists.
func (*World) JoinChunk ¶
Adds the watcher to the chunk at the coordinates. If the chunk isn't loaded then it will be loaded.
func (*World) LeaveChunk ¶
Removes the watcher to the chunk at the coordinates.
func (*World) QueuePacket ¶
Sends the packet to all watchers of the chunk apart from the watcher with the passed uuid (leave blank to send to all)
func (*World) Read ¶
Reads the value into the world's system's storage. This method is safe to call from different goroutines when the key is different.