Documentation
¶
Index ¶
- Constants
- Variables
- func FallbackBlock(block byte) byte
- func IsValidMessage(message string) bool
- func IsValidName(name string) bool
- func NbtMarshal(w io.Writer, name string, v interface{}) error
- func NbtUnmarshal(r io.Reader, v interface{}) error
- func RandomUUID() (uuid [16]byte)
- func WordWrap(message string, width int) (result []string)
- type AABB
- type BlockBuffer
- type BlockDefinition
- type ColorDesc
- type Command
- type CommandHandler
- type CommandSender
- type Config
- type CwBlockDefinitionMap
- type CwMetadataMap
- type CwStorage
- type Entity
- func (entity *Entity) ID() byte
- func (entity *Entity) Level() *Level
- func (entity *Entity) Location() Location
- func (entity *Entity) Name() string
- func (entity *Entity) Respawn()
- func (entity *Entity) SendListName()
- func (entity *Entity) SendModel()
- func (entity *Entity) SendProps(mask uint32)
- func (entity *Entity) Server() *Server
- func (entity *Entity) Teleport(location Location)
- func (entity *Entity) TeleportLevel(level *Level)
- type EntityProps
- type EnvConfig
- type EventBlockBreak
- type EventBlockPlace
- type EventCommand
- type EventEntityLevelChange
- type EventEntityMove
- type EventHandler
- type EventLevelLoad
- type EventLevelSave
- type EventLevelUnload
- type EventPlayerChat
- type EventPlayerClick
- type EventPlayerJoin
- type EventPlayerLogin
- type EventPlayerQuit
- type ExtEntry
- type FlatGenerator
- type Generator
- type GeneratorFunc
- type HackConfig
- type HotkeyDesc
- type LavaSimulator
- type Level
- func (level *Level) AddSimulator(simulator Simulator)
- func (level *Level) Clone(name string) *Level
- func (level *Level) DefaultEnvConfig() EnvConfig
- func (level *Level) FillLayers(yStart, yEnd int, block byte)
- func (level *Level) ForEachEntity(fn func(*Entity))
- func (level *Level) ForEachPlayer(fn func(*Player))
- func (level *Level) GetBlock(x, y, z int) byte
- func (level *Level) InBounds(x, y, z int) bool
- func (level *Level) Index(x, y, z int) int
- func (level *Level) Position(index int) (x, y, z int)
- func (level *Level) RemoveSimulator(simulator Simulator)
- func (level *Level) SendEnvConfig(mask uint32)
- func (level *Level) SendHackConfig()
- func (level *Level) SendMOTD()
- func (level *Level) Server() *Server
- func (level *Level) SetBlock(x, y, z int, block byte)
- func (level *Level) SetBlockFast(x, y, z int, block byte)
- func (level *Level) Size() int
- func (level *Level) UpdateBlock(x, y, z int)
- type LevelStorage
- type Location
- type LvlStorage
- type NullRGB
- type Player
- func (player *Player) CanExecute(command *Command) bool
- func (player *Player) CanReach(x, y, z int) bool
- func (player *Player) Disconnect()
- func (player *Player) HasExtension(extension int) bool
- func (player *Player) HeldBlock() byte
- func (player *Player) Kick(reason string)
- func (player *Player) RemoteAddr() string
- func (player *Player) ResetSelection(id byte)
- func (player *Player) SendMessage(message string)
- func (player *Player) SendMessageExt(msgType int, message string)
- func (player *Player) SendPermissions()
- func (player *Player) SetHeldBlock(block byte, lock bool)
- func (player *Player) SetSelection(id byte, label string, box AABB, color RGBA)
- func (player *Player) SetSpawn()
- type Plugin
- type RGB
- type RGBA
- type Rank
- type SandSimulator
- type Server
- func (server *Server) AddCommand(command *Command)
- func (server *Server) AddEntity(entity *Entity) bool
- func (server *Server) AddGenerator(name string, fn GeneratorFunc)
- func (server *Server) AddHandler(eventType int, handler EventHandler)
- func (server *Server) AddLevel(level *Level)
- func (server *Server) AddPlayer(player *Player)
- func (server *Server) AddPlugin(plugin Plugin)
- func (server *Server) BroadcastMessage(message string)
- func (server *Server) ExecuteCommand(sender CommandSender, message string)
- func (server *Server) FindCommand(name string) *Command
- func (server *Server) FindEntity(name string) *Entity
- func (server *Server) FindEntityByID(id byte) *Entity
- func (server *Server) FindLevel(name string) *Level
- func (server *Server) FindPlayer(name string) *Player
- func (server *Server) FireEvent(eventType int, event interface{})
- func (server *Server) ForEachCommand(fn func(*Command))
- func (server *Server) ForEachEntity(fn func(*Entity))
- func (server *Server) ForEachLevel(fn func(*Level))
- func (server *Server) ForEachPlayer(fn func(*Player))
- func (server *Server) LoadLevel(name string) (*Level, error)
- func (server *Server) NewGenerator(name string, args ...string) Generator
- func (server *Server) RemoveEntity(entity *Entity)
- func (server *Server) RemoveLevel(level *Level)
- func (server *Server) RemovePlayer(player *Player)
- func (server *Server) SaveLevel(level *Level)
- func (server *Server) Start(wg *sync.WaitGroup) (err error)
- func (server *Server) Stop()
- func (server *Server) UnloadLevel(level *Level)
- type Simulator
- type Vector3
- type WaterSimulator
Constants ¶
const ( BlockAir = 0 BlockStone = 1 BlockGrass = 2 BlockDirt = 3 BlockCobblestone = 4 BlockWood = 5 BlockSapling = 6 BlockBedrock = 7 BlockActiveWater = 8 BlockWater = 9 BlockActiveLava = 10 BlockLava = 11 BlockSand = 12 BlockGravel = 13 BlockGoldOre = 14 BlockIronOre = 15 BlockCoal = 16 BlockLog = 17 BlockLeaves = 18 BlockSponge = 19 BlockGlass = 20 BlockRed = 21 BlockOrange = 22 BlockYellow = 23 BlockLime = 24 BlockGreen = 25 BlockAqua = 26 BlockCyan = 27 BlockBlue = 28 BlockPurple = 29 BlockIndigo = 30 BlockViolet = 31 BlockMagenta = 32 BlockPink = 33 BlockBlack = 34 BlockGray = 35 BlockWhite = 36 BlockDandelion = 37 BlockRose = 38 BlockBrownShroom = 39 BlockRedShroom = 40 BlockGold = 41 BlockIron = 42 BlockDoubleSlab = 43 BlockSlab = 44 BlockBrick = 45 BlockTNT = 46 BlockBookshelf = 47 BlockMoss = 48 BlockObsidian = 49 BlockMaxClassic = BlockObsidian BlockCountClassic = BlockMaxClassic + 1 BlockCobblestoneSlab = 50 BlockRope = 51 BlockSandstone = 52 BlockSnow = 53 BlockFire = 54 BlockLightPink = 55 BlockForestGreen = 56 BlockBrown = 57 BlockDeepBlue = 58 BlockTurquoise = 59 BlockIce = 60 BlockCeramicTile = 61 BlockMagma = 62 BlockPillar = 63 BlockCrate = 64 BlockStoneBrick = 65 BlockMaxCPE = BlockStoneBrick BlockCountCPE = BlockMaxCPE + 1 BlockMax = 255 BlockCount = BlockMax + 1 )
const ( FacePosX = 0 FaceNegX = 1 FacePosY = 2 FaceNegY = 3 FacePosZ = 4 FaceNegZ = 5 )
const ( CollideModeWalk = 0 CollideModeSwim = 1 CollideModeSolid = 2 )
const ( WalkSoundNone = 0 WalkSoundWood = 1 WalkSoundGravel = 2 WalkSoundGrass = 3 WalkSoundStone = 4 WalkSoundMetal = 5 WalkSoundGlass = 6 WalkSoundWool = 7 WalkSoundSand = 8 WalkSoundSnow = 9 )
const ( BlockShapeSprite = 0 BlockShapeCube = 16 )
const ( DrawModeOpaque = 0 DrawModeGlass = 1 DrawModeLeaves = 2 DrawModeIce = 3 DrawModeGas = 4 )
const ( ColorBlack = "&0" ColorDarkBlue = "&1" ColorDarkGreen = "&2" ColorDarkAqua = "&3" ColorDarkRed = "&4" ColorDarkPurple = "&5" ColorGold = "&6" ColorGray = "&7" ColorDarkGray = "&8" ColorBlue = "&9" ColorGreen = "&a" ColorAqua = "&b" ColorRed = "&c" ColorLightPurple = "&d" ColorYellow = "&e" ColorWhite = "&f" ColorDefault = ColorWhite )
const ( KeyModNone = 0 KeyModCtrl = 1 KeyModShift = 2 KeyModAlt = 4 )
const ( MessageChat = 0 MessageStatus1 = 1 MessageStatus2 = 2 MessageStatus3 = 3 MessageBottomRight1 = 11 MessageBottomRight2 = 12 MessageBottomRight3 = 13 MessageAnnouncement = 100 )
const ( ModelChicken = "chicken" ModelCreeper = "creeper" ModelCrocodile = "croc" ModelHumanoid = "humanoid" ModelPig = "pig" ModelPrinter = "printer" ModelSheep = "sheep" ModelSkeleton = "skeleton" ModelSpider = "spider" ModelZombie = "zombie" ModelHead = "head" ModelSitting = "sitting" ModelChibi = "chibi" )
const ( EntityPropRotX = 1 << 0 EntityPropRotY = 1 << 1 EntityPropRotZ = 1 << 2 EntityPropScaleX = 1 << 3 EntityPropScaleY = 1 << 4 EntityPropScaleZ = 1 << 5 EntityPropAll = (EntityPropScaleZ << 1) - 1 )
const ( ButtonLeft = 0 ButtonRight = 1 ButtonMiddle = 2 )
const ( ButtonPress = 0 ButtonRelease = 1 )
const ( EventTypePlayerLogin = iota EventTypePlayerJoin EventTypePlayerQuit EventTypePlayerChat EventTypePlayerClick EventTypeEntityLevelChange EventTypeEntityMove EventTypeBlockPlace EventTypeBlockBreak EventTypeLevelLoad EventTypeLevelUnload EventTypeLevelSave EventTypeCommand )
const ( WeatherSunny = 0 WeatherRaining = 1 WeatherSnowing = 2 )
const ( EnvPropWeather = 1 << 0 EnvPropTexturePack = 1 << 1 EnvPropSideBlock = 1 << 2 EnvPropEdgeBlock = 1 << 3 EnvPropEdgeHeight = 1 << 4 EnvPropCloudHeight = 1 << 5 EnvPropMaxViewDistance = 1 << 6 EnvPropCloudSpeed = 1 << 7 EnvPropWeatherSpeed = 1 << 8 EnvPropWeatherFade = 1 << 9 EnvPropExpFog = 1 << 10 EnvPropSideOffset = 1 << 11 EnvPropSkyColor = 1 << 12 EnvPropCloudColor = 1 << 13 EnvPropFogColor = 1 << 14 EnvPropAmbientColor = 1 << 15 EnvPropDiffuseColor = 1 << 16 EnvPropAll = (EnvPropDiffuseColor << 1) - 1 )
const ( NbtTagEnd = 0 NbtTagByte = 1 NbtTagShort = 2 NbtTagInt = 3 NbtTagLong = 4 NbtTagFloat = 5 NbtTagDouble = 6 NbtTagByteArray = 7 NbtTagString = 8 NbtTagList = 9 NbtTagCompound = 10 NbtTagIntArray = 11 NbtTagLongArray = 12 NbtTagMax = NbtTagLongArray NbtTagCount = NbtTagMax + 1 )
const ( CpeClickDistance = iota CpeCustomBlocks CpeHeldBlock CpeTextHotKey CpeExtPlayerList CpeEnvColors CpeSelectionCuboid CpeBlockPermissions CpeChangeModel CpeEnvWeatherType CpeHackControl CpeMessageTypes CpePlayerClick CpeLongerMessages CpeBlockDefinitions CpeBlockDefinitionsExt CpeBulkBlockUpdate CpeTextColors CpeEnvMapAspect CpeEntityProperty CpeExtEntityPositions CpeTwoWayPing CpeInventoryOrder CpeInstantMOTD CpeFastMap CpeExtendedTextures CpeMax = CpeExtendedTextures CpeCount = CpeMax + 1 )
const ( ServerSoftware = "go-mcc" UpdateInterval = 50 * time.Millisecond HeartbeatInterval = 45 * time.Second SaveInterval = 5 * time.Minute )
Variables ¶
var BlockName = [BlockCountCPE]string{
"air", "stone", "grass", "dirt", "cobblestone", "wood", "sapling",
"bedrock", "active_water", "water", "active_lava", "lava", "sand",
"gravel", "gold_ore", "iron_ore", "coal", "log", "leaves", "sponge",
"glass", "red", "orange", "yellow", "lime", "green", "aqua", "cyan",
"blue", "purple", "indigo", "violet", "magenta", "pink", "black",
"gray", "white", "dandelion", "rose", "brown_shroom", "red_shroom",
"gold", "iron", "doubleslab", "slab", "brick", "tnt", "bookshelf",
"moss", "obsidian", "cobblestone_slab", "rope", "sandstone", "snow",
"fire", "light_pink", "forest_green", "brown", "deep_blue", "turquoise",
"ice", "ceramic_tile", "magma", "pillar", "crate", "stone_brick",
}
var DefaultRank = func() (rank Rank) { for i := 0; i < BlockCount; i++ { rank.CanPlace[i] = true rank.CanBreak[i] = true } banned := []byte{BlockBedrock, BlockActiveWater, BlockWater, BlockActiveLava, BlockLava} for _, block := range banned { rank.CanPlace[block] = false } rank.CanBreak[BlockBedrock] = false return }()
DefaultRank stores the default player permissions.
var Extensions = [CpeCount]ExtEntry{
{"ClickDistance", 1},
{"CustomBlocks", 1},
{"HeldBlock", 1},
{"TextHotKey", 1},
{"ExtPlayerList", 2},
{"EnvColors", 1},
{"SelectionCuboid", 1},
{"BlockPermissions", 1},
{"ChangeModel", 1},
{"EnvWeatherType", 1},
{"HackControl", 1},
{"MessageTypes", 1},
{"PlayerClick", 1},
{"LongerMessages", 1},
{"BlockDefinitions", 1},
{"BlockDefinitionsExt", 2},
{"BulkBlockUpdate", 1},
{"TextColors", 1},
{"EnvMapAspect", 1},
{"EntityProperty", 1},
{"ExtEntityPositions", 1},
{"TwoWayPing", 1},
{"InventoryOrder", 1},
{"InstantMOTD", 1},
{"FastMap", 1},
{"ExtendedTextures", 1},
}
Functions ¶
func FallbackBlock ¶
FallbackBlock converts a CPE block to a similar vanilla-compatible one.
func IsValidMessage ¶
IsValidMessage reports whether message is a valid chat message.
func IsValidName ¶
IsValidName reports whether name is a valid entity name.
func NbtMarshal ¶
NbtMarshal writes the NBT representation of v into w. name specifies the name of the root tag.
func NbtUnmarshal ¶
NbtUnmarshal reads NBT data from r into v.
Types ¶
type BlockBuffer ¶
type BlockBuffer struct {
// contains filtered or unexported fields
}
BlockBuffer is a queue of block changes to apply to a level.
func NewBlockBuffer ¶
func NewBlockBuffer(level *Level) *BlockBuffer
NewBlockBuffer returns a new BlockBuffer to queue changes to level.
func (*BlockBuffer) Flush ¶
func (buffer *BlockBuffer) Flush()
Flush flushes any pending changes to the underlying level.
func (*BlockBuffer) Set ¶
func (buffer *BlockBuffer) Set(x, y, z int, block byte)
Set sets the block at the specified coordinates.
type BlockDefinition ¶
type BlockDefinition struct { Name string Fallback byte Speed float64 CollideMode byte WalkSound byte BlockLight bool FullBright bool DrawMode byte Textures [6]int Shape byte AABB AABB FogDensity byte Fog RGB }
BlockDefinition describes a custom block.
type Command ¶
type Command struct { Name string Description string Usage string Permissions uint32 Handler CommandHandler }
Command describes a command.
func (*Command) PrintUsage ¶
func (command *Command) PrintUsage(sender CommandSender)
PrintUsage sends the command usage message to sender.
type CommandHandler ¶
type CommandHandler func(sender CommandSender, command *Command, message string)
CommandHandler is the type of the function called to execute a command. The sender argument is the entity that invoked the command. The message argument contains the arguments of the command.
type CommandSender ¶
type CommandSender interface { Server() *Server Name() string SendMessage(message string) CanExecute(command *Command) bool }
A CommandSender is a generic entity that can execute commands and receive messages.
type Config ¶
type Config struct { Port int `json:"server-port"` Name string `json:"server-name"` MOTD string `json:"motd"` Verify bool `json:"verify-names"` Public bool `json:"public"` MaxPlayers int `json:"max-players"` Heartbeat string `json:"heartbeat,omitempty"` MainLevel string `json:"main-level"` }
Config is used to configure a server.
type CwBlockDefinitionMap ¶
type CwBlockDefinitionMap map[string]cwBlockDefinition
type CwMetadataMap ¶
type CwMetadataMap map[string]interface{}
type CwStorage ¶
type CwStorage struct { // FixSpawnPosition controls whether to attempt to parse the spawn // position as block coordinates. This format is incorrectly used by // some client software. FixSpawnPosition bool // contains filtered or unexported fields }
CwStorage is an implementation of the LevelStorage interface that can handle ClassicWorld (.cw) levels.
func NewCwStorage ¶
NewCwStorage creates a new CwStorage that uses dirPath as the working directory.
type Entity ¶
type Entity struct { Model string Props EntityProps DisplayName string SkinName string ListName string GroupName string GroupRank byte // contains filtered or unexported fields }
Entity represents a base entity.
func (*Entity) Respawn ¶
func (entity *Entity) Respawn()
Respawn respawns the entity to all relevant players.
func (*Entity) SendListName ¶
func (entity *Entity) SendListName()
SendListName sends the tab list name of the entity to all relevant players.
func (*Entity) SendModel ¶
func (entity *Entity) SendModel()
SendModel sends the model of the entity to all relevant players.
func (*Entity) SendProps ¶
SendProps sends the EntityProps of the entity to all relevant players. mask controls which properties are sent.
func (*Entity) TeleportLevel ¶
TeleportLevel teleports the entity to the spawn location of level.
type EntityProps ¶
EntityProps holds various entity properties.
type EnvConfig ¶
type EnvConfig struct { Weather byte TexturePack string SideBlock byte EdgeBlock byte EdgeHeight int CloudHeight int MaxViewDistance int CloudSpeed float64 WeatherSpeed float64 WeatherFade float64 ExpFog bool SideOffset int SkyColor NullRGB CloudColor NullRGB FogColor NullRGB AmbientColor NullRGB DiffuseColor NullRGB }
EnvConfig specifies the appearance of a level.
type EventBlockBreak ¶
EventBlockBreak is dispatched when a player breaks a block. If the event is cancelled, the block will not be broken.
type EventBlockPlace ¶
type EventBlockPlace struct { Player *Player Level *Level Block byte OldBlock byte X, Y, Z int Cancel bool }
EventBlockPlace is dispatched when a player places a block. If the event is cancelled, the block will not be placed.
type EventCommand ¶
type EventCommand struct { Sender CommandSender Command *Command Message string Allow bool }
EventCommand is dispatched before a command is executed.
type EventEntityLevelChange ¶
EventEntityLevelChange is dispatched when an entity changes level.
type EventEntityMove ¶
EventEntityMove is dispatched when an entity moves. If the event is cancelled, the entity will not move.
type EventHandler ¶
type EventHandler func(eventType int, event interface{})
EventHandler is the type of the function called to handle an event.
type EventLevelLoad ¶
type EventLevelLoad struct {
Level *Level
}
EventLevelLoad is dispatched when a level is loaded.
type EventLevelSave ¶
type EventLevelSave struct {
Level *Level
}
EventLevelSave is dispatched when a level is saved.
type EventLevelUnload ¶
type EventLevelUnload struct {
Level *Level
}
EventLevelUnload is dispatched when a level is unloaded.
type EventPlayerChat ¶
type EventPlayerChat struct { Player *Player Targets []*Player Message string Format string Cancel bool }
EventPlayerChat is dispatched when a player sends a message. If the event is cancelled, the message will not be sent.
type EventPlayerClick ¶
type EventPlayerClick struct { Player *Player Button, Action byte Yaw, Pitch float64 Target *Entity BlockX, BlockY, BlockZ int BlockFace byte }
EventPlayerClick is dispatched when a player makes a mouse click. If the player is currently targeting another entity, Target will be set. If the player is currently targeting a block, BlockX, BlockY, BlockZ, BlockFace will be set.
type EventPlayerJoin ¶
type EventPlayerJoin struct {
Player *Player
}
EventPlayerJoin is dispatched when a player joins the server.
type EventPlayerLogin ¶
EventPlayerLogin is dispatched when a player attempts to log in. If the event is cancelled, the player will be kicked.
type EventPlayerQuit ¶
type EventPlayerQuit struct {
Player *Player
}
EventPlayerQuit is dispatched when a player leaves the server.
type FlatGenerator ¶
FlatGenerator is an implementation of the Generator interface that can generate flat grass levels.
func (*FlatGenerator) Generate ¶
func (generator *FlatGenerator) Generate(level *Level)
Generate implements Generator.
type Generator ¶
type Generator interface {
Generate(level *Level)
}
Generator is the interface that must be implemented by level generators.
func NewFlatGenerator ¶
type GeneratorFunc ¶
GeneratorFunc is the type of function called to create a new generator.
type HackConfig ¶
type HackConfig struct { ReachDistance float64 Flying bool NoClip bool Speeding bool SpawnControl bool ThirdPersonView bool JumpHeight float64 }
HackConfig holds configuration for client hacks/cheats.
type HotkeyDesc ¶
HotKeyDesc describes a text hotkey.
type LavaSimulator ¶
type LavaSimulator struct { Level *Level // contains filtered or unexported fields }
LavaSimulator is an implementation of the Simulator interface that handles lava physics.
func (*LavaSimulator) Update ¶
func (simulator *LavaSimulator) Update(block, old byte, index int)
Update implements Simulator.
type Level ¶
type Level struct { Width int Height int Length int Blocks []byte Dirty bool Name string UUID [16]byte TimeCreated time.Time MOTD string Spawn Location EnvConfig EnvConfig HackConfig HackConfig BlockDefs []*BlockDefinition Inventory []byte Metadata, MetadataCPE map[string]interface{} // contains filtered or unexported fields }
Level represents a level, which contains blocks and various metadata.
func (*Level) AddSimulator ¶
AddSimulator registers a physics simulator.
func (*Level) DefaultEnvConfig ¶
DefaultEnvConfig returns the default EnvConfig for this level.
func (*Level) FillLayers ¶
FillLayers fills the specified range of layers with block.
func (*Level) ForEachEntity ¶
ForEachEntity calls fn for each entity in the level.
func (*Level) ForEachPlayer ¶
ForEachPlayer calls fn for each player in the level.
func (*Level) InBounds ¶
InBounds reports whether the specified coordinates are within the bounds of the level.
func (*Level) RemoveSimulator ¶
RemoveSimulator unregisters a physics simulator.
func (*Level) SendEnvConfig ¶
SendEnvConfig sends the EnvConfig of the level to all relevant players. mask controls which properties are sent.
func (*Level) SendHackConfig ¶
func (level *Level) SendHackConfig()
SendHackConfig sends the HackConfig of the level to all relevant players.
func (*Level) SendMOTD ¶
func (level *Level) SendMOTD()
SendMOTD sends the MOTD of the level to all relevant players.
func (*Level) SetBlockFast ¶
SetBlockFast sets the block at the specified coordinates without notifying the physics simulators.
func (*Level) UpdateBlock ¶
UpdateBlock updates the block at the specified coordinates.
type LevelStorage ¶
LevelStorage is the interface that must be implemented by storage backends that can import and export levels.
type Location ¶
type Location struct {
X, Y, Z, Yaw, Pitch float64
}
Location represents the location of an entity in a world. Yaw and Pitch are specified in degrees.
type LvlStorage ¶
type LvlStorage struct {
// contains filtered or unexported fields
}
LvlStorage is an implementation of the LevelStorage interface that can handle MCSharp (.lvl) levels.
func NewLvlStorage ¶
func NewLvlStorage(dirPath string) *LvlStorage
NewLvlStorage creates a new LvlStorage that uses dirPath as the working directory.
func (*LvlStorage) Load ¶
func (storage *LvlStorage) Load(name string) (level *Level, err error)
Load implements LevelStorage.
func (*LvlStorage) Save ¶
func (storage *LvlStorage) Save(level *Level) (err error)
Save implements LevelStorage.
type Player ¶
Player represents a game client.
func (*Player) CanExecute ¶
CanExecute implements CommandSender.
func (*Player) CanReach ¶
CanReach reports whether the player can reach the block at the specified coordinates.
func (*Player) Disconnect ¶
func (player *Player) Disconnect()
Disconnect closes the remote connection.
func (*Player) HasExtension ¶
HasExtension reports whether the player has the specified CPE extension.
func (*Player) HeldBlock ¶
HeldBlock returns the block that the player is holding. If the player does not support the HeldBlock extension, the function returns BlockAir.
func (*Player) RemoteAddr ¶
RemoteAddr returns the remote network address as a string.
func (*Player) ResetSelection ¶
ResetSelection resets the selection with the specified ID.
func (*Player) SendMessage ¶
SendMessage sends a message to the player.
func (*Player) SendMessageExt ¶
SendMessageExt sends a message with the specified type to the player.
func (*Player) SendPermissions ¶
func (player *Player) SendPermissions()
SendPermissions sends the block permissions to the player.
func (*Player) SetHeldBlock ¶
SetHeldBlock changes the block that the player is holding. lock controls whether the player can change the held block.
func (*Player) SetSelection ¶
SetSelection marks a cuboid selection.
type Rank ¶
type Rank struct { Name string Tag string Permissions uint32 Rules map[string]bool CanPlace [BlockCount]bool CanBreak [BlockCount]bool }
Rank represents a group of players that have the same permissions.
func (*Rank) CanExecute ¶
CanExecute returns whether the members of the rank can execute command.
type SandSimulator ¶
type SandSimulator struct {
Level *Level
}
SandSimulator is an implementation of the Simulator interface that handles falling block physics.
func (*SandSimulator) Update ¶
func (simulator *SandSimulator) Update(block, old byte, index int)
Update implements Simulator.
type Server ¶
type Server struct { Config *Config MainLevel *Level URL string Colors []ColorDesc Hotkeys []HotkeyDesc // contains filtered or unexported fields }
Server represents a game server.
func NewServer ¶
func NewServer(config *Config, storage LevelStorage) *Server
NewServer returns a new Server.
func (*Server) AddCommand ¶
AddCommand registers the specified command.
func (*Server) AddEntity ¶
AddEntity adds entity to the server. It returns true on success, or false if the server is full.
func (*Server) AddGenerator ¶
func (server *Server) AddGenerator(name string, fn GeneratorFunc)
AddGenerator registers a level generator.
func (*Server) AddHandler ¶
func (server *Server) AddHandler(eventType int, handler EventHandler)
AddHandler registers a handler for the specified event type.
func (*Server) BroadcastMessage ¶
BroadcastMessage broadcasts a message to all players.
func (*Server) ExecuteCommand ¶
func (server *Server) ExecuteCommand(sender CommandSender, message string)
ExecuteCommand executes the command specified by message, if it exists.
func (*Server) FindCommand ¶
Findcommand returns the command with the specified name.
func (*Server) FindEntity ¶
FindEntity returns the entity with the specified name.
func (*Server) FindEntityByID ¶
FindEntityByID returns the entity with the specified ID.
func (*Server) FindPlayer ¶
FindPlayer returns the player with the specified name.
func (*Server) ForEachCommand ¶
ForEachCommand calls fn for each command.
func (*Server) ForEachEntity ¶
ForEachEntity calls fn for each entity.
func (*Server) ForEachLevel ¶
ForEachLevel calls fn for each level.
func (*Server) ForEachPlayer ¶
ForEachPlayer calls fn for each player.
func (*Server) NewGenerator ¶
NewGenerator returns a new generator with the specified options.
func (*Server) RemoveEntity ¶
RemoveEntity removes entity from the server.
func (*Server) RemoveLevel ¶
RemoveLevel removes level from the server. All players in level will be moved to the main level.
func (*Server) RemovePlayer ¶
RemovePlayer removes player from the server.
func (*Server) Stop ¶
func (server *Server) Stop()
Stop stops the server, disconnects all clients, disables all plugins and unloads all levels.
func (*Server) UnloadLevel ¶
UnloadLevel saves and removes level from the server. All players in level will be moved to the main level.
type Simulator ¶
Simulator is the interface that must be implemented by block-based physics simulators.
type Vector3 ¶
type Vector3 struct {
X, Y, Z int
}
Vector3 represents a three-dimensional integer vector.
type WaterSimulator ¶
type WaterSimulator struct { Level *Level // contains filtered or unexported fields }
WaterSimulator is an implementation of the Simulator interface that handles water and sponge physics.
func (*WaterSimulator) Update ¶
func (simulator *WaterSimulator) Update(block, old byte, index int)
Update implements Simulator.