Pulcedocs

Gameplay API v0.2

Preferred entrypoint for current gameplay development with handle-first APIs and v0.2 links.

On this page

v0.2 archive

Overview

This is the preferred gameplay reference for new plugin development. Use ctx.Gameplay().Players(), Worlds(), Entities(), Sessions(), PlayerData(), and WorldTemplates().

  • Handle-first gameplay mutations should use collection handles from Gameplay(), not raw object mutation.
  • Request-style methods on plugin.Gameplay remain for compatibility.
  • Cross-links below cover events, content behaviors, entities, containers, and player data/template APIs.
gameplay-v0.2.go
gameplay := ctx.Gameplay()
worldHandle, ok := gameplay.Worlds().ByName("Hub")
if !ok {
	return fmt.Errorf("world not found")
}

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

inv := playerHandle.Inventory()
if _, err := inv.Give(item.New("pulse:ruby").Count(4).Stack()); err != nil {
	return err
}

if err := worldHandle.SetBlock(world.Pos{X: 10, Y: 64, Z: 10}, block.New("minecraft:stone").Block()); err != nil {
	return err
}

if _, err := gameplay.RegisterBlock(content.DefineBlock("pulse:glow_cube").
		Protocol(748, content.ProtocolOverride{Components: map[string]any{"minecraft:custom_components": "pulse:glow_cube"}}).
		Spec()); err != nil {
	return err
}