player

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 34 Imported by: 190

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Type ptype

Type is a world.EntityType implementation for Player.

Functions

This section is empty.

Types

type Config added in v0.10.0

type Config struct {
	Session  *session.Session
	Skin     skin.Skin
	XUID     string
	UUID     uuid.UUID
	Name     string
	Locale   language.Tag
	GameMode world.GameMode

	Position               mgl64.Vec3
	Rotation               cube.Rotation
	Velocity               mgl64.Vec3
	Health                 float64
	MaxHealth              float64
	FoodTick               int
	Food                   int
	Exhaustion, Saturation float64
	AirSupply              int
	MaxAirSupply           int
	EnchantmentSeed        int64
	Experience             int
	HeldSlot               int
	Inventory              *inventory.Inventory
	OffHand                *inventory.Inventory
	Armour                 *inventory.Armour
	EnderChestInventory    *inventory.Inventory
	FireTicks              int64
	FallDistance           float64
	Effects                []effect.Effect
}

Config holds options that a Player can be created with.

func (Config) Apply added in v0.10.0

func (cfg Config) Apply(data *world.EntityData)

Apply applies fields from a Config to a world.EntityData, filling out empty fields with reasonable defaults.

type Context added in v0.10.0

type Context = event.Context[*Player]

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 *Context, newPos mgl64.Vec3, newRot cube.Rotation)
	// HandleJump handles the player jumping.
	HandleJump(p *Player)
	// HandleTeleport handles the teleportation of a player. ctx.Cancel() may be called to cancel it.
	HandleTeleport(ctx *Context, pos mgl64.Vec3)
	// HandleChangeWorld handles when the player is added to a new world. before may be nil.
	HandleChangeWorld(p *Player, before, after *world.World)
	// HandleToggleSprint handles when the player starts or stops sprinting.
	// After is true if the player is sprinting after toggling (changing their sprinting state).
	HandleToggleSprint(ctx *Context, after bool)
	// HandleToggleSneak handles when the player starts or stops sneaking.
	// After is true if the player is sneaking after toggling (changing their sneaking state).
	HandleToggleSneak(ctx *Context, after bool)
	// 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 *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 *Context, from int, 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 *Context, health *float64, src world.HealingSource)
	// 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.
	// *damage is the final damage dealt to the player. Immune is set to true
	// if the player was hurt during an immunity frame with higher damage than
	// the original cause of the immunity frame. In this case, the damage is
	// reduced but the player is still knocked back.
	HandleHurt(ctx *Context, damage *float64, immune bool, attackImmunity *time.Duration, src world.DamageSource)
	// HandleDeath handles the player dying to a particular damage cause.
	HandleDeath(p *Player, src world.DamageSource, keepInv *bool)
	// HandleRespawn handles the respawning of the player in the world. The spawn position passed may be
	// changed by assigning to *pos. The world.World in which the Player is respawned may be modifying by assigning to
	// *w. This world may be the world the Player died in, but it might also point to a different world (the overworld)
	// if the Player died in the nether or end.
	HandleRespawn(p *Player, pos *mgl64.Vec3, w **world.World)
	// HandleSkinChange handles the player changing their skin. ctx.Cancel() may be called to cancel the skin
	// change.
	HandleSkinChange(ctx *Context, skin *skin.Skin)
	// HandleFireExtinguish handles the player extinguishing a fire at a specific position. ctx.Cancel() may
	// be called to cancel the fire being extinguished.
	// cube.Pos can be used to see where was the fire extinguished, may be used to cancel this on specific positions.
	HandleFireExtinguish(ctx *Context, pos cube.Pos)
	// 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 *Context, pos cube.Pos)
	// HandleBlockBreak handles a block that is being broken by a player. ctx.Cancel() may be called to cancel
	// the block being broken. A pointer to a slice of the block's drops is passed, and may be altered
	// to change what items will actually be dropped.
	HandleBlockBreak(ctx *Context, pos cube.Pos, drops *[]item.Stack, xp *int)
	// 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 *Context, pos cube.Pos, b world.Block)
	// HandleBlockPick handles the player picking a specific block at a position in its world. ctx.Cancel()
	// may be called to cancel the block being picked.
	HandleBlockPick(ctx *Context, pos cube.Pos, 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 *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 *Context, pos cube.Pos, face cube.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 *Context, e world.Entity)
	// HandleItemRelease handles the player releasing an item after using it for
	// a particular duration. These include items such as bows.
	HandleItemRelease(ctx *Context, item item.Stack, dur time.Duration)
	// HandleItemConsume handles the player consuming an item. This is called whenever a consumable such as
	// food is consumed.
	HandleItemConsume(ctx *Context, item item.Stack)
	// 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.
	// The knock back force and height is also provided which can be modified.
	// The attack can be a critical attack, which would increase damage by a factor of 1.5 and
	// spawn critical hit particles around the target entity. These particles will not be displayed
	// if no damage is dealt.
	HandleAttackEntity(ctx *Context, e world.Entity, force, height *float64, critical *bool)
	// HandleExperienceGain handles the player gaining experience. ctx.Cancel() may be called to cancel
	// the gain.
	// The amount is also provided which can be modified.
	HandleExperienceGain(ctx *Context, amount *int)
	// HandlePunchAir handles the player punching air.
	HandlePunchAir(ctx *Context)
	// HandleSignEdit handles the player editing a sign. It is called for every keystroke while editing a sign and
	// has both the old text passed and the text after the edit. This typically only has a change of one character.
	HandleSignEdit(ctx *Context, pos cube.Pos, frontSide bool, oldText, newText string)
	// HandleLecternPageTurn handles the player turning a page in a lectern. ctx.Cancel() may be called to cancel the
	// page turn. The page number may be changed by assigning to *page.
	HandleLecternPageTurn(ctx *Context, pos cube.Pos, oldPage int, newPage *int)
	// 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 *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 *Context, i *item.Stack)
	// HandleHeldSlotChange handles the player changing the slot they are currently holding.
	HandleHeldSlotChange(ctx *Context, from, to int)
	// HandleItemDrop handles the player dropping an item on the ground. The dropped item entity is passed.
	// ctx.Cancel() may be called to prevent the player from dropping the entity.Item passed on the ground.
	// e.Item() may be called to obtain the item stack dropped.
	HandleItemDrop(ctx *Context, s item.Stack)
	// HandleTransfer handles a player being transferred to another server. ctx.Cancel() may be called to
	// cancel the transfer.
	HandleTransfer(ctx *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 *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(p *Player)
	// HandleDiagnostics handles the latest diagnostics data that the player has sent to the server. This is
	// not sent by every client however, only those with the "Creator > Enable Client Diagnostics" setting
	// enabled.
	HandleDiagnostics(p *Player, d session.Diagnostics)
}

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(*Context, world.Entity, *float64, *float64, *bool)

