Class Controllable

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

public class Controllable extends Trait implements Toggleable, CommandConfigurable
Persists the controllable status for /npc controllable A controllable NPC can be mounted by a Player using right click or /npc mount and moved around using e.g. arrow keys.
  • Constructor Details

    • Controllable

      public Controllable()
  • Method Details

    • configure

      public void configure(CommandContext args)
      Configures the explicit type parameter.
      Specified by:
      configure in interface CommandConfigurable
      See Also:
    • isEnabled

      public boolean isEnabled()
    • load

      public void load(DataKey key) throws NPCLoadException
      Description copied from class: Trait
      Loads a trait.
      Overrides:
      load in class Trait
      Parameters:
      key - DataKey to load from
      Throws:
      NPCLoadException - Thrown if this trait failed to load properly
    • mount

      public boolean mount(Player toMount)
      Attempts to mount the Player onto the NPC.
      Parameters:
      toMount - the player to mount
      Returns:
      whether the mount was successful
    • onSpawn

      public void onSpawn()
      Description copied from class: Trait
      Called when an NPC is spawned. NPC.getEntity() will return null until this is called. This is also called onAttach when the NPC is already spawned.
      Overrides:
      onSpawn in class Trait
    • run

      public void run()
      Description copied from class: Trait
      Called every tick if overridden.
      Specified by:
      run in interface Runnable
      Overrides:
      run 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
    • setEnabled

      public boolean setEnabled(boolean enabled)
    • setExplicitType

      public void setExplicitType(EntityType type)
      Configures the explicit typei.e. whether the NPC should be controlled as if it was a certain EntityType.
      Parameters:
      type - the explicit type
    • setOwnerRequired

      public void setOwnerRequired(boolean ownerRequired)
      Sets whether the Player attempting to mount the NPC must actually own the NPC to mount it.
      See Also:
    • toggle

      public boolean toggle()
      Specified by:
      toggle in interface Toggleable
    • registerControllerType

      public static void registerControllerType(EntityType type, Class<? extends Controllable.MovementController> clazz)
      Register a movement controller for a certain EntityType to be used for NPCs with that type. Default controllers are registered for BAT, BLAZE, ENDER_DRAGON, GHAST, WITHER and PARROT using Controllable.PlayerInputAirController.
      Parameters:
      type - the entity type
      clazz - the controller class