world

package
v0.0.0-...-6f503ef Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: AGPL-3.0 Imports: 27 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 [2]int32) (c *level.Chunk, errRet error)

func (*ChunkProvider) PutChunk

func (p *ChunkProvider) PutChunk(pos [2]int32, c *level.Chunk) (err error)

type ChunkViewer

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

type Client

type Client interface {
	ChunkViewer
	EntityViewer
	SendDisconnect(reason chat.Message)
	SendPlayerPosition(pos [3]float64, rot [2]float32) (teleportID int32)
	SendSetChunkCacheCenter(chunkPos [2]int32)
}

type ClientInfo

type ClientInfo struct {
	Locale              string
	ViewDistance        int8
	ChatMode            int32
	ChatColors          bool
	DisplayedSkinParts  byte
	MainHand            int32
	EnableTextFiltering bool
	AllowServerListings bool
}

func (*ClientInfo) ReadFrom

func (i *ClientInfo) ReadFrom(r io.Reader) (n int64, err error)

type Config

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

type Entity

type Entity struct {
	EntityID int32
	Position
	Rotation
	OnGround
	// contains filtered or unexported fields
}

type EntityViewer

type EntityViewer interface {
	ViewAddPlayer(p *Player)
	ViewRemoveEntities(entityIDs []int32)
	ViewMoveEntityPos(id int32, delta [3]int16, onGround bool)
	ViewMoveEntityPosAndRot(id int32, delta [3]int16, rot [2]int8, onGround bool)
	ViewMoveEntityRot(id int32, rot [2]int8, onGround bool)
	ViewRotateHead(id int32, yaw int8)
	ViewTeleportEntity(id int32, pos [3]float64, rot [2]int8, onGround bool)
}

type Inputs

type Inputs struct {
	sync.Mutex
	ClientInfo
	Position
	Rotation
	OnGround
	Latency    time.Duration
	TeleportID int32
}

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 OnGround

type OnGround bool

type Player

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

	ChunkPos     [3]int32
	ViewDistance int32

	Gamemode       int32
	EntitiesInView map[int32]*Entity

	Inputs Inputs
	// contains filtered or unexported fields
}

func (*Player) GetPrevChatSignature

func (p *Player) GetPrevChatSignature() []byte

func (*Player) SetLastChatTimestamp

func (p *Player) SetLastChatTimestamp(t time.Time) bool

SetLastChatTimestamp update the lastChatTimestamp and return true if new timestamp is newer than last one. Otherwise, didn't update the lastChatTimestamp and return false.

func (*Player) SetPrevChatSignature

func (p *Player) SetPrevChatSignature(sig []byte)

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 *user.PublicKey, properties []user.Property) (player *Player, errRet error)

type Position

type Position [3]float64

func (*Position) IsValid

func (p *Position) IsValid() bool

type Rotation

type Rotation [2]float32

type TeleportRequest

type TeleportRequest struct {
	ID int32
	Position
	Rotation
}

type World

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

func New

func New(logger *zap.Logger, 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) Name

func (w *World) Name() string

func (*World) RemovePlayer

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

func (*World) SpawnPositionAndAngle

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

Directories

Path Synopsis
internal
bvh

Jump to

Keyboard shortcuts

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