func (NopHandler) HandleBlockBreak

func (NopHandler) HandleBlockBreak(*Context, cube.Pos, *[]item.Stack, *int)

func (NopHandler) HandleBlockPick

func (NopHandler) HandleBlockPick(*Context, cube.Pos, world.Block)

func (NopHandler) HandleBlockPlace

func (NopHandler) HandleBlockPlace(*Context, cube.Pos, world.Block)

func (NopHandler) HandleChangeWorld added in v0.6.0

func (NopHandler) HandleChangeWorld(*Player, *world.World, *world.World)

func (NopHandler) HandleChat

func (NopHandler) HandleChat(*Context, *string)

func (NopHandler) HandleCommandExecution

func (NopHandler) HandleCommandExecution(*Context, cmd.Command, []string)

func (NopHandler) HandleDeath

func (NopHandler) HandleDeath(*Player, world.DamageSource, *bool)

func (NopHandler) HandleDiagnostics added in v0.9.18

func (NopHandler) HandleDiagnostics(*Player, session.Diagnostics)

func (NopHandler) HandleExperienceGain added in v0.7.0

func (NopHandler) HandleExperienceGain(*Context, *int)

func (NopHandler) HandleFireExtinguish added in v0.9.18

func (NopHandler) HandleFireExtinguish(*Context, cube.Pos)

func (NopHandler) HandleFoodLoss

func (NopHandler) HandleFoodLoss(*Context, int, *int)

func (NopHandler) HandleHeal

func (NopHandler) HandleHeal(*Context, *float64, world.HealingSource)

func (NopHandler) HandleHeldSlotChange added in v0.10.0

func (NopHandler) HandleHeldSlotChange(*Context, int, int)

func (NopHandler) HandleHurt

func (NopHandler) HandleItemConsume added in v0.6.0

func (NopHandler) HandleItemConsume(*Context, item.Stack)

func (NopHandler) HandleItemDamage

func (NopHandler) HandleItemDamage(*Context, item.Stack, int)

func (NopHandler) HandleItemDrop

func (NopHandler) HandleItemDrop(*Context, item.Stack)

func (NopHandler) HandleItemPickup

func (NopHandler) HandleItemPickup(*Context, *item.Stack)

func (NopHandler) HandleItemRelease added in v0.10.0

func (NopHandler) HandleItemRelease(ctx *Context, item item.Stack, dur time.Duration)

func (NopHandler) HandleItemUse

func (NopHandler) HandleItemUse(*Context)

func (NopHandler) HandleItemUseOnBlock

