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
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
class
static interface
class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(CommandContext args) Configures the explicit type parameter.boolean
void
Loads a trait.boolean
void
onSpawn()
Called when anNPC
is spawned.static void
registerControllerType
(EntityType type, Class<? extends Controllable.MovementController> clazz) Register a movement controller for a certainEntityType
to be used forNPC
s with that type.void
run()
Called every tick if overridden.void
Saves a trait.boolean
setEnabled
(boolean enabled) void
setExplicitType
(EntityType type) Configures the explicit typei.e.void
setOwnerRequired
(boolean ownerRequired) boolean
toggle()
-
Constructor Details
-
Controllable
public Controllable()
-
-
Method Details
-
configure
Configures the explicit type parameter.- Specified by:
configure
in interfaceCommandConfigurable
- See Also:
-
isEnabled
public boolean isEnabled() -
load
Description copied from class:Trait
Loads a trait.- Overrides:
load
in classTrait
- Parameters:
key
- DataKey to load from- Throws:
NPCLoadException
- Thrown if this trait failed to load properly
-
mount
- Parameters:
toMount
- the player to mount- Returns:
- whether the mount was successful
-
onSpawn
public void onSpawn()Description copied from class:Trait
Called when anNPC
is 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:Trait
Called every tick if overridden. -
save
Description copied from class:Trait
Saves 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:
toggle
in interfaceToggleable
-
registerControllerType
public static void registerControllerType(EntityType type, Class<? extends Controllable.MovementController> clazz) Register a movement controller for a certainEntityType
to be used forNPC
s 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
-