Documentation
¶
Overview ¶
This file contains abstractions for serializing data For how data is stored, and Database access, see client_storage.go
This file contains how data is saved in the database For how data is represented while loaded see client_data.go
minetest-go is a *very* simple minetest server written in golang
Index ¶
- Constants
- Variables
- func Acks(acks ...<-chan struct{}) <-chan struct{}
- func AddAlias(alias ...Alias)
- func AddExpiredCondition(f func(*MapBlk) bool)
- func AddItemDef(defs ...ItemDef)
- func AddMedia(m ...struct{ Name, Base64SHA1 string })
- func AddMediaURL(url ...string)
- func AddNodeDef(defs ...NodeDef)
- func AnticheatPos(clt *Client, old, new PPos, dtime time.Duration) bool
- func Broadcast(cmd mt.Cmd) []<-chan struct{}
- func BroadcastAOMsgs(ao ActiveObject, msgs ...mt.AOMsg) (<-chan struct{}, error)
- func BroadcastClientM(s map[*Client]struct{}, cmd mt.Cmd) <-chan struct{}
- func BroadcastClientS(s []*Client, cmd mt.Cmd) <-chan struct{}
- func Caller(i int) string
- func CleanCache()
- func CltLeave(l *Leave) (ack <-chan struct{}, err error)
- func Clts() map[*Client]struct{}
- func ConfigVerbose() bool
- func Cos32(x float32) float32
- func DB_PlayerDelData(uuid UUID, name string) (err error)
- func DB_PlayerGetByUUID(uuid UUID) (name string, err error)
- func DB_PlayerGetData(uuid UUID) (cd map[string]ClientData, bytes int, err error)
- func DB_PlayerSet(uuid UUID, name string) (err error)
- func DB_PlayerSetData(uuid UUID, name string, data []byte) (err error)
- func DefaultMapLoader() string
- func Deserialize(r io.Reader, d interface{}) error
- func Distance(a, b [3]float32) float32
- func Fields2map(s []mt.NodeMetaField) map[string]mt.NodeMetaField
- func ForInConfig(f func(k string, v any) error) (err error)
- func GetConfig[K any](key string, d K) (val K, ok bool)
- func GetConfigV[K any](key string, d K) (val K)
- func GetNode(p IntPos) (node mt.Node, meta *mt.NodeMeta)
- func GetNodeID(name string) mt.Content
- func GetPAOID(clt *Client) mt.AOID
- func Give(c *Client, inv *InvLocation, cnt uint16, itm string) (uint16, <-chan struct{}, error)
- func GroupCapsS2ToolGroupCapM(s []mt.ToolGroupCap) (m map[string]ToolGroupCap)
- func GroupsS2GroupsM(groups []mt.Group) (m map[string]int16)
- func HasAO(clt *Client, ao mt.AOID) bool
- func IDAOMsgs(id mt.AOID, msgs ...mt.AOMsg) (s []mt.IDAOMsg)
- func InitClient(c *Client)
- func IsCached(pos IntPos) bool
- func ListAOs() map[mt.AOID]ActiveObject
- func ListDrivers() (s []string)
- func LoadBlk(clt *Client, p IntPos) <-chan struct{}
- func LoadConfig()
- func Map2Slice[V comparable](m map[V]struct{}) []V
- func MaxSpeed(clt *Client) float32
- func MustGetConfig(key string) any
- func NRGBA(c color.Color) color.NRGBA
- func NodeMaps() (NodeIdMap map[mt.Content]string, IdNodeMap map[string]mt.Content)
- func NodeMetasEqual(m1, m2 *mt.NodeMeta) bool
- func Path(path string) string
- func PlayerExists(name string) bool
- func ReadInt(r io.Reader, colon bool) (i int)
- func ReadString(r io.Reader, colon bool) (str string)
- func ReadUint16(r io.Reader, colon bool) (i uint16)
- func RealNodeName(name string) string
- func RegisterAO(ao ActiveObject) mt.AOID
- func RegisterDetached(name string, inv *DetachedInv)
- func RegisterMapDriver(name string, driver MapDriver)
- func RegisterMapGenerator(name string, gen MapGenerator)
- func RegisterMapLoader(name string, loader MapLoader)
- func RegisterPlayer(c *Client)
- func RegisterPlayerMaker(name string, mk PlayerAOMaker)
- func RegisterStage1(f func())
- func RegisterStage2(f func())
- func Relevant(ao ActiveObject, clt *Client) bool
- func ReloadConfig()
- func RmAO(id mt.AOID) bool
- func Round32(x float32) float32
- func RoundToEven32(x float32) float32
- func Run()
- func SCaller(i int) string
- func SaveCache()
- func SerializeString(s func(io.Writer) error) (string, error)
- func SetNode(p IntPos, node mt.Node, meta *mt.NodeMeta)
- func SimpleInvFromNamedInvList(list mt.Inv, inv *SimpleInv)
- func Sin32(x float32) float32
- func Sqrt32(x float32) float32
- func Stage1()
- func Stage2()
- func SyncPlayerData(c *Client)
- func T[K any](c bool, t, f K) K
- func TestSpec() string
- func TextureS2StringS(s []Texture) (r []string)
- func TextureStr(t Texture) mt.Texture
- func TimesS2TimesM(s []mt.DigTime) (m map[int16]float32)
- func TryCache(pos IntPos) error
- func Update(inv RWInv, loc *InvLocation, c *Client) (<-chan struct{}, error)
- func UseItem(inv RWInv, name string, slot int, i int) bool
- type ALH
- type AOData
- type AOInit
- type AOPos
- type ActiveObject
- type ActiveObjectAPIAOPos
- type ActiveObjectPlayer
- type ActiveObjectRelevant
- type ActiveObjectTicker
- type Alias
- type BlamedErr
- type Client
- func (c *Client) DelData(field string) (found bool)
- func (c *Client) DigPos() (*IntPos, time.Time)
- func (c *Client) Fatalf(str string, v ...any) (ack <-chan struct{}, err error)
- func (c *Client) GetData(field string) (cd ClientData, ok bool)
- func (c *Client) GetFullPos() *ClientPos
- func (c *Client) GetMapLoader() *Registerd[*Registerd[MapLoader]]
- func (c *Client) GetPos() PPos
- func (c *Client) GetSpec(name string) (spec *Formspec)
- func (c *Client) Init() <-chan struct{}
- func (c *Client) IsDigging() bool
- func (c *Client) Kick(r mt.KickReason, Custom string) (ack <-chan struct{}, err error)
- func (c *Client) Log(v ...any)
- func (c *Client) Logf(format string, v ...any)
- func (c *Client) MapLoad() bool
- func (c *Client) PRoD(pr float32) float32
- func (c *Client) PointRange() float32
- func (c *Client) RegisterFormspec(spec *Formspec)
- func (c *Client) SendAnnounceMedia()
- func (c *Client) SendCmd(cmd mt.Cmd) (ack <-chan struct{}, err error)
- func (c *Client) SendItemDefs() (<-chan struct{}, error)
- func (c *Client) SendNodeDefs() (<-chan struct{}, error)
- func (c *Client) SetData(field string, value ClientData) (overwrote bool)
- func (c *Client) SetMapLoader(loader *Registerd[MapLoader])
- func (c *Client) SetState(state ClientState)
- func (c *Client) ShowSpec(spec *Formspec) (<-chan struct{}, error)
- func (c *Client) ShowSpecf(rspec *Formspec, v ...any) (<-chan struct{}, error)
- func (c *Client) String() string
- type ClientData
- type ClientDataSaved
- type ClientDataSerialize
- type ClientDataString
- type ClientPos
- type ClientState
- type CraftItem
- func (itm *CraftItem) ItemDef() mt.ItemDef
- func (itm *CraftItem) Name() string
- func (itm *CraftItem) OnActivate(c *Client, s mt.Stack, a *mt.ToSrvInteract) mt.Stack
- func (itm *CraftItem) OnMove(c *Client, s mt.Stack, a *InvAction) mt.Stack
- func (itm *CraftItem) OnPlace(c *Client, s mt.Stack, a *mt.ToSrvInteract) mt.Stack
- func (itm *CraftItem) OnUse(c *Client, s mt.Stack, a *mt.ToSrvInteract) mt.Stack
- type Deserializer
- type DetachedInv
- type DigCond
- type DimID
- type Dimension
- type DropHook
- type ErrInvalidInvAction
- type FormSpecSubmitFunc
- type Formspec
- type HookRef
- func RegisterALH(h ALH) HookRef[Registerd[ALH]]
- func RegisterDigCond(h DigCond) HookRef[Registerd[DigCond]]
- func RegisterDropHook(h DropHook) HookRef[Registerd[DropHook]]
- func RegisterInitHook(h InitHook) HookRef[Registerd[InitHook]]
- func RegisterJoinHook(h JoinHook) HookRef[Registerd[JoinHook]]
- func RegisterLeaveHook(h LeaveHook) HookRef[Registerd[LeaveHook]]
- func RegisterPacketPre(h PacketPre) HookRef[Registerd[PacketPre]]
- func RegisterPhysTickHook(h PhysHook) HookRef[Registerd[PhysHook]]
- func RegisterPktProcessor(h PktProcessor) HookRef[Registerd[PktProcessor]]
- func RegisterPktTickHook(h PktTickHook) HookRef[Registerd[PktTickHook]]
- func RegisterPlaceCond(h PlaceCond) HookRef[Registerd[PlaceCond]]
- func RegisterPosUpdater(pu PosUpdater) HookRef[Registerd[PosUpdater]]
- func RegisterRawPktProcessor(h RawPktProcessor) HookRef[Registerd[RawPktProcessor]]
- func RegisterRegisterHook(h RegisterHook) HookRef[Registerd[RegisterHook]]
- func RegisterSaveFileHook(h SaveFileHook) HookRef[Registerd[SaveFileHook]]
- func RegisterShutdownHook(h ShutdownHook) HookRef[Registerd[ShutdownHook]]
- func RegisterTickHook(h func()) HookRef[Registerd[TickHook]]
- type InitHook
- type IntPos
- type Inv
- type InvAction
- type InvActionDrop
- type InvActionMove
- type InvIdentifier
- type InvIdentifierCurrentPlayer
- type InvIdentifierDetached
- type InvIdentifierNodeMeta
- type InvIdentifierPlayer
- type InvIdentifierUndefined
- type InvList
- type InvLocation
- type Item
- type ItemActivateFunc
- type ItemDef
- type ItemMoveFunc
- type ItemPlaceFunc
- type ItemTextures
- type ItemType
- type ItemUseFunc
- type JoinHook
- type Leave
- type LeaveHook
- type MapBlk
- type MapDriver
- type MapGenerator
- type MapLoader
- type MultiError
- type NodeDef
- type NodeDigFunc
- type NodeDugFunc
- type NodeItem
- func (itm *NodeItem) ItemDef() mt.ItemDef
- func (itm *NodeItem) Name() string
- func (itm *NodeItem) OnActivate(c *Client, s mt.Stack, a *mt.ToSrvInteract) mt.Stack
- func (itm *NodeItem) OnMove(c *Client, s mt.Stack, a *InvAction) mt.Stack
- func (itm *NodeItem) OnPlace(c *Client, s mt.Stack, i *mt.ToSrvInteract) mt.Stack
- func (itm *NodeItem) OnUse(c *Client, s mt.Stack, a *mt.ToSrvInteract) mt.Stack
- type NodeStopDiggingFunc
- type PPos
- type PacketPre
- type PhysHook
- type PktProcessor
- type PktTickHook
- type PlaceCond
- type PlayerAOMaker
- type Pos
- type PosUpdater
- type RWInv
- type RawPktProcessor
- type Reason
- type RegisterHook
- type Registerd
- func GetDetached(name string, c *Client) (inv *Registerd[*DetachedInv], err error)
- func GetItemDef(name string) (def *Registerd[ItemDef])
- func GetMapLoader(name string) *Registerd[MapLoader]
- func GetNodeDef(name string) (def *Registerd[NodeDef])
- func GetNodeDefID(id mt.Content) (def *Registerd[NodeDef])
- type SaveFileHook
- type SerializationError
- type ServerState
- type ShutdownHook
- type SimpleInv
- type SimpleInvList
- type SoundDef
- type StrTexture
- type Texture
- type TextureOverlay
- type TickHook
- type ToolGroupCap
- type ToolItem
- func (itm *ToolItem) ItemDef() mt.ItemDef
- func (itm *ToolItem) MtGroupCaps() (s []mt.ToolGroupCap)
- func (itm *ToolItem) Name() string
- func (itm *ToolItem) OnActivate(c *Client, s mt.Stack, a *mt.ToSrvInteract) mt.Stack
- func (itm *ToolItem) OnMove(c *Client, s mt.Stack, a *InvAction) mt.Stack
- func (itm *ToolItem) OnPlace(c *Client, s mt.Stack, a *mt.ToSrvInteract) mt.Stack
- func (itm *ToolItem) OnUse(c *Client, s mt.Stack, a *mt.ToSrvInteract) mt.Stack
- type UUID
Constants ¶
const ( LowestAOID mt.AOID = (1) HighestAOID mt.AOID = (65534) // one lower than largest value )
const ( SerializeVer = 28 ProtoVer = 39 VersionString = "mtgo-5.4.1" MaxPlayerNameLen = 20 )
const AOActionTimeout time.Duration = time.Second
ao
const RelevantDistance float32 = 100 * 10 // in 10th nodes
Variables ¶
var ( ActiveObjectsMu sync.RWMutex ActiveObjects = make(map[mt.AOID]ActiveObject) )
var ( ErrInvalidLocation = errors.New("the location specified is Invalid") ErrInvalidStack = errors.New("tried to interact with invalid stack") ErrInvalidInv = errors.New("tried to interact with invalid inventory") ErrStackInsufficient = errors.New("stack quanitiy is ErrStackInsufficient") ErrStackNotEmpty = errors.New("the stack interacted with is not empty") ErrInvalidPos = errors.New("the position supplied is not parsable (e.g. not 3 dimensional)") ErrOutOfSpace = errors.New("inventory already full") ErrInvalidFormspec = errors.New("formspec is not registered") ErrClientNotReady = errors.New("client not ready") ErrClientDataNil = errors.New("client data unexpectedly nil") ErrAOTimeout = errors.New("ActiveObject timeout reached") )
var ErrClientDataInvalidType = errors.New("ClientData has invalid type!")
var ErrClientDataNotFound = errors.New("ClientData not found!")
var ErrInvalidDim = errors.New("invalid dimension")
var ErrInvalidDriver = errors.New("invalid mapdriver")
var ErrInvalidGenerator = errors.New("invalid map generator")
var (
ErrNilValue = errors.New("unexpected nil value")
)
var (
ErrServerShuttingDown = errors.New("Server shutting down")
)
var (
ErrUUIDFormat = errors.New("uuid not 16 bytes!")
)
var Loggers interface { Default(s string, depth int) Defaultf(s string, depth int, v ...any) Info(s string, depth int) Infof(s string, depth int, v ...any) Verbose(s string, depth int) Verbosef(s string, depth int, v ...any) Warn(s string, depth int) Warnf(s string, depth int, v ...any) Error(s string, depth int) Errorf(s string, depth int, v ...any) // contains filtered or unexported methods } = logLevels{}
Functions ¶
func Acks ¶
func Acks(acks ...<-chan struct{}) <-chan struct{}
Combine acks into one ack Waits for all acks to close then closes ack
func AddExpiredCondition ¶
add a function that is used to determin whether a blk can be unloaded all have to be false, to unload a blk its possible for a chunk to get unloaded without your function getting called, for a hook use `RegisterUnloadHook`
func AddMedia ¶
func AddMedia(m ...struct{ Name, Base64SHA1 string })
Add a file to the media pool pls only use while init func
func AddMediaURL ¶
func AddMediaURL(url ...string)
Add a file to the mediaURL pls only use while init func
func AddNodeDef ¶
func AddNodeDef(defs ...NodeDef)
Add more item definitions to pool Param0 field is overwritten
func AnticheatPos ¶
Check if NewPos is valid
func BroadcastAOMsgs ¶
func BroadcastAOMsgs(ao ActiveObject, msgs ...mt.AOMsg) (<-chan struct{}, error)
func BroadcastClientM ¶
BroadcastClientM broadcasts a mt.Cmd to a client slice
func BroadcastClientS ¶
BroadcastClientS broadcasts a mt.Cmd to a client slice
func ConfigVerbose ¶
func ConfigVerbose() bool
ConfigVerbose is a helper function to indicate if verbose logging is turned on
func DB_PlayerDelData ¶
PlayerDelData removes a data field
func DB_PlayerGetByUUID ¶
PlayerGetByUUID returns the name corosponding to a given UUID
func DB_PlayerGetData ¶
func DB_PlayerGetData(uuid UUID) (cd map[string]ClientData, bytes int, err error)
PlayerGetData returns all client data of a given UUID
func DB_PlayerSet ¶
PlayerPut updates a players name / adds a player
func DB_PlayerSetData ¶
PlayerSetData adds or updates some datafiled for a given UUID
func DefaultMapLoader ¶
func DefaultMapLoader() string
func Deserialize ¶
func Fields2map ¶
func Fields2map(s []mt.NodeMetaField) map[string]mt.NodeMetaField
func ForInConfig ¶
ForInConfig executes f `for k, v := range config` if any call of f results in a err != nil, err is returned
func GetConfig ¶
Returns value which is is the config field if set or d if not ok is set if the config field existed
func GetConfigV ¶
Like GetConfig but does not return ok
func GetNode ¶
GetNode returns a mt.Node and NodeMeta for a coordinate If no NodeMeta is specified returns mt.Node and nil
func Give ¶
Give adds cnt itms to inv as seen out of cs view. If InvLocation.Stack is <0 the function will try to figure out a free slot Returns the about of items added and any given error
func GroupCapsS2ToolGroupCapM ¶
func GroupCapsS2ToolGroupCapM(s []mt.ToolGroupCap) (m map[string]ToolGroupCap)
func InitClient ¶
func InitClient(c *Client)
func ListAOs ¶
func ListAOs() map[mt.AOID]ActiveObject
func ListDrivers ¶
func ListDrivers() (s []string)
func LoadBlk ¶
LoadBlk sends a blk and marks it as send only sends updates after that until client send DeletedBlks
func Map2Slice ¶
func Map2Slice[V comparable](m map[V]struct{}) []V
func MustGetConfig ¶
func NodeMetasEqual ¶
func PlayerExists ¶
func ReadString ¶
Reads space or colon speperated strings from io.Reader
func ReadUint16 ¶
Reads space speperated uint16 from io.Reader
func RealNodeName ¶
RealNodeName returns the underlying name of a given node checks aliases map if !ok returns name
func RegisterDetached ¶
func RegisterDetached(name string, inv *DetachedInv)
func RegisterMapDriver ¶
func RegisterMapGenerator ¶
func RegisterMapGenerator(name string, gen MapGenerator)
RegisterMapGenerator `gen` for `name` overwrites if allready exists
func RegisterMapLoader ¶
func RegisterPlayerMaker ¶
func RegisterPlayerMaker(name string, mk PlayerAOMaker)
func RegisterStage1 ¶
func RegisterStage1(f func())
func RegisterStage2 ¶
func RegisterStage2(f func())
func Relevant ¶
func Relevant(ao ActiveObject, clt *Client) bool
func ReloadConfig ¶
func ReloadConfig()
ReloadConfig reloads the config and triggers Config Reload hooks may break some modules
func RoundToEven32 ¶
func SetNode ¶
SetNode sets a mt.Node and NodeMeta for a coordinate If no NodeMeta is specified it WILL be overwritten
func SyncPlayerData ¶
func SyncPlayerData(c *Client)
SyncPlayerData, syncronizes all data for a given client
func TextureS2StringS ¶
Converts a Texture slice to a string slice
func TextureStr ¶
Types ¶
type AOInit ¶
func (*AOInit) AOInitData ¶
func (i *AOInit) AOInitData(id mt.AOID) mt.AOInitData
type ActiveObject ¶
type ActiveObject interface { //SetAO should set the AOID SetAO(mt.AOID) //GetAO should return the ID //0 when none is defined GetAO() mt.AOID //AOInit should return Initialisation data for the AO AOInit(*Client) *AOInit Punch(clt *Client, i *mt.ToSrvInteract) //is called when removing AO Clean() }
ActiveObject
func GetAO ¶
func GetAO(id mt.AOID) ActiveObject
type ActiveObjectAPIAOPos ¶
type ActiveObjectAPIAOPos interface { ActiveObject //GetPos should return the position GetAOPos() AOPos SetAOPos(AOPos) }
ActiveObjectAPIAOPos specifies a standard interface to work with Positions of AOs
type ActiveObjectPlayer ¶
type ActiveObjectPlayer interface { ActiveObject //GetPos should return the position GetPos() PPos SetPos(PPos) }
ActiveObjectPlayer specifies a client ActiveObject
func GetPAO ¶
func GetPAO(clt *Client) ActiveObjectPlayer
GetPAO returns the ActiveObject representing clt.
type ActiveObjectRelevant ¶
type ActiveObjectRelevant interface { ActiveObject // Tick gets called when client is evaluating relevante of AO // true: relevant and will be added; false: won't Relevant(c *Client) bool }
ActiveObjectRelevant extends the ActiveObject to optionally overwrite the Relevance functions
type ActiveObjectTicker ¶
type ActiveObjectTicker interface { ActiveObject // Tick gets called each PhysTick Tick(dtime time.Duration) }
ActiveObjectTicker extends the ActiveObject to optional Ticked callbacks
type Client ¶
type Client struct { mt.Peer sync.RWMutex UUID UUID Name string State ClientState Pos *ClientPos PosState sync.RWMutex //active Object stuffs (conains own mutex) AOData *AOData // contains filtered or unexported fields }
A Client represents a client
func PlayerByName ¶
func (*Client) GetFullPos ¶
GetFullPos returns pos of player / client
func (*Client) Kick ¶
func (c *Client) Kick(r mt.KickReason, Custom string) (ack <-chan struct{}, err error)
func (*Client) PointRange ¶
func (*Client) RegisterFormspec ¶
func (*Client) SendAnnounceMedia ¶
func (c *Client) SendAnnounceMedia()
Send (cached) AnnounceMedia to client
func (*Client) SendItemDefs ¶
Send (cached) ItemDefinitions to client
func (*Client) SendNodeDefs ¶
Send (cached) NodeDefinitions to client
func (*Client) SetMapLoader ¶
func (*Client) SetState ¶
func (c *Client) SetState(state ClientState)
func (*Client) ShowSpec ¶
name is name of registerd FormspecDef returns ErrInvalidFormspec if formspec is not registered
type ClientData ¶
type ClientData interface { }
type ClientDataSaved ¶
type ClientDataSaved struct {
// contains filtered or unexported fields
}
The raw data loaded from the Database implements ClientData
func (*ClientDataSaved) Bytes ¶
func (cd *ClientDataSaved) Bytes() (b []byte)
func (*ClientDataSaved) Desc ¶
func (cd *ClientDataSaved) Desc() string
type ClientDataSerialize ¶
type ClientDataSerialize interface { ClientData // Serialize should serialize ClientData into some kind of format // Binary is prefered as its more space efficient Serialize(w io.Writer) (err error) }
If a ClientDataSerialize is used as ClientData it will be serialized and saved in the players table
type ClientDataString ¶
type ClientDataString struct {
String string
}
func TryClientDataString ¶
func TryClientDataString(c *Client, f string) *ClientDataString
func (*ClientDataString) Desc ¶
func (cd *ClientDataString) Desc() string
type ClientState ¶
type ClientState uint8
const ( CsCreated ClientState = iota CsInit CsActive CsSudo )
type CraftItem ¶
type CraftItem struct {
Item
}
func (*CraftItem) OnActivate ¶
type Deserializer ¶
Stolen from https://github.com/anon55555/mt/blob/bcc58cb3048faa146ed0f90b330ebbe791d53b5c/zerialize.go#L26
type DetachedInv ¶
type DetachedInv struct { SimpleInv Name string // List of clients suppost to have access ClientsMu sync.RWMutex Clients map[*Client]struct{} }
func (*DetachedInv) AddClient ¶
func (di *DetachedInv) AddClient(c *Client) (<-chan struct{}, error)
func (*DetachedInv) RmClient ¶
func (di *DetachedInv) RmClient(c *Client)
func (*DetachedInv) SendUpdates ¶
func (di *DetachedInv) SendUpdates() (<-chan struct{}, error)
func (*DetachedInv) Set ¶
func (di *DetachedInv) Set(k string, v InvList)
type DimID ¶
type DimID uint16
func RegisterDim ¶
RegisterDim registers a new Dimension Id will be generated by NewDim if id == 0; returns id
type ErrInvalidInvAction ¶
type ErrInvalidInvAction struct {
Action string
}
func (*ErrInvalidInvAction) Error ¶
func (err *ErrInvalidInvAction) Error() string
type FormSpecSubmitFunc ¶
type Formspec ¶
type Formspec struct { Name string Spec string Submit FormSpecSubmitFunc }
type HookRef ¶
type HookRef[H any] struct { // contains filtered or unexported fields }
func RegisterDigCond ¶
DigCond gets called before Place is acted upon If returns false doesn't place node (NodeDef.OnDig not called) Gets called BEFORE NodeDef.OnPlace
func RegisterInitHook ¶
Gets called as soon as client authentication is successfull
func RegisterJoinHook ¶
Gets called after client is initialized After player is given controll
func RegisterLeaveHook ¶
Gets called after client has left (*Client struct still exists)
func RegisterPacketPre ¶
Gets called before packet reaches Processors If (one) func returns false packet is dropped
func RegisterPhysTickHook ¶
Gets called each tick dtime is time since last tick
func RegisterPktProcessor ¶
func RegisterPktProcessor(h PktProcessor) HookRef[Registerd[PktProcessor]]
Gets called for each packet received; as long as clt is initialized
func RegisterPktTickHook ¶
func RegisterPktTickHook(h PktTickHook) HookRef[Registerd[PktTickHook]]
Gets called at end of each tick If you can, send packets in here
func RegisterPlaceCond ¶
PlaceCond gets called before Place is acted upon If returns false doesn't place node (ItemDef.OnPlace not called) Gets called BEFORE NodeDef.OnPlace
func RegisterPosUpdater ¶
func RegisterPosUpdater(pu PosUpdater) HookRef[Registerd[PosUpdater]]
PosUpdater is called with a UNLOCKED ClientPos
func RegisterRawPktProcessor ¶
func RegisterRawPktProcessor(h RawPktProcessor) HookRef[Registerd[RawPktProcessor]]
Gets called for each packet received; even for uninitialized clients
func RegisterRegisterHook ¶
func RegisterRegisterHook(h RegisterHook) HookRef[Registerd[RegisterHook]]
Gets called at registrationtime intended to initialize client data
func RegisterSaveFileHook ¶
func RegisterSaveFileHook(h SaveFileHook) HookRef[Registerd[SaveFileHook]]
func RegisterShutdownHook ¶
func RegisterShutdownHook(h ShutdownHook) HookRef[Registerd[ShutdownHook]]
Gets called when server shuts down NOTE: (Leave hooks also get called)
func RegisterTickHook ¶
Gets called each tick
type InvAction ¶
type InvActionDrop ¶
type InvActionDrop struct { Count uint16 From *InvLocation }
func (*InvActionDrop) Apply ¶
func (act *InvActionDrop) Apply(c *Client) (_ <-chan struct{}, err error)
func (*InvActionDrop) Deserialize ¶
func (act *InvActionDrop) Deserialize(r io.Reader)
func (*InvActionDrop) InvActionVerb ¶
func (*InvActionDrop) InvActionVerb() string
func (*InvActionDrop) String ¶
func (act *InvActionDrop) String() string
type InvActionMove ¶
type InvActionMove struct { Count uint16 From *InvLocation To *InvLocation }
func (*InvActionMove) Apply ¶
func (act *InvActionMove) Apply(c *Client) (_ <-chan struct{}, err error)
func (*InvActionMove) Deserialize ¶
func (act *InvActionMove) Deserialize(r io.Reader)
func (*InvActionMove) String ¶
func (act *InvActionMove) String() string
type InvIdentifier ¶
type InvIdentifier interface { InvIdentifier() string Equals(InvIdentifier) bool }
type InvIdentifierCurrentPlayer ¶
type InvIdentifierCurrentPlayer struct{}
func (*InvIdentifierCurrentPlayer) Deserialize ¶
func (*InvIdentifierCurrentPlayer) Deserialize(io.Reader)
InvIdentifierCurrentPlayer
func (*InvIdentifierCurrentPlayer) Equals ¶
func (*InvIdentifierCurrentPlayer) Equals(i InvIdentifier) bool
func (*InvIdentifierCurrentPlayer) InvIdentifier ¶
func (*InvIdentifierCurrentPlayer) InvIdentifier() string
type InvIdentifierDetached ¶
type InvIdentifierDetached struct {
// contains filtered or unexported fields
}
InvIdentifierDetached
func (*InvIdentifierDetached) Deserialize ¶
func (i *InvIdentifierDetached) Deserialize(r io.Reader)
func (*InvIdentifierDetached) Equals ¶
func (d *InvIdentifierDetached) Equals(i InvIdentifier) bool
func (*InvIdentifierDetached) InvIdentifier ¶
func (*InvIdentifierDetached) InvIdentifier() string
type InvIdentifierNodeMeta ¶
type InvIdentifierNodeMeta struct {
X, Y, Z int16
}
InvIdentifierNodeMeta
func (*InvIdentifierNodeMeta) Deserialize ¶
func (i *InvIdentifierNodeMeta) Deserialize(r io.Reader)
func (*InvIdentifierNodeMeta) Equals ¶
func (self *InvIdentifierNodeMeta) Equals(to InvIdentifier) bool
func (*InvIdentifierNodeMeta) InvIdentifier ¶
func (*InvIdentifierNodeMeta) InvIdentifier() string
type InvIdentifierPlayer ¶
type InvIdentifierPlayer struct {
// contains filtered or unexported fields
}
InvIdentifierPlayer
func (*InvIdentifierPlayer) Deserialize ¶
func (i *InvIdentifierPlayer) Deserialize(r io.Reader)
func (*InvIdentifierPlayer) Equals ¶
func (self *InvIdentifierPlayer) Equals(to InvIdentifier) bool
func (*InvIdentifierPlayer) InvIdentifier ¶
func (*InvIdentifierPlayer) InvIdentifier() string
type InvIdentifierUndefined ¶
type InvIdentifierUndefined struct{}
InvIdentifierUndefined
func (*InvIdentifierUndefined) Deserialize ¶
func (*InvIdentifierUndefined) Deserialize(io.Reader)
func (*InvIdentifierUndefined) Equals ¶
func (*InvIdentifierUndefined) Equals(InvIdentifier) bool
undefined is like NaN not itsel
func (*InvIdentifierUndefined) InvIdentifier ¶
func (*InvIdentifierUndefined) InvIdentifier() string
type InvLocation ¶
type InvLocation struct { Identifier InvIdentifier Name string Stack int }
InvLocation
func ParseInvLocation ¶
func ParseInvLocation(str string) *InvLocation
func (*InvLocation) Deserialize ¶
func (l *InvLocation) Deserialize(r io.Reader)
func (*InvLocation) SendUpdate ¶
func (l *InvLocation) SendUpdate(list string, c *Client) (<-chan struct{}, error)
type Item ¶
type ItemActivateFunc ¶
type ItemActivateFunc func(*Client, Inv, *mt.ToSrvInteract)
type ItemDef ¶
type ItemDef interface { ItemDef() mt.ItemDef Name() string //returned mt.Stack will overwrite old OnMove(*Client, mt.Stack, *InvAction) mt.Stack OnPlace(*Client, mt.Stack, *mt.ToSrvInteract) mt.Stack OnUse(*Client, mt.Stack, *mt.ToSrvInteract) mt.Stack OnActivate(*Client, mt.Stack, *mt.ToSrvInteract) mt.Stack }
type ItemMoveFunc ¶
type ItemPlaceFunc ¶
type ItemPlaceFunc func(*Client, Inv, *mt.ToSrvInteract)
type ItemTextures ¶
type ItemUseFunc ¶
type ItemUseFunc func(*Client, Inv, *mt.ToSrvInteract)
type Leave ¶
type Leave struct { Reason mt.KickReason Custom string AbstrReason Reason Client *Client }
type MapBlk ¶
type MapBlk struct { MapBlk mt.MapBlk Pos [3]int16 Driver MapDriver sync.RWMutex ForceLoaded bool // if set the default func for cleanup block won't be unloaded Loaded time.Time // timestamp when blk was loaded (unixmillis) LastAccess time.Time // timestamp when blk was last Accessed (unixmillis) LastSeen time.Time // timestamp when client was in blk for the last time (unixmillis) LastRefresh time.Time // timestamp when blk was last manualy refreshed (unixmillis) // contains filtered or unexported fields }
func (*MapBlk) IsLoadedBy ¶
type MapGenerator ¶
type MapGenerator interface { Make(drv MapDriver, args string) MapGenerator // Generate is called with a BlkPos // Should save generated Blk into MapDriver Generate([3]int16) (*MapBlk, error) }
MapGenerator specifies the API a MapGen has to use has access to mapdriver can but should (in most cases) not set blocks its not asked to
type MultiError ¶
type MultiError struct {
Errs []error
}
func (*MultiError) Add ¶
func (merr *MultiError) Add(err error)
func (*MultiError) Error ¶
func (err *MultiError) Error() string
type NodeDef ¶
type NodeDef struct { mt.NodeDef OnDig NodeDigFunc OnStopDigging NodeStopDiggingFunc OnDug NodeDugFunc }
type NodeDigFunc ¶
type NodeDigFunc func(c *Client, i *mt.ToSrvInteract, digtime <-chan time.Duration)
type NodeDugFunc ¶
type NodeDugFunc func(c *Client, i *mt.ToSrvInteract, digtime time.Duration)
type NodeItem ¶
NodeItem specifies a item that will palce NoteItem.Places
func (*NodeItem) OnActivate ¶
type NodeStopDiggingFunc ¶
type NodeStopDiggingFunc func(c *Client, i *mt.ToSrvInteract, digtime time.Duration)
type PktProcessor ¶
type PktTickHook ¶
type PktTickHook func()
type PlayerAOMaker ¶
type PlayerAOMaker func(clt *Client, id mt.AOID) ActiveObject
func GetPlayerAOmaker ¶
func GetPlayerAOmaker(clt *Client) (PlayerAOMaker, string)
type RawPktProcessor ¶
type RegisterHook ¶
type RegisterHook func(*Client)
type Registerd ¶
type Registerd[T any] struct { Thing T // contains filtered or unexported fields }
func GetDetached ¶
func GetDetached(name string, c *Client) (inv *Registerd[*DetachedInv], err error)
func GetItemDef ¶
GetItemDef returns pointer to ItemDef if registerd
func GetMapLoader ¶
func GetNodeDef ¶
GetNodeDef returns pointer to node def if registerd otherwise nil
func GetNodeDefID ¶
GetNodeID returns pointer to node def if registerd otherwise nil
type SaveFileHook ¶
type SaveFileHook func()
type SerializationError ¶
type SerializationError struct {
// contains filtered or unexported fields
}
type ServerState ¶
type ServerState uint8
const ( StateInitializing ServerState = iota StateOnline StateShuttingDown StateOffline // only reached when saving )
func State ¶
func State() ServerState
type ShutdownHook ¶
type ShutdownHook func()
type SimpleInvList ¶
func (*SimpleInvList) InvList ¶
func (il *SimpleInvList) InvList() mt.InvList
func (*SimpleInvList) Width ¶
func (il *SimpleInvList) Width() int
type StrTexture ¶
func (StrTexture) Texture ¶
func (str StrTexture) Texture() string
type Texture ¶
type Texture interface { // should return string representation of texture Texture() string }
type TextureOverlay ¶
type TextureOverlay struct {
Textures []Texture
}
func (TextureOverlay) Texture ¶
func (o TextureOverlay) Texture() string
type ToolGroupCap ¶
func (ToolGroupCap) MtDigTimes ¶
func (caps ToolGroupCap) MtDigTimes() (s []mt.DigTime)
type ToolItem ¶
type ToolItem struct { Item AttackCooldown float32 MaxDropLvl int16 //TODO: figure out GroupCaps map[string]ToolGroupCap }
func (*ToolItem) MtGroupCaps ¶
func (itm *ToolItem) MtGroupCaps() (s []mt.ToolGroupCap)
func (*ToolItem) OnActivate ¶
Source Files
¶
- action.go
- ao.go
- ao_filter.go
- api.go
- api_ao.go
- broadcast.go
- cache.go
- client.go
- client_data.go
- client_storage.go
- config.go
- detached.go
- error.go
- formspec.go
- give.go
- hooks.go
- interact.go
- inventory.go
- items.go
- items_craftitem.go
- items_nodes.go
- items_tools.go
- itemtype_string.go
- listen.go
- loader.go
- log.go
- map.go
- math.go
- media.go
- nodes.go
- player.go
- player_ao.go
- pos.go
- process.go
- run.go
- server.go
- sound.go
- stages.go
- textures.go
- tick.go
- type.go
- types.go
- zerialize.go