func (NopHandler) HandleItemUseOnBlock(*Context, cube.Pos, cube.Face, mgl64.Vec3)

func (NopHandler) HandleItemUseOnEntity

func (NopHandler) HandleItemUseOnEntity(*Context, world.Entity)

func (NopHandler) HandleJump added in v0.6.0

func (NopHandler) HandleJump(*Player)

func (NopHandler) HandleLecternPageTurn added in v0.9.8

func (NopHandler) HandleLecternPageTurn(*Context, cube.Pos, int, *int)

func (NopHandler) HandleMove

func (NopHandler) HandleMove(*Context, mgl64.Vec3, cube.Rotation)

func (NopHandler) HandlePunchAir added in v0.3.0

func (NopHandler) HandlePunchAir(*Context)

func (NopHandler) HandleQuit

func (NopHandler) HandleQuit(*Player)

func (NopHandler) HandleRespawn

func (NopHandler) HandleRespawn(*Player, *mgl64.Vec3, **world.World)

func (NopHandler) HandleSignEdit added in v0.2.0

func (NopHandler) HandleSignEdit(*Context, cube.Pos, bool, string, string)

func (NopHandler) HandleSkinChange added in v0.1.0

func (NopHandler) HandleSkinChange(*Context, *skin.Skin)

func (NopHandler) HandleStartBreak

func (NopHandler) HandleStartBreak(*Context, cube.Pos)

func (NopHandler) HandleTeleport

func (NopHandler) HandleTeleport(*Context, mgl64.Vec3)

func (NopHandler) HandleToggleSneak added in v0.4.0

func (NopHandler) HandleToggleSneak(*Context, bool)

func (NopHandler) HandleToggleSprint added in v0.4.0

func (NopHandler) HandleToggleSprint(*Context, bool)

func (NopHandler) HandleTransfer

func (NopHandler) HandleTransfer(*Context, *net.UDPAddr)

type NopProvider added in v0.1.0

type NopProvider struct{}

NopProvider is a player data provider that won't store any data and instead always return default values

func (NopProvider) Close added in v0.1.0

func (NopProvider) Close() error

func (NopProvider) Load added in v0.1.0

func (NopProvider) Save added in v0.1.0

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 (*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) Absorption added in v0.7.3

func (p *Player) Absorption() float64

Absorption returns the absorption health that the player has.

func (*Player) AddEffect

func (p *Player) AddEffect(e effect.Effect)

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) AddExperience added in v0.7.0

func (p *Player) AddExperience(amount int) int

AddExperience adds experience to the player.

func (*Player) AddFood

func (p *Player) AddFood(points int)

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) Addr

func (p *Player) Addr() net.Addr

Addr returns the net.Addr of the Player. If the Player is not connected to a network session, nil is returned.

func (*Player) AirSupply added in v0.7.3

func (p *Player) AirSupply() time.Duration

AirSupply returns the player's remaining air supply.

func (*Player) Armour

func (p *Player) Armour() *inventory.Armour

Armour returns the armour inventory of the player. This inventory yields 4 slots, for the helmet, chestplate, leggings and boots respectively.

func (*Player) AttackEntity

func (p *Player) AttackEntity(e world.Entity) bool

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) BeaconAffected

func (*Player) BeaconAffected() bool

BeaconAffected ...

func (*Player) BreakBlock

func (p *Player) BreakBlock(pos cube.Pos)

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) Breathing added in v0.2.0

func (p *Player) Breathing() bool

Breathing checks if the player is currently able to breathe. If it's underwater and the player does not have the water breathing or conduit power effect, this returns false. If the player is in creative or spectator mode, Breathing always returns true.

func (*Player) Chat

func (p *Player) Chat(msg ...any)

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

func (p *Player) Close() error

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) CloseDialogue added in v0.10.0

func (p *Player) CloseDialogue()

CloseDialogue closes the player's currently open dialogue, if any. If the dialogue's Submittable implements dialogue.Closer, the Close method of the Submittable is called after the client acknowledges the closing of the dialogue.

func (*Player) CloseForm added in v0.9.17

func (p *Player) CloseForm()

CloseForm closes any forms that the player currently has open. If the player has no forms open, nothing happens.

func (*Player) Collect

func (p *Player) Collect(s item.Stack) (int, bool)

Collect makes the player collect the item stack passed, adding it to the inventory. The amount of items that could be added is returned.

func (*Player) CollectExperience added in v0.7.0

func (p *Player) CollectExperience(value int) bool

CollectExperience makes the player collect the experience points passed, adding it to the experience manager. A bool is returned indicating whether the player was able to collect the experience or not, due to the 100ms delay between experience collection or if the player was dead or in a game mode that doesn't allow collection.

