Class BehaviorTrait

java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.BehaviorTrait
All Implemented Interfaces:
Runnable, Listener

public class BehaviorTrait extends Trait
Trait that allows NPCs to have behavior trees.
  • Constructor Details

    • BehaviorTrait

      public BehaviorTrait()
  • Method Details

    • applyBehaviorsFromFile

      public boolean applyBehaviorsFromFile(File file)
    • applyBehaviorsFromKey

      public void applyBehaviorsFromKey(DataKey key)
    • getMemory

      public Memory getMemory()
      Returns:
      the blackboard memory for this NPC's behavior tree
    • load

      public void load(DataKey key)
      Description copied from class: Trait
      Loads a trait.
      Overrides:
      load in class Trait
      Parameters:
      key - DataKey to load from
    • onDespawn

      public void onDespawn()
      Description copied from class: Trait
      Called just before the attached NPC is despawned. NPC.getEntity() will be non-null.
      Overrides:
      onDespawn in class Trait
    • save

      public void save(DataKey key)
      Description copied from class: Trait
      Saves a trait.
      Overrides:
      save in class Trait
      Parameters:
      key - DataKey to save to
    • createTemplateParser

      public static TraitTemplateParser createTemplateParser()
      Creates a template parser for BehaviorTrait that supports:
      • Short form: "tree.yml" - loads tree from file
      • Long form: tree as child