Package net.citizensnpcs.trait
Class Controllable
java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.Controllable
- All Implemented Interfaces:
Runnable,CommandConfigurable,Toggleable,Listener
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassstatic interfaceclass -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(CommandContext args) Configures the explicit type parameter.booleanvoidLoads a trait.booleanAttempts to mount thePlayeronto theNPC.voidonSpawn()Called when anNPCis spawned.static voidregisterControllerType(EntityType type, Class<? extends Controllable.MovementController> clazz) Register a movement controller for a certainEntityTypeto be used forNPCs with that type.voidrun()Called every tick if overridden.voidSaves a trait.booleansetEnabled(boolean enabled) voidsetExplicitType(EntityType type) Configures the explicit typei.e.voidsetOwnerRequired(boolean ownerRequired) booleantoggle()Methods inherited from class net.citizensnpcs.api.trait.Trait
getName, getNPC, isRunImplemented, linkToNPC, onAttach, onCopy, onDespawn, onPreSpawn, onRemove
-
Constructor Details
-
Controllable
public Controllable() -
Controllable
public Controllable(boolean enabled)
-
-
Method Details
-
configure
Configures the explicit type parameter.- Specified by:
configurein interfaceCommandConfigurable- See Also:
-
isEnabled
public boolean isEnabled() -
load
Description copied from class:TraitLoads a trait.- Overrides:
loadin classTrait- Parameters:
key- DataKey to load from- Throws:
NPCLoadException- Thrown if this trait failed to load properly
-
mount
Attempts to mount thePlayeronto theNPC.- Parameters:
toMount- the player to mount- Returns:
- whether the mount was successful
-
onSpawn
public void onSpawn()Description copied from class:TraitCalled when anNPCis spawned.NPC.getEntity()will return null until this is called. This is also called onAttach when the NPC is already spawned. -
run
public void run()Description copied from class:TraitCalled every tick if overridden. -
save
Description copied from class:TraitSaves a trait. -
setEnabled
public boolean setEnabled(boolean enabled) -
setExplicitType
Configures the explicit typei.e. whether the NPC should be controlled as if it was a certainEntityType.- Parameters:
type- the explicit type
-
setOwnerRequired
public void setOwnerRequired(boolean ownerRequired) -
toggle
public boolean toggle()- Specified by:
togglein interfaceToggleable
-
registerControllerType
public static void registerControllerType(EntityType type, Class<? extends Controllable.MovementController> clazz) Register a movement controller for a certainEntityTypeto be used forNPCs with that type. Default controllers are registered for BAT, BLAZE, ENDER_DRAGON, GHAST, WITHER and PARROT usingControllable.PlayerInputAirController.- Parameters:
type- the entity typeclazz- the controller class
-