Documentation
¶
Index ¶
- type Handler
- type NopHandler
- func (NopHandler) HandleAttackEntity(*event.Context, world.Entity)
- func (NopHandler) HandleBlockBreak(*event.Context, world.BlockPos)
- func (NopHandler) HandleBlockPlace(*event.Context, world.BlockPos, world.Block)
- func (NopHandler) HandleChat(*event.Context, *string)
- func (NopHandler) HandleCommandExecution(*event.Context, cmd.Command, []string)
- func (NopHandler) HandleDeath(damage.Source)
- func (NopHandler) HandleFoodLoss(*event.Context, int, int)
- func (NopHandler) HandleHeal(*event.Context, *float64, healing.Source)
- func (NopHandler) HandleHurt(*event.Context, *float64, damage.Source)
- func (NopHandler) HandleItemDamage(*event.Context, item.Stack, int)
- func (NopHandler) HandleItemPickup(*event.Context, item.Stack)
- func (NopHandler) HandleItemUse(*event.Context)
- func (NopHandler) HandleItemUseOnBlock(*event.Context, world.BlockPos, world.Face, mgl64.Vec3)
- func (NopHandler) HandleItemUseOnEntity(*event.Context, world.Entity)
- func (NopHandler) HandleMove(*event.Context, mgl64.Vec3, float64, float64)
- func (NopHandler) HandleQuit()
- func (NopHandler) HandleRespawn(*mgl64.Vec3)
- func (NopHandler) HandleStartBreak(*event.Context, world.BlockPos)
- func (NopHandler) HandleTeleport(*event.Context, mgl64.Vec3)
- func (NopHandler) HandleTransfer(*event.Context, *net.UDPAddr)
- type Player
- func (p *Player) AABB() physics.AABB
- func (p *Player) AbortBreaking()
- func (p *Player) AddEffect(e entity.Effect)
- func (p *Player) AddFood(points int)
- func (p *Player) Armour() item.ArmourContainer
- func (p *Player) AttackEntity(e world.Entity)
- func (p *Player) AttackImmune() bool
- func (p *Player) BreakBlock(pos world.BlockPos)
- func (p *Player) Chat(msg ...interface{})
- func (p *Player) Close() error
- func (p *Player) Collect(s item.Stack) (n int)
- func (p *Player) ContinueBreaking(face world.Face)
- func (p *Player) Dead() bool
- func (p *Player) Disconnect(msg ...interface{})
- func (p *Player) Effects() []entity.Effect
- func (p *Player) ExecuteCommand(commandLine string)
- func (p *Player) Exhaust(points float64)
- func (p *Player) EyeHeight() float64
- func (p *Player) Facing() world.Direction
- func (p *Player) FinishBreaking()
- func (p *Player) Food() int
- func (p *Player) GameMode() gamemode.GameMode
- func (p *Player) Handle(h Handler)
- func (p *Player) Heal(health float64, source healing.Source)
- func (p *Player) Health() float64
- func (p *Player) HeldItems() (mainHand, offHand item.Stack)
- func (p *Player) HideCoordinates()
- func (p *Player) Hurt(dmg float64, source damage.Source)
- func (p *Player) Inventory() *inventory.Inventory
- func (p *Player) KnockBack(src mgl64.Vec3, force, height float64)
- func (p *Player) MaxHealth() float64
- func (p *Player) Message(a ...interface{})
- func (p *Player) Move(deltaPos mgl64.Vec3)
- func (p *Player) Name() string
- func (p *Player) OnGround() bool
- func (p *Player) OpenBlockContainer(pos world.BlockPos)
- func (p *Player) Ping() time.Duration
- func (p *Player) Pitch() float64
- func (p *Player) PlaceBlock(pos world.BlockPos, b world.Block, ctx *item.UseContext)
- func (p *Player) Position() mgl64.Vec3
- func (p *Player) RemoveBossBar()
- func (p *Player) RemoveEffect(e entity.Effect)
- func (p *Player) RemoveScoreboard()
- func (p *Player) Respawn()
- func (p *Player) Rotate(deltaYaw, deltaPitch float64)
- func (p *Player) Saturate(food int, saturation float64)
- func (p *Player) SendBossBar(bar bossbar.BossBar)
- func (p *Player) SendCommandOutput(output *cmd.Output)
- func (p *Player) SendForm(f form.Form)
- func (p *Player) SendPopup(a ...interface{})
- func (p *Player) SendScoreboard(scoreboard *scoreboard.Scoreboard)
- func (p *Player) SendTip(a ...interface{})
- func (p *Player) SendTitle(t title.Title)
- func (p *Player) SetAbsorption(health float64)
- func (p *Player) SetFood(level int)
- func (p *Player) SetGameMode(mode gamemode.GameMode)
- func (p *Player) SetHeldItems(mainHand, offHand item.Stack)
- func (p *Player) SetInvisible()
- func (p *Player) SetMaxHealth(health float64)
- func (p *Player) SetNameTag(name string)
- func (p *Player) SetSpeed(speed float64)
- func (p *Player) SetVelocity(v mgl64.Vec3)
- func (p *Player) SetVisible()
- func (p *Player) ShowCoordinates()
- func (p *Player) Skin() skin.Skin
- func (p *Player) Sneaking() bool
- func (p *Player) Speed() float64
- func (p *Player) Sprinting() bool
- func (p *Player) StartBreaking(pos world.BlockPos)
- func (p *Player) StartSneaking()
- func (p *Player) StartSprinting()
- func (p *Player) StartSwimming()
- func (p *Player) State() (s []state.State)
- func (p *Player) StopSneaking()
- func (p *Player) StopSprinting()
- func (p *Player) StopSwimming()
- func (p *Player) Swimming() bool
- func (p *Player) Teleport(pos mgl64.Vec3)
- func (p *Player) Tick(current int64)
- func (p *Player) Transfer(address string) (err error)
- func (p *Player) UUID() uuid.UUID
- func (p *Player) UseItem()
- func (p *Player) UseItemOnBlock(pos world.BlockPos, face world.Face, clickPos mgl64.Vec3)
- func (p *Player) UseItemOnEntity(e world.Entity)
- func (p *Player) Velocity() mgl64.Vec3
- func (p *Player) World() *world.World
- func (p *Player) XUID() string
- func (p *Player) Yaw() float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface {
// HandleMove handles the movement of a player. ctx.Cancel() may be called to cancel the movement event.
// The new position, yaw and pitch are passed.
HandleMove(ctx *event.Context, newPos mgl64.Vec3, newYaw, newPitch float64)
// HandleTeleport handles the teleportation of a player. ctx.Cancel() may be called to cancel it.
HandleTeleport(ctx *event.Context, pos mgl64.Vec3)
// HandleChat handles a message sent in the chat by a player. ctx.Cancel() may be called to cancel the
// message being sent in chat.
// The message may be changed by assigning to *message.
HandleChat(ctx *event.Context, message *string)
// HandleFoodLoss handles the food bar of a player depleting naturally, for example because the player was
// sprinting and jumping. ctx.Cancel() may be called to cancel the food points being lost.
HandleFoodLoss(ctx *event.Context, from, to int)
// HandleHeal handles the player being healed by a healing source. ctx.Cancel() may be called to cancel
// the healing.
// The health added may be changed by assigning to *health.
HandleHeal(ctx *event.Context, health *float64, src healing.Source)
// HandleHurt handles the player being hurt by any damage source. ctx.Cancel() may be called to cancel the
// damage being dealt to the player.
// The damage dealt to the player may be changed by assigning to *damage.
HandleHurt(ctx *event.Context, damage *float64, src damage.Source)
// HandleDeath handles the player dying to a particular damage cause.
HandleDeath(src damage.Source)
// HandleRespawn handles the respawning of the player in the world. The spawn position passed may be
// changed by assigning to *pos.
HandleRespawn(pos *mgl64.Vec3)
// HandleStartBreak handles the player starting to break a block at the position passed. ctx.Cancel() may
// be called to stop the player from breaking the block completely.
HandleStartBreak(ctx *event.Context, pos world.BlockPos)
// HandleBlockBreak handles a block that is being broken by a player. ctx.Cancel() may be called to cancel
// the block being broken.
HandleBlockBreak(ctx *event.Context, pos world.BlockPos)
// HandleBlockPlace handles the player placing a specific block at a position in its world. ctx.Cancel()
// may be called to cancel the block being placed.
HandleBlockPlace(ctx *event.Context, pos world.BlockPos, b world.Block)
// HandleItemUse handles the player using an item in the air. It is called for each item, although most
// will not actually do anything. Items such as snowballs may be thrown if HandleItemUse does not cancel
// the context using ctx.Cancel(). It is not called if the player is holding no item.
HandleItemUse(ctx *event.Context)
// HandleItemUseOnBlock handles the player using the item held in its main hand on a block at the block
// position passed. The face of the block clicked is also passed, along with the relative click position.
// The click position has X, Y and Z values which are all in the range 0.0-1.0. It is also called if the
// player is holding no item.
HandleItemUseOnBlock(ctx *event.Context, pos world.BlockPos, face world.Face, clickPos mgl64.Vec3)
// HandleItemUseOnEntity handles the player using the item held in its main hand on an entity passed to
// the method.
// HandleItemUseOnEntity is always called when a player uses an item on an entity, regardless of whether
// the item actually does anything when used on an entity. It is also called if the player is holding no
// item.
HandleItemUseOnEntity(ctx *event.Context, e world.Entity)
// HandleAttackEntity handles the player attacking an entity using the item held in its hand. ctx.Cancel()
// may be called to cancel the attack, which will cancel damage dealt to the target and will stop the
// entity from being knocked back.
// The entity attacked may not be alive (implements entity.Living), in which case no damage will be dealt
// and the target won't be knocked back.
// The entity attacked may also be immune when this method is called, in which case no damage and knock-
// back will be dealt.
HandleAttackEntity(ctx *event.Context, e world.Entity)
// HandleItemDamage handles the event wherein the item either held by the player or as armour takes
// damage through usage.
// The type of the item may be checked to determine whether it was armour or a tool used. The damage to
// the item is passed.
HandleItemDamage(ctx *event.Context, i item.Stack, damage int)
// HandleItemPickup handles the player picking up an item from the ground. The item stack laying on the
// ground is passed. ctx.Cancel() may be called to prevent the player from picking up the item.
HandleItemPickup(ctx *event.Context, i item.Stack)
// HandleTransfer handles a player being transferred to another server. ctx.Cancel() may be called to
// cancel the transfer.
HandleTransfer(ctx *event.Context, addr *net.UDPAddr)
// HandleCommandExecution handles the command execution of a player, who wrote a command in the chat.
// ctx.Cancel() may be called to cancel the command execution.
HandleCommandExecution(ctx *event.Context, command cmd.Command, args []string)
// HandleQuit handles the closing of a player. It is always called when the player is disconnected,
// regardless of the reason.
HandleQuit()
}
Handler handles events that are called by a player. Implementations of Handler may be used to listen to specific events such as when a player chats or moves.
type NopHandler ¶
type NopHandler struct{}
NopHandler implements the Handler interface but does not execute any code when an event is called. The default handler of players is set to NopHandler. Users may embed NopHandler to avoid having to implement each method.
func (NopHandler) HandleAttackEntity ¶
func (NopHandler) HandleAttackEntity(*event.Context, world.Entity)
HandleAttackEntity ...
func (NopHandler) HandleBlockBreak ¶
func (NopHandler) HandleBlockBreak(*event.Context, world.BlockPos)
HandleBlockBreak ...
func (NopHandler) HandleBlockPlace ¶
HandleBlockPlace ...
func (NopHandler) HandleCommandExecution ¶
HandleCommandExecution ...
func (NopHandler) HandleFoodLoss ¶ added in v0.0.2
func (NopHandler) HandleFoodLoss(*event.Context, int, int)
HandleFoodLoss ...
func (NopHandler) HandleHeal ¶ added in v0.0.2
HandleHeal ...
func (NopHandler) HandleHurt ¶
HandleHurt ...
func (NopHandler) HandleItemDamage ¶
HandleItemDamage ...
func (NopHandler) HandleItemPickup ¶
func (NopHandler) HandleItemPickup(*event.Context, item.Stack)
HandleItemPickup ...
func (NopHandler) HandleItemUseOnBlock ¶
HandleItemUseOnBlock ...
func (NopHandler) HandleItemUseOnEntity ¶
func (NopHandler) HandleItemUseOnEntity(*event.Context, world.Entity)
HandleItemUseOnEntity ...
func (NopHandler) HandleMove ¶
HandleMove ...
func (NopHandler) HandleStartBreak ¶
func (NopHandler) HandleStartBreak(*event.Context, world.BlockPos)
HandleStartBreak ...
func (NopHandler) HandleTeleport ¶
func (NopHandler) HandleTeleport(*event.Context, mgl64.Vec3)
HandleTeleport ...
func (NopHandler) HandleTransfer ¶
func (NopHandler) HandleTransfer(*event.Context, *net.UDPAddr)
HandleTransfer ...
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player is an implementation of a player entity. It has methods that implement the behaviour that players need to play in the world.
func New ¶
New returns a new initialised player. A random UUID is generated for the player, so that it may be identified over network.
func NewWithSession ¶
func NewWithSession(name, xuid string, uuid uuid.UUID, skin skin.Skin, s *session.Session, pos mgl64.Vec3) *Player
NewWithSession returns a new player for a network session, so that the network session can control the player. A set of additional fields must be provided to initialise the player with the client's data, such as the name and the skin of the player.
func (*Player) AbortBreaking ¶
func (p *Player) AbortBreaking()
AbortBreaking makes the player stop breaking the block it is currently breaking, or returns immediately if the player isn't breaking anything. Unlike FinishBreaking, AbortBreaking does not stop the animation.
func (*Player) AddEffect ¶ added in v0.0.2
AddEffect adds an entity.Effect to the Player. If the effect is instant, it is applied to the Player immediately. If not, the effect is applied to the player every time the Tick method is called. AddEffect will overwrite any effects present if the level of the effect is higher than the existing one, or if the effects' levels are equal and the new effect has a longer duration.
func (*Player) AddFood ¶ added in v0.0.2
AddFood adds a number of points to the food level of the player. If the new food level is negative or if it exceeds 20, it will be set to 0 or 20 respectively.
func (*Player) Armour ¶
func (p *Player) Armour() item.ArmourContainer
Armour returns the armour inventory of the player. This inventory yields 4 slots, for the helmet, chestplate, leggings and boots respectively.
func (*Player) AttackEntity ¶
AttackEntity uses the item held in the main hand of the player to attack the entity passed, provided it is within range of the player. The damage dealt to the entity will depend on the item held by the player and any effects the player may have. If the player cannot reach the entity at its position, the method returns immediately.
func (*Player) AttackImmune ¶
AttackImmune checks if the player is currently immune to entity attacks, meaning it was recently attacked.
func (*Player) BreakBlock ¶
BreakBlock makes the player break a block in the world at a position passed. If the player is unable to reach the block passed, the method returns immediately.
func (*Player) Chat ¶
func (p *Player) Chat(msg ...interface{})
Chat writes a message in the global chat (chat.Global). The message is prefixed with the name of the player and is formatted following the rules of fmt.Sprintln.
func (*Player) Close ¶
Close closes the player and removes it from the world. Close disconnects the player with a 'Connection closed.' message. Disconnect should be used to disconnect a player with a custom message.
func (*Player) Collect ¶
Collect makes the player collect the item stack passed, adding it to the inventory.
func (*Player) ContinueBreaking ¶
ContinueBreaking makes the player continue breaking the block it started breaking after a call to Player.StartBreaking(). The face passed is used to display particles on the side of the block broken.
func (*Player) Dead ¶
Dead checks if the player is considered dead. True is returned if the health of the player is equal to or lower than 0.
func (*Player) Disconnect ¶
func (p *Player) Disconnect(msg ...interface{})
Disconnect closes the player and removes it from the world. Disconnect, unlike Close, allows a custom message to be passed to show to the player when it is disconnected. The message is formatted following the rules of fmt.Sprintln without a newline at the end.
func (*Player) Effects ¶ added in v0.0.2
Effects returns any effect currently applied to the entity. The returned effects are guaranteed not to have expired when returned.
func (*Player) ExecuteCommand ¶
ExecuteCommand executes a command passed as the player. If the command could not be found, or if the usage was incorrect, an error message is sent to the player.
func (*Player) Exhaust ¶ added in v0.0.2
Exhaust exhausts the player by the amount of points passed if the player is in survival mode. If the total exhaustion level exceeds 4, a saturation point, or food point, if saturation is 0, will be subtracted.
func (*Player) FinishBreaking ¶
func (p *Player) FinishBreaking()
FinishBreaking makes the player finish breaking the block it is currently breaking, or returns immediately if the player isn't breaking anything. FinishBreaking will stop the animation and break the block.
func (*Player) Food ¶ added in v0.0.2
Food returns the current food level of a player. The level returned is guaranteed to always be between 0 and 20. Every half drumstick is one level.
func (*Player) GameMode ¶
GameMode returns the current game mode assigned to the player. If not changed, the game mode returned will be the same as that of the world that the player spawns in. The game mode may be changed using Player.SetGameMode().
func (*Player) Handle ¶
Handle changes the current handler of the player. As a result, events called by the player will call handlers of the Handler passed. Handle sets the player's handler to NopHandler if nil is passed.
func (*Player) Heal ¶ added in v0.0.2
Heal heals the entity for a given amount of health. The source passed represents the cause of the healing, for example healing.SourceFood if the entity healed by having a full food bar. If the health added to the original health exceeds the entity's max health, Heal will not add the full amount. If the health passed is negative, Heal will not do anything.
func (*Player) Health ¶
Health returns the current health of the player. It will always be lower than Player.MaxHealth().
func (*Player) HeldItems ¶
HeldItems returns the items currently held in the hands of the player. The first item stack returned is the one held in the main hand, the second is held in the off-hand. If no item was held in a hand, the stack returned has a count of 0. Stack.Empty() may be used to check if the hand held anything.
func (*Player) HideCoordinates ¶
func (p *Player) HideCoordinates()
HideCoordinates disables the vanilla coordinates for the player.
func (*Player) Hurt ¶
Hurt hurts the player for a given amount of damage. The source passed represents the cause of the damage, for example damage.SourceEntityAttack if the player is attacked by another entity. If the final damage exceeds the health that the player currently has, the player is killed and will have to respawn. If the damage passed is negative, Hurt will not do anything.
func (*Player) Inventory ¶
Inventory returns the inventory of the player. This inventory holds the items stored in the normal part of the inventory and the hotbar. It also includes the item in the main hand as returned by Player.HeldItems().
func (*Player) KnockBack ¶
KnockBack knocks the player back with a given force and height. A source is passed which indicates the source of the velocity, typically the position of an attacking entity. The source is used to calculate the direction which the entity should be knocked back in.
func (*Player) MaxHealth ¶
MaxHealth returns the maximum amount of health that a player may have. The MaxHealth will always be higher than Player.Health().
func (*Player) Message ¶
func (p *Player) Message(a ...interface{})
Message sends a formatted message to the player. The message is formatted following the rules of fmt.Sprintln, however the newline at the end is not written.
func (*Player) Move ¶
Move moves the player from one position to another in the world, by adding the delta passed to the current position of the player.
func (*Player) Name ¶
Name returns the username of the player. If the player is controlled by a client, it is the username of the client. (Typically the XBOX Live name)
func (*Player) OpenBlockContainer ¶
OpenBlockContainer opens a block container, such as a chest, at the position passed. If no container was present at that location, OpenBlockContainer does nothing. OpenBlockContainer will also do nothing if the player has no session connected to it.
func (*Player) Ping ¶
Ping sends a ping to the player. The method blocks the caller until a response from the client is received, after which the RTT (time from server -> client -> server) will be returned. Because of the blocking nature of this method, this should be called on another goroutine. The latency may be calculated by dividing the RTT returned by 2. If the Player is not connected to a client, the duration returned will be 0. If the player's latency is too high (15 seconds to reply to the ping and above), the player will be disconnected. The latency returned by this method is generally higher than the actual network latency, due to the overhead of the Minecraft layer. The actual network latency is generally roughly 20-30 ms lower.
func (*Player) Pitch ¶
Pitch returns the pitch of the entity. This is vertical rotation (rotation around the horizontal axis), and is 0 when the entity faces forward.
func (*Player) PlaceBlock ¶
PlaceBlock makes the player place the block passed at the position passed, granted it is within the range of the player. A use context may be passed to obtain information on if the block placement was successful. (SubCount will be incremented). Nil may also be passed for the context parameter.
func (*Player) Position ¶
Position returns the current position of the player. It may be changed as the player moves or is moved around the world.
func (*Player) RemoveBossBar ¶
func (p *Player) RemoveBossBar()
RemoveBossBar removes any boss bar currently active on the player's screen. If no boss bar is currently present, nothing happens.
func (*Player) RemoveEffect ¶ added in v0.0.2
RemoveEffect removes any effect that might currently be active on the Player.
func (*Player) RemoveScoreboard ¶
func (p *Player) RemoveScoreboard()
RemoveScoreboard removes any scoreboard currently present on the screen of the player. Nothing happens if the player has no scoreboard currently active.
func (*Player) Respawn ¶
func (p *Player) Respawn()
Respawn spawns the player after it dies, so that its health is replenished and it is spawned in the world again. Nothing will happen if the player does not have a session connected to it.
func (*Player) Rotate ¶
Rotate rotates the player, adding deltaYaw and deltaPitch to the respective values.
func (*Player) Saturate ¶ added in v0.0.2
Saturate saturates the player's food bar with the amount of food points and saturation points passed. The total saturation of the player will never exceed its total food level.
func (*Player) SendBossBar ¶
SendBossBar sends a boss bar to the player, so that it will be shown indefinitely at the top of the player's screen. The boss bar may be removed by calling Player.RemoveBossBar().
func (*Player) SendCommandOutput ¶
SendCommandOutput sends the output of a command to the player.
func (*Player) SendForm ¶
SendForm sends a form to the player for the client to fill out. Once the client fills it out, the Submit method of the form will be called. Note that the client may also close the form instead of filling it out, which will result in the form not having its Submit method called at all. Forms should never depend on the player actually filling out the form.
func (*Player) SendPopup ¶
func (p *Player) SendPopup(a ...interface{})
SendPopup sends a formatted popup to the player. The popup is shown above the hotbar of the player and overwrites/is overwritten by the name of the item equipped. The popup is formatted following the rules of fmt.Sprintln without a newline at the end.
func (*Player) SendScoreboard ¶
func (p *Player) SendScoreboard(scoreboard *scoreboard.Scoreboard)
SendScoreboard sends a scoreboard to the player. The scoreboard will be present indefinitely until removed by the caller. SendScoreboard may be called at any time to change the scoreboard of the player.
func (*Player) SendTip ¶
func (p *Player) SendTip(a ...interface{})
SendTip sends a tip to the player. The tip is shown in the middle of the screen of the player. The tip is formatted following the rules of fmt.Sprintln without a newline at the end.
func (*Player) SendTitle ¶
SendTitle sends a title to the player. The title may be configured to change the duration it is displayed and the text it shows. If non-empty, the subtitle is shown in a smaller font below the title. The same counts for the action text of the title, which is shown in a font similar to that of a tip/popup.
func (*Player) SetAbsorption ¶ added in v0.0.2
SetAbsorption sets the absorption health of a player. This extra health shows as golden hearts and do not actually increase the maximum health. Once the hearts are lost, they will not regenerate. Nothing happens if a negative number is passed.
func (*Player) SetFood ¶ added in v0.0.2
SetFood sets the food level of a player. The level passed must be in a range of 0-20. If the level passed is negative, the food level will be set to 0. If the level exceeds 20, the food level will be set to 20.
func (*Player) SetGameMode ¶
SetGameMode sets the game mode of a player. The game mode specifies the way that the player can interact with the world that it is in.
func (*Player) SetHeldItems ¶
SetHeldItems sets items to the main hand and the off-hand of the player. The Stacks passed may be empty (Stack.Empty()) to clear the held item.
func (*Player) SetInvisible ¶
func (p *Player) SetInvisible()
SetInvisible sets the player invisible, so that other players will not be able to see it.
func (*Player) SetMaxHealth ¶
SetMaxHealth sets the maximum health of the player. If the current health of the player is higher than the new maximum health, the health is set to the new maximum. SetMaxHealth panics if the max health passed is 0 or lower.
func (*Player) SetNameTag ¶ added in v0.0.2
SetNameTag changes the name tag displayed over the player in-game. Changing the name tag does not change the player's name in, for example, the player list or the chat.
func (*Player) SetSpeed ¶
SetSpeed sets the speed of the player. The value passed is the blocks/tick speed that the player will then obtain.
func (*Player) SetVelocity ¶
SetVelocity sets the velocity of the player.
func (*Player) SetVisible ¶
func (p *Player) SetVisible()
SetVisible sets the player visible again, so that other players can see it again. If the player was already visible, nothing happens.
func (*Player) ShowCoordinates ¶
func (p *Player) ShowCoordinates()
ShowCoordinates enables the vanilla coordinates for the player.
func (*Player) Skin ¶
Skin returns the skin that a player joined with. This skin will be visible to other players that the player is shown to. If the player was not connected to a network session, a default skin will be set.
func (*Player) Speed ¶
Speed returns the speed of the player, returning a value that indicates the blocks/tick speed. The default speed of a player is 0.1.
func (*Player) StartBreaking ¶
StartBreaking makes the player start breaking the block at the position passed using the item currently held in its main hand. If no block is present at the position, or if the block is out of range, StartBreaking will return immediately and the block will not be broken. StartBreaking will stop the breaking of any block that the player might be breaking before this method is called.
func (*Player) StartSneaking ¶
func (p *Player) StartSneaking()
StartSneaking makes a player start sneaking. If the player is already sneaking, StartSneaking will not do anything. If the player is sprinting while StartSneaking is called, the sprinting is stopped.
func (*Player) StartSprinting ¶
func (p *Player) StartSprinting()
StartSprinting makes a player start sprinting, increasing the speed of the player by 30% and making particles show up under the feet. The player will only start sprinting if its food level is high enough. If the player is sneaking when calling StartSprinting, it is stopped from sneaking.
func (*Player) StartSwimming ¶
func (p *Player) StartSwimming()
StartSwimming makes the player start swimming if it is not currently doing so. If the player is sneaking while StartSwimming is called, the sneaking is stopped.
func (*Player) State ¶
State returns the current state of the player. Types from the `entity/state` package are returned depending on what the player is currently doing.
func (*Player) StopSneaking ¶
func (p *Player) StopSneaking()
StopSneaking makes a player stop sneaking if it currently is. If the player is not sneaking, StopSneaking will not do anything.
func (*Player) StopSprinting ¶
func (p *Player) StopSprinting()
StopSprinting makes a player stop sprinting, setting back the speed of the player to its original value.
func (*Player) StopSwimming ¶
func (p *Player) StopSwimming()
StopSwimming makes the player stop swimming if it is currently doing so.
func (*Player) Teleport ¶
Teleport teleports the player to a target position in the world. Unlike Move, it immediately changes the position of the player, rather than showing an animation.
func (*Player) Tick ¶
Tick ticks the entity, performing actions such as checking if the player is still breaking a block.
func (*Player) Transfer ¶
Transfer transfers the player to a server at the address passed. If the address could not be resolved, an error is returned. If it is returned, the player is closed and transferred to the server.
func (*Player) UUID ¶
UUID returns the UUID of the player. This UUID will remain consistent with an XBOX Live account, and will, unlike the name of the player, never change. It is therefore recommended to use the UUID over the name of the player. Additionally, it is recommended to use the UUID over the XUID because of its standard format.
func (*Player) UseItem ¶
func (p *Player) UseItem()
UseItem uses the item currently held in the player's main hand in the air. Generally, nothing happens, unless the held item implements the item.Usable interface, in which case it will be activated. This generally happens for items such as throwable items like snowballs.
func (*Player) UseItemOnBlock ¶
UseItemOnBlock uses the item held in the main hand of the player on a block at the position passed. The player is assumed to have clicked the face passed with the relative click position clickPos. If the item could not be used successfully, for example when the position is out of range, the method returns immediately.
func (*Player) UseItemOnEntity ¶
UseItemOnEntity uses the item held in the main hand of the player on the entity passed, provided it is within range of the player. If the item held in the main hand of the player does nothing when used on an entity, nothing will happen.
func (*Player) XUID ¶
XUID returns the XBOX Live user ID of the player. It will remain consistent with the XBOX Live account, and will not change in the lifetime of an account. The XUID is a number that can be parsed as an int64. No more information on what it represents is available, and the UUID should be preferred. The XUID returned is empty if the Player is not connected to a network session.