NpcHandle returned by firstNpc.ready() as npc in the examples below.
A shared change is visible to every player watching that NPC.
Play an animation
A model contains named clips. The example bot hasidle and wave.
Calling npc.playClip("wave") selects the clip, but your application must also advance its time.
The quickstart ZIP includes src/main/java/example/npc/NpcAnimations.java.
It installs one repeating task on the owning instance and measures elapsed time with a
monotonic clock. Keep it with your NPC so you can cancel the task later:
animations.play("idle") switches to its idle clip.
The helper resets its clock only after an admitted start. If an NPC cannot start the clip,
the returned stage fails and the current clock continues.
The helper samples elapsed real time once per instance tick. A busy server can skip visual
samples; elapsed animation time still follows the monotonic clock. It waits for an old
frame to finish before switching clips and skips ticks while the new start is pending.
Turn the head and move the NPC
Head angles are degrees. This changes the head pose without turning the whole body:Make a clip audible
Sound cues describe what to play. Your application decides who hears them; the default sound callback is silent. The example bot bindswave to the Vanilla event
minecraft:entity.villager.yes.
Use NpcSounds.java from the quickstart ZIP, then create the NPC with that callback:
wave through your animation helper. Players within the cue’s radius
on this instance hear it. The callback uses the cue’s volume and pitch. Custom sound files
must also be present in the resourcepack.
Stop and remove
npc.stopClip() selects the rest pose. To return to an authored idle animation, call
animations.play("idle") instead.
Before removing the NPC, stop its animation driver:
