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 TypeClassDescriptionclass
class
static interface
class
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(CommandContext args) Configures the explicit type parameter.boolean
void
Loads a trait.boolean
Attempts to mount thePlayer
onto theNPC
.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()
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:
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
Attempts to mount thePlayer
onto theNPC
.- 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
-