func (*Player) ContinueBreaking

func (p *Player) ContinueBreaking(face cube.Face)

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) Crawling added in v0.9.19

func (p *Player) Crawling() bool

Crawling checks if the player is currently crawling.

func (*Player) Data added in v0.1.0

func (p *Player) Data() Config

Data returns the player data that needs to be saved. This is used when the player gets disconnected and the player provider needs to save the data.

func (*Player) Dead

func (p *Player) Dead() bool

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) DeathPosition added in v0.8.2

func (p *Player) DeathPosition() (mgl64.Vec3, world.Dimension, bool)

DeathPosition returns the last position the player was at when they died. If the player has never died, the third return value will be false.

func (*Player) DeviceID added in v0.9.0

func (p *Player) DeviceID() string

DeviceID returns the device ID of the player. If the Player is not connected to a network session, an empty string is returned. Otherwise, the device ID the network session sent in the ClientData is returned.

func (*Player) DeviceModel added in v0.9.0

func (p *Player) DeviceModel() string

DeviceModel returns the device model of the player. If the Player is not connected to a network session, an empty string is returned. Otherwise, the device model the network session sent in the ClientData is returned.

func (*Player) DisableInstantRespawn added in v0.3.0

func (p *Player) DisableInstantRespawn()

DisableInstantRespawn disables the vanilla instant respawn for the player.

func (*Player) Disconnect

func (p *Player) Disconnect(msg ...any)

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) Drop

func (p *Player) Drop(s item.Stack) int

Drop makes the player drop the item.Stack passed as an entity.Item, so that it may be picked up from the ground. The dropped item entity has a pickup delay of 2 seconds. The number of items that was dropped in the end is returned. It is generally the count of the stack passed or 0 if dropping the item.Stack was cancelled.

func (*Player) EditSign added in v0.2.0

func (p *Player) EditSign(pos cube.Pos, frontText, backText string) error

EditSign edits the sign at the cube.Pos passed and writes the text passed to a sign at that position. If no sign is present, an error is returned.

func (*Player) Effect added in v0.5.0

func (p *Player) Effect(e effect.Type) (effect.Effect, bool)

Effect returns the effect instance and true if the Player has the effect. If not found, it will return an empty effect instance and false.

func (*Player) Effects

func (p *Player) Effects() []effect.Effect

Effects returns any effect currently applied to the entity. The returned effects are guaranteed not to have expired when returned.

func (*Player) EnableInstantRespawn added in v0.3.0

func (p *Player) EnableInstantRespawn()

EnableInstantRespawn enables the vanilla instant respawn for the player.

func (*Player) EnchantmentSeed added in v0.8.0

func (p *Player) EnchantmentSeed() int64

EnchantmentSeed is a seed used to calculate random enchantments with enchantment tables.

func (*Player) EnderChestInventory added in v0.8.0

func (p *Player) EnderChestInventory() *inventory.Inventory

EnderChestInventory returns the player's ender chest inventory. Its accessed by the player when opening ender chests anywhere.

func (*Player) ExecuteCommand

func (p *Player) ExecuteCommand(commandLine string)

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. This message should start with a "/" for the command to be recognised.

func (*Player) Exhaust

func (p *Player) Exhaust(points float64)

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) Experience added in v0.7.0

func (p *Player) Experience() int

Experience returns the amount of experience the player has.

func (*Player) ExperienceLevel added in v0.7.0

func (p *Player) ExperienceLevel() int

ExperienceLevel returns the experience level of the player.

func (*Player) ExperienceProgress added in v0.7.0

func (p *Player) ExperienceProgress() float64

ExperienceProgress returns the experience progress of the player.

func (*Player) Explode added in v0.8.0

func (p *Player) Explode(explosionPos mgl64.Vec3, impact float64, c block.ExplosionConfig)

Explode ...

func (*Player) Extinguish

func (p *Player) Extinguish()

Extinguish ...

func (*Player) EyeHeight

func (p *Player) EyeHeight() float64

EyeHeight returns the eye height of the player: 1.62, 1.26 if player is sneaking or 0.52 if the player is swimming, gliding or crawling.

func (*Player) FallDistance added in v0.4.0

func (p *Player) FallDistance() float64

FallDistance returns the player's fall distance.

func (*Player) FinalDamageFrom

func (p *Player) FinalDamageFrom(dmg float64, src world.DamageSource) float64

FinalDamageFrom resolves the final damage received by the player if it is attacked by the source passed with the damage passed. FinalDamageFrom takes into account things such as the armour worn and the enchantments on the individual pieces. The damage returned will be at the least 0.

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) FireProof added in v0.3.0

func (p *Player) FireProof() bool

FireProof checks if the Player is currently fireproof. True is returned if the player has a fireResistance effect or if it is in creative mode.

func (*Player) FlightSpeed added in v0.9.19

func (p *Player) FlightSpeed() float64

FlightSpeed returns the flight speed of the player, with the value representing the base speed. The actual blocks/tick speed is this value multiplied by 10. The default flight speed of a player is 0.05, which corresponds to 0.5 blocks/tick.

func (*Player) Flying added in v0.4.0

func (p *Player) Flying() bool

Flying checks if the player is currently flying.

func (*Player) Food

func (p *Player) Food() int

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

func (p *Player) GameMode() world.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) Gliding added in v0.8.0

func (p *Player) Gliding() bool

Gliding checks if the player is currently gliding.

func (*Player) H added in v0.10.0

func (p *Player) H() *world.EntityHandle

func (*Player) Handle

func (p *Player) Handle(h Handler)

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) Handler added in v0.7.3

func (p *Player) Handler() Handler

Handler returns the Handler of the player.

func (*Player) HasCooldown added in v0.5.0

func (p *Player) HasCooldown(item world.Item) bool

HasCooldown returns true if the item passed has an active cooldown, meaning it currently cannot be used again. If the world.Item passed is nil, HasCooldown always returns false.

func (*Player) Heal

func (p *Player) Heal(health float64, source world.HealingSource)

Heal heals the entity for a given amount of health. The source passed represents the cause of the healing, for example entity.FoodHealingSource 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

func (p *Player) Health() float64

Health returns the current health of the player. It will always be lower than Player.MaxHealth().

func (*Player) HeldItems

func (p *Player) HeldItems() (mainHand, offHand item.Stack)

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) HideEntity added in v0.4.0

func (p *Player) HideEntity(e world.Entity)

HideEntity hides a world.Entity from the Player so that it can under no circumstance see it. Hidden entities can be made visible again through a call to ShowEntity.

func (*Player) Hurt

func (p *Player) Hurt(dmg float64, src world.DamageSource) (float64, bool)

Hurt hurts the player for a given amount of damage. The source passed represents the cause of the damage, for example entity.AttackDamageSource 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. Hurt returns the final damage dealt to the Player and if the Player was vulnerable to this kind of damage.

func (*Player) Immobile added in v0.2.0

func (p *Player) Immobile() bool

Immobile checks if the Player is currently immobile.

func (*Player) Inventory

func (p *Player) Inventory() *inventory.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) Invisible added in v0.2.0

func (p *Player) Invisible() bool

Invisible checks if the Player is currently invisible.

func (*Player) Jump added in v0.6.0

func (p *Player) Jump()

Jump makes the player jump if they are on ground. It exhausts the player by 0.05 food points, an additional 0.15 is exhausted if the player is sprint jumping.

func (*Player) KnockBack

func (p *Player) KnockBack(src mgl64.Vec3, force, height float64)

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) Latency

func (p *Player) Latency() time.Duration

Latency returns a rolling average of latency between the sending and the receiving end of the connection of the player. The latency returned is updated continuously and is half the round trip time (RTT). If the Player does not have a session associated with it, Latency returns 0.

func (*Player) Locale

func (p *Player) Locale() language.Tag

Locale returns the language and locale of the Player, as selected in the Player's settings.

func (*Player) MaxAirSupply added in v0.7.3

func (p *Player) MaxAirSupply() time.Duration

MaxAirSupply returns the player's maximum air supply.

func (*Player) MaxHealth

func (p *Player) MaxHealth() float64

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 ...any)

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) Messagef

func (p *Player) Messagef(f string, a ...any)

Messagef sends a formatted message using a specific format to the player. The message is formatted according to the fmt.Sprintf formatting rules.

func (*Player) Messaget added in v0.10.0

func (p *Player) Messaget(t chat.Translation, a ...any)

Messaget sends a translatable message to a player and parameterises it using the arguments passed. Messaget panics if an incorrect amount of arguments is passed.

func (*Player) Move

func (p *Player) Move(deltaPos mgl64.Vec3, deltaYaw, deltaPitch float64)

Move moves the player from one position to another in the world, by adding the delta passed to the current position of the player. Move also rotates the player, adding deltaYaw and deltaPitch to the respective values.

func (*Player) MoveItemsToInventory added in v0.10.0

func (p *Player) MoveItemsToInventory()

MoveItemsToInventory moves items kept in 'temporary' slots, such as the crafting grid of slots in an enchantment table, to the player's inventory. If no space is left for these items, the leftover items are dropped.

func (*Player) Name

func (p *Player) Name() string

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) NameTag added in v0.2.0

func (p *Player) NameTag() string

NameTag returns the current name tag of the Player as shown in-game. It can be changed using SetNameTag.

func (*Player) OnFireDuration

func (p *Player) OnFireDuration() time.Duration

OnFireDuration ...

func (*Player) OnGround

func (p *Player) OnGround() bool

OnGround checks if the player is considered to be on the ground.

func (*Player) OpenBlockContainer

func (p *Player) OpenBlockContainer(pos cube.Pos, tx *world.Tx)

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) OpenSign added in v0.9.6

func (p *Player) OpenSign(pos cube.Pos, frontSide bool)

OpenSign makes the player open the sign at the cube.Pos passed, with the specific side provided. The client will not show the interface if it is not aware of a sign at the position.

func (*Player) PickBlock

func (p *Player) PickBlock(pos cube.Pos)

PickBlock makes the player pick a block in the world at a position passed. If the player is unable to pick the block, the method returns immediately.

func (*Player) PlaceBlock

func (p *Player) PlaceBlock(pos cube.Pos, b world.Block, ctx *item.UseContext)

PlaceBlock makes the player place the block passed at the position passed, granted it is within the range of the player. An item.UseContext 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) PlaySound

func (p *Player) PlaySound(sound world.Sound)

PlaySound plays a world.Sound that only this Player can hear. Unlike World.PlaySound, it is not broadcast to players around it.

func (*Player) Position

func (p *Player) Position() mgl64.Vec3

Position returns the current position of the player. It may be changed as the player moves or is moved around the world.

func (*Player) PunchAir added in v0.3.0

func (p *Player) PunchAir()

PunchAir makes the player punch the air and plays the sound for attacking with no damage.

func (*Player) ReleaseItem

func (p *Player) ReleaseItem()

ReleaseItem makes the Player release the item it is currently using. This is only applicable for items that implement the item.Releasable interface. If the Player is not currently using any item, ReleaseItem returns immediately. ReleaseItem either aborts the using of the item or finished it, depending on the time that elapsed since the item started being used.

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

func (p *Player) RemoveEffect(e effect.Type)

RemoveEffect removes any effect that might currently be active on the Player.

func (*Player) RemoveExperience added in v0.7.0

func (p *Player) RemoveExperience(amount int)

RemoveExperience removes experience from 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) ResetEnchantmentSeed added in v0.8.0

func (p *Player) ResetEnchantmentSeed()

ResetEnchantmentSeed resets the enchantment seed to a new random value.

func (*Player) ResetFallDistance

func (p *Player) ResetFallDistance()

ResetFallDistance resets the player's fall distance.

func (*Player) Respawn

func (p *Player) Respawn() *world.EntityHandle

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. Calling Respawn may lead to the player being removed from its world and being added to a new world. This means that p cannot be assumed to be valid after a call to Respawn.

func (*Player) Rotation added in v0.1.0

func (p *Player) Rotation() cube.Rotation

Rotation returns the yaw and pitch of the player in degrees. Yaw is horizontal rotation (rotation around the vertical axis, 0 when facing forward), pitch is vertical rotation (rotation around the horizontal axis, also 0 when facing forward).

func (*Player) Saturate

func (p *Player) Saturate(food int, saturation float64)

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) Scale

func (p *Player) Scale() float64

Scale returns the scale modifier of the Player. The default value for a normal scale is 1. A scale of 0 will make the Player completely invisible.

func (*Player) ScoreTag added in v0.6.0

func (p *Player) ScoreTag() string

ScoreTag returns the current score tag of the player. It can be changed using SetScoreTag and by default is empty.

func (*Player) SelfSignedID added in v0.9.0

func (p *Player) SelfSignedID() string

SelfSignedID returns the self-signed ID of the player. If the Player is not connected to a network session, an empty string is returned. Otherwise, the self-signed ID the network session sent in the ClientData is returned.

func (*Player) SendBossBar

func (p *Player) SendBossBar(bar bossbar.BossBar)

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

func (p *Player) SendCommandOutput(output *cmd.Output)

SendCommandOutput sends the output of a command to the player.

func (*Player) SendDialogue added in v0.10.0

func (p *Player) SendDialogue(d dialogue.Dialogue, e world.Entity)

SendDialogue sends an NPC dialogue to the player, using the entity passed as the entity that the dialogue is shown for. Dialogues can be sent on top of each other without the other closing, making it possible to have non-flashing transitions between menus compared to forms. The player can either press one of the buttons or close the dialogue. It is impossible for a dialogue to have any more than 6 buttons.

func (*Player) SendForm

func (p *Player) SendForm(f form.Form)

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) SendJukeboxPopup added in v0.6.0

func (p *Player) SendJukeboxPopup(a ...any)

SendJukeboxPopup sends a formatted jukebox popup to the player. This popup is shown above the hotbar of the player. The popup is close to the position of an action bar message and the text has no background.

func (*Player) SendPopup

func (p *Player) SendPopup(a ...any)

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 ...any)

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

func (p *Player) SendTitle(t title.Title)

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) SendToast added in v0.7.0

func (p *Player) SendToast(title, message string)

SendToast sends a toast to the player. This toast is shown at the top of the screen, similar to achievements or pack loading.

func (*Player) SetAbsorption

func (p *Player) SetAbsorption(health float64)

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) SetAirSupply added in v0.7.3

func (p *Player) SetAirSupply(duration time.Duration)

SetAirSupply sets the player's remaining air supply.

func (*Player) SetCooldown added in v0.5.0

func (p *Player) SetCooldown(item world.Item, cooldown time.Duration)

SetCooldown sets a cooldown for an item. If the world.Item passed is nil, nothing happens.

func (*Player) SetExperienceLevel added in v0.7.0

func (p *Player) SetExperienceLevel(level int)

SetExperienceLevel sets the experience level of the player. The level must have a value between 0 and 2,147,483,647, otherwise the method panics.

func (*Player) SetExperienceProgress added in v0.7.0

func (p *Player) SetExperienceProgress(progress float64)

SetExperienceProgress sets the experience progress of the player. The progress must have a value between 0.0 and 1.0, otherwise the method panics.

func (*Player) SetFlightSpeed added in v0.9.19

func (p *Player) SetFlightSpeed(flightSpeed float64)

SetFlightSpeed sets the flight speed of the player. The value passed represents the base speed, which is multiplied by 10 to obtain the actual blocks/tick speed that the player will then obtain while flying.

func (*Player) SetFood

func (p *Player) SetFood(level int)

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

func (p *Player) SetGameMode(mode world.GameMode)

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

func (p *Player) SetHeldItems(mainHand, offHand item.Stack)

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) SetHeldSlot added in v0.10.0

func (p *Player) SetHeldSlot(to int) error

SetHeldSlot updates the held slot of the player to the slot provided. The slot must be between 0 and 8.

func (*Player) SetImmobile

func (p *Player) SetImmobile()

SetImmobile prevents the player from moving around, but still allows them to look around.

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) SetMaxAirSupply added in v0.7.3

func (p *Player) SetMaxAirSupply(duration time.Duration)

SetMaxAirSupply sets the player's maximum air supply.

func (*Player) SetMaxHealth

func (p *Player) SetMaxHealth(health float64)

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) SetMobile

func (p *Player) SetMobile()

SetMobile allows the player to freely move around again after being immobile.

func (*Player) SetNameTag

func (p *Player) SetNameTag(name string)

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) SetOnFire

func (p *Player) SetOnFire(duration time.Duration)

SetOnFire ...

func (*Player) SetScale

func (p *Player) SetScale(s float64)

SetScale changes the scale modifier of the Player. The default value for a normal scale is 1. A scale of 0 will make the Player completely invisible.

func (*Player) SetScoreTag added in v0.6.0

func (p *Player) SetScoreTag(a ...any)

SetScoreTag changes the score tag displayed over the player in-game. The score tag is displayed under the player's name tag.

func (*Player) SetSkin added in v0.1.0

func (p *Player) SetSkin(skin skin.Skin)

SetSkin changes the skin of the player. This skin will be visible to other players that the player is shown to.

func (*Player) SetSpeed

func (p *Player) SetSpeed(speed float64)

SetSpeed sets the speed of the player. The value passed is the blocks/tick speed that the player will then obtain.

func (*Player) SetVelocity

func (p *Player) SetVelocity(velocity mgl64.Vec3)

SetVelocity updates the player's velocity. If there is an attached session, this will just send the velocity to the player session for the player to update.

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, or if the player is in spectator mode, nothing happens.

func (*Player) ShowCoordinates

func (p *Player) ShowCoordinates()

ShowCoordinates enables the vanilla coordinates for the player.

func (*Player) ShowEntity added in v0.4.0

func (p *Player) ShowEntity(e world.Entity)

ShowEntity shows a world.Entity previously hidden from the Player using HideEntity. It does nothing if the entity wasn't currently hidden.

func (*Player) ShowParticle added in v0.7.0

func (p *Player) ShowParticle(pos mgl64.Vec3, particle world.Particle)

ShowParticle shows a particle that only this Player can see. Unlike World.AddParticle, it is not broadcast to players around it.

func (*Player) Skin

func (p *Player) Skin() skin.Skin

Skin returns the skin that a player is currently using. 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) Sneaking

func (p *Player) Sneaking() bool

Sneaking checks if the player is currently sneaking.

func (*Player) Speed

func (p *Player) Speed() float64

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) Splash added in v0.9.19

func (p *Player) Splash(*world.Tx, mgl64.Vec3)

Splash is called when a water bottle splashes onto the player.

func (*Player) Sprinting

func (p *Player) Sprinting() bool

Sprinting checks if the player is currently sprinting.

func (*Player) StartBreaking

func (p *Player) StartBreaking(pos cube.Pos, face cube.Face)

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) StartCrawling added in v0.9.19

func (p *Player) StartCrawling()

StartCrawling makes the player start crawling if it is not currently doing so. If the player is sneaking while StartCrawling is called, the sneaking is stopped.

func (*Player) StartFlying added in v0.4.0

func (p *Player) StartFlying()

StartFlying makes the player start flying if they aren't already. It requires the player to be in a gamemode which allows flying.

func (*Player) StartGliding added in v0.8.0

func (p *Player) StartGliding()

StartGliding makes the player start gliding if it is not currently doing so.

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) StopCrawling added in v0.9.19

func (p *Player) StopCrawling()

StopCrawling makes the player stop crawling if it is currently doing so.

func (*Player) StopFlying added in v0.4.0

func (p *Player) StopFlying()

StopFlying makes the player stop flying if it currently is.

func (*Player) StopGliding added in v0.8.0

func (p *Player) StopGliding()

StopGliding makes the player stop gliding if it is currently doing so.

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) Swimming

func (p *Player) Swimming() bool

Swimming checks if the player is currently swimming.

func (*Player) SwingArm

func (p *Player) SwingArm()

SwingArm makes the player swing its arm.

func (*Player) Teleport

func (p *Player) Teleport(pos mgl64.Vec3)

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

func (p *Player) Tick(tx *world.Tx, current int64)

Tick ticks the entity, performing actions such as checking if the player is still breaking a block.

func (*Player) TorsoHeight added in v0.10.0

func (p *Player) TorsoHeight() float64

TorsoHeight returns the torso height of the player: 1.52, 1.16 if the player is sneaking, or 0.42 if the player is swimming, gliding, or crawling.

func (*Player) Transfer

func (p *Player) Transfer(address string) error

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) TurnLecternPage added in v0.9.8

func (p *Player) TurnLecternPage(pos cube.Pos, page int) error

TurnLecternPage edits the lectern at the cube.Pos passed by turning the page to the page passed. If no lectern is present, an error is returned.

func (*Player) Tx added in v0.10.0

func (p *Player) Tx() *world.Tx

func (*Player) UUID

func (p *Player) UUID() uuid.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 using 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) UpdateDiagnostics added in v0.9.18

func (p *Player) UpdateDiagnostics(d session.Diagnostics)

UpdateDiagnostics updates the diagnostics of the player.

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

func (p *Player) UseItemOnBlock(pos cube.Pos, face cube.Face, clickPos mgl64.Vec3)

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. UseItemOnBlock does nothing if the block at the cube.Pos passed is of the type block.Air.

func (*Player) UseItemOnEntity

func (p *Player) UseItemOnEntity(e world.Entity) bool

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) UsingItem added in v0.2.0

func (p *Player) UsingItem() bool

UsingItem checks if the Player is currently using an item. True is returned if the Player is currently eating an item or using it over a longer duration such as when using a bow.

func (*Player) Velocity

func (p *Player) Velocity() mgl64.Vec3

Velocity returns the players current velocity. If there is an attached session, this will be empty.

func (*Player) XUID

func (p *Player) XUID() string

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 or if the Player is not authenticated with XBOX Live.

type Provider added in v0.1.0

type Provider interface {
	// Save is called when the player leaves the server. The Data of the player is passed.
	Save(uuid uuid.UUID, data Config, w *world.World) error
	// Load is called when the player joins and passes the UUID of the player.
	// It expects to the player data, and an error that is nil if the player data could be found. If non-nil, the player
	// will use default values, and you can use an empty Data struct.
	Load(uuid uuid.UUID, world func(world.Dimension) *world.World) (Config, *world.World, error)
	// Closer is used on server close when the server calls Provider.Close() and is used to safely close the Provider.
	io.Closer
}

Provider represents a value that may provide data to a Player value. It usually does the reading and writing of the player data so that the Player may use it.

type StarvationDamageSource added in v0.8.6

type StarvationDamageSource struct{}

StarvationDamageSource is the world.DamageSource passed when a player is dealt damage from an empty food bar.

func (StarvationDamageSource) Fire added in v0.8.6

func (StarvationDamageSource) ReducedByArmour added in v0.8.6

func (StarvationDamageSource) ReducedByArmour() bool

func (StarvationDamageSource) ReducedByResistance added in v0.8.6

func (StarvationDamageSource) ReducedByResistance() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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