Pulcedocs

Players

Resolve players and apply server-owned player mutations through handles.

On this page

Lookup

Use ctx.Gameplay().Players() to resolve players by name, ID, XUID, UUID, or active session identity.

players.go
playerHandle, ok := ctx.Gameplay().Players().ByName("Steve")
if !ok {
	return fmt.Errorf("player not found")
}

target, ok := ctx.Gameplay().Players().Resolve("Steve") // ID, name, XUID, or UUID
_ = target
_ = ok

_, err := playerHandle.Inventory().Give(item.New("diamond_sword").
	Enchant(item.Sharpness(5)).
	NameTag("Arena Blade").
	Stack())

worldHandle, ok := ctx.Gameplay().Worlds().ByName("Hub")
if !ok {
	return fmt.Errorf("world not found")
}

container := worldHandle.ContainerAt(world.Pos{X: 10, Y: 64, Z: 10}, 27)
_, err = container.Give(item.New("diamond").Count(8).Stack())

Player State

Player handles expose identity, locale, device, skin profile, full skin snapshots, motion, network, inventory, forms, scoreboards, and runtime actions.

motion-network.go
motion, ok := playerHandle.Motion()
_ = motion
_ = ok

err := playerHandle.SetMotion(entity.Motion{X: 0.2, Y: 0.42, Z: 0})
_, err = playerHandle.Knockback(entity.Position{X: 0, Y: 64, Z: 0}, 0.4, 0.36)

network, ok := playerHandle.Network()
locale, _ := playerHandle.Locale()
device, _ := playerHandle.Device()
skinProfile, _ := playerHandle.SkinProfile()
skin, err := playerHandle.Skin()
_, err = playerHandle.SetSkin(skin)
_ = network
_ = ok
_ = locale
_ = device
_ = skinProfile
_ = skin