world

package
v0.0.0-...-18e7427 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReachRateLimit = errors.New("reach rate limit")
View Source
var NetworkCodec registry.NetworkCodec

Functions

func NewEntityID

func NewEntityID() int32

Types

type ChunkProvider

type ChunkProvider struct {
	// contains filtered or unexported fields
}

ChunkProvider implements chunk storage

func NewProvider

func NewProvider(dir string, limiter *rate.Limiter) ChunkProvider

func (*ChunkProvider) GetChunk

func (p *ChunkProvider) GetChunk(pos maths.Vec2i) (c *level.Chunk, errRet error)

func (*ChunkProvider) PutChunk

func (p *ChunkProvider) PutChunk(pos maths.Vec2i, c *level.Chunk) (err error)

type ChunkViewer

type ChunkViewer interface {
	ViewChunkLoad(pos maths.Vec2i, c *level.Chunk)
	ViewChunkUnload(pos maths.Vec2i)
}

type Client

type Client interface {
	ChunkViewer
	EntityViewer
	SendDisconnect(reason chat.Message)
	SendPlayerPosition(pos maths.Vec3d, rot maths.Vec2f) (teleportID int32)
	SendSetChunkCacheCenter(chunkPos maths.Vec2i)
}

type Config

type Config struct {
	ViewDistance  int32
	SpawnAngle    float32
	SpawnPosition [3]int32
}

type Entity

type Entity struct {
	EntityID int32
	Position maths.Vec3d
	Rotation maths.Vec2f
	ChunkPos maths.Vec2i
	OnGround bool
	// contains filtered or unexported fields
}

type EntityViewer

type EntityViewer interface {
	ViewAddPlayer(p *Player)
	ViewRemoveEntities(entityIDs []int32)
	ViewMoveEntityPos(id int32, delta maths.Vec3s, onGround bool)
	ViewMoveEntityPosAndRot(id int32, delta maths.Vec3s, rot maths.Vec2b, onGround bool)
	ViewMoveEntityRot(id int32, rot maths.Vec2b, onGround bool)
	ViewRotateHead(id int32, yaw int8)
	ViewTeleportEntity(id int32, pos maths.Vec3d, rot maths.Vec2b, onGround bool)
}

type LoadedChunk

type LoadedChunk struct {
	sync.Mutex

	*level.Chunk
	// contains filtered or unexported fields
}

func (*LoadedChunk) AddViewer

func (lc *LoadedChunk) AddViewer(v ChunkViewer)

func (*LoadedChunk) RemoveViewer

func (lc *LoadedChunk) RemoveViewer(v ChunkViewer) bool

type Player

type Player struct {
	Entity
	Name       string
	UUID       uuid.UUID
	PubKey     *auth.PublicKey
	Properties []auth.Property
	Latency    time.Duration

	Gamemode       int32
	EntitiesInView map[int32]*Entity
	ViewDistance   int32
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(name string, uuid uuid.UUID, key *auth.PublicKey, properties []auth.Property) *Player

type PlayerProvider

type PlayerProvider struct {
	// contains filtered or unexported fields
}

func NewPlayerProvider

func NewPlayerProvider(dir string) *PlayerProvider

func (*PlayerProvider) GetPlayer

func (p *PlayerProvider) GetPlayer(name string, id uuid.UUID, pubKey *auth.PublicKey, properties []auth.Property) (player *Player, errRet error)

type World

type World struct {
	Name string
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld(logger *zap.Logger, name string, provider ChunkProvider, config Config) (w *World)

func (*World) AddPlayer

func (w *World) AddPlayer(c Client, p *Player, limiter *rate.Limiter)

func (*World) HashedSeed

func (w *World) HashedSeed() [8]byte

func (*World) RemovePlayer

func (w *World) RemovePlayer(c Client, p *Player)

func (*World) SpawnPositionAndAngle

func (w *World) SpawnPositionAndAngle() ([3]int32, float32)

Jump to

Keyboard shortcuts

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