Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 943 Bytes

README.md

File metadata and controls

34 lines (27 loc) · 943 Bytes

npc

NPC library for Dragonfly.

Getting started

The NPC library may be imported using go get:

go get github.com/df-mc/npc

Usage

Go Reference

Usage of the NPC library is simple. It relies on the Create method:

// var w *world.World

settings := npc.Settings{
    Name: "Example NPC",
    Scale: 2,
    Position: mgl64.Vec3{1, 2, 3},
    Skin   ...,
}
p := npc.Create(settings, w, nil)
p.SwingArm()

Instead of nil, an npc.HandlerFunc may be passed to handle the NPC being hit by other players.

Note that the npc.Settings passed initially may be overwritten by calling methods on the *player.Player returned by npc.Create().

The NPC library also contains convenience functions for reading/parsing skin data from files. The npc.Skin(), npc.*Model() and npc.*Texture() functions may be used to do so.