Package net.citizensnpcs.npc
Class CitizensNPC
java.lang.Object
net.citizensnpcs.api.npc.AbstractNPC
net.citizensnpcs.npc.CitizensNPC
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.citizensnpcs.api.npc.NPC
NPC.Metadata, NPC.NPCUpdate
-
Field Summary
Fields inherited from class net.citizensnpcs.api.npc.AbstractNPC
coloredNameComponentCache, coloredNameStringCache, traits
-
Constructor Summary
ConstructorDescriptionCitizensNPC
(UUID uuid, int id, String name, EntityController controller, NPCRegistry registry) -
Method Summary
Modifier and TypeMethodDescriptionboolean
despawn
(DespawnReason reason) Despawns this NPC.void
destroy()
Permanently removes this NPC and all data about it from the registry it's attached to.void
faceLocation
(Location location) Faces a givenLocation
if the NPC is spawned.getBlockBreaker
(Block targetBlock, BlockBreaker.BlockBreakerConfiguration config) Creates aBlockBreaker
that allows you to break blocks using the Minecraft breaking algorithm.Gets the Bukkit entity associated with this NPC.If the NPC is not spawned, then this method will return the last known location, or null if it has never been spawned.boolean
Returns whether this NPC is flyable or not.boolean
Gets whether this NPC is currently spawned.boolean
isUpdating
(NPC.NPCUpdate update) void
boolean
void
void
scheduleUpdate
(NPC.NPCUpdate update) void
Sets theEntityType
of this NPC.void
setEntityController
(EntityController newController) void
setFlyable
(boolean flyable) Sets whether this NPC is flyable or not.void
setMoveDestination
(Location destination) Set the target movement destination location to walk towards using Minecraft movement.protected void
setNameInternal
(String name) void
setSneaking
(boolean sneaking) boolean
boolean
boolean
Attempts to spawn this NPC.boolean
spawn
(Location at, SpawnReason reason) Attempts to spawn this NPC.void
teleport
(Location location, PlayerTeleportEvent.TeleportCause reason) An alternative tonpc.getEntity().getLocation()
that teleports passengers as well.toString()
void
update()
Methods inherited from class net.citizensnpcs.api.npc.AbstractNPC
addRunnable, addTrait, addTrait, clone, copy, data, despawn, destroy, equals, getDefaultGoalController, getDefaultSpeechController, getEntityType, getFullName, getId, getItemProvider, getMinecraftUniqueId, getName, getOrAddTrait, getOwningRegistry, getRawName, getTrait, getTraitFor, getTraitNullable, getTraits, getUniqueId, hashCode, hasTrait, isHiddenFrom, isProtected, isPushableByFluids, removeTrait, setAlwaysUseNameHologram, setItemProvider, setName, setProtected, setUseMinecraftAI, unloadEvents, useMinecraftAI
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.citizensnpcs.api.npc.NPC
getTraitOptional
-
Constructor Details
-
CitizensNPC
public CitizensNPC(UUID uuid, int id, String name, EntityController controller, NPCRegistry registry)
-
-
Method Details
-
despawn
Description copied from interface:NPC
Despawns this NPC.- Parameters:
reason
- The reason for despawning, for use inNPCDespawnEvent
- Returns:
- Whether this NPC was able to despawn
-
destroy
public void destroy()Description copied from interface:NPC
Permanently removes this NPC and all data about it from the registry it's attached to.- Specified by:
destroy
in interfaceNPC
- Overrides:
destroy
in classAbstractNPC
-
faceLocation
Description copied from interface:NPC
Faces a givenLocation
if the NPC is spawned. -
getBlockBreaker
public BlockBreaker getBlockBreaker(Block targetBlock, BlockBreaker.BlockBreakerConfiguration config) Description copied from interface:NPC
Creates aBlockBreaker
that allows you to break blocks using the Minecraft breaking algorithm. -
getEntity
Description copied from interface:NPC
Gets the Bukkit entity associated with this NPC. This may benull
ifNPC.isSpawned()
is false.- Returns:
- Entity associated with this NPC
-
getEntityController
-
getStoredLocation
Description copied from interface:NPC
If the NPC is not spawned, then this method will return the last known location, or null if it has never been spawned. Otherwise, it is equivalent to callingnpc.getBukkitEntity().getLocation()
.- Returns:
- The stored location, or
null
if none was found.
-
isFlyable
public boolean isFlyable()Description copied from interface:NPC
Returns whether this NPC is flyable or not.- Specified by:
isFlyable
in interfaceNPC
- Overrides:
isFlyable
in classAbstractNPC
- Returns:
- Whether this NPC is flyable
-
isSpawned
public boolean isSpawned()Description copied from interface:NPC
Gets whether this NPC is currently spawned.- Returns:
- Whether this NPC is spawned
-
isUpdating
-
load
Description copied from interface:NPC
Loads theNPC
from the givenDataKey
. This reloads all traits, respawns the NPC and sets it up for execution. Should not be called often.- Specified by:
load
in interfaceNPC
- Overrides:
load
in classAbstractNPC
- Parameters:
root
- The root data key
-
requiresNameHologram
public boolean requiresNameHologram()- Specified by:
requiresNameHologram
in interfaceNPC
- Overrides:
requiresNameHologram
in classAbstractNPC
-
save
Description copied from interface:NPC
Saves theNPC
to the givenDataKey
. This includes all metadata, traits, and spawn information that will allow it to respawn at a later time viaNPC.load(DataKey)
.- Specified by:
save
in interfaceNPC
- Overrides:
save
in classAbstractNPC
- Parameters:
root
- The root data key
-
scheduleUpdate
-
setBukkitEntityType
Description copied from interface:NPC
Sets theEntityType
of this NPC. The NPC will respawned if currently spawned, or will remain despawned otherwise.- Parameters:
type
- The new mob type
-
setEntityController
-
setFlyable
public void setFlyable(boolean flyable) Description copied from interface:NPC
Sets whether this NPC is flyable or not. Note that this is intended for normally ground-based entities only - it will generally have no effect on mob types that were originally flyable.- Specified by:
setFlyable
in interfaceNPC
- Overrides:
setFlyable
in classAbstractNPC
- Parameters:
flyable
-
-
setMoveDestination
Description copied from interface:NPC
Set the target movement destination location to walk towards using Minecraft movement. Should be set every tick.- Parameters:
destination
- The destinationLocation
-
setNameInternal
- Overrides:
setNameInternal
in classAbstractNPC
-
setSneaking
public void setSneaking(boolean sneaking) -
shouldRemoveFromPlayerList
public boolean shouldRemoveFromPlayerList() -
shouldRemoveFromTabList
public boolean shouldRemoveFromTabList()- Returns:
- Whether to remove the NPC from the tablist. Only applicable for
Player
-type NPCs.
-
spawn
Description copied from interface:NPC
Attempts to spawn this NPC.- Parameters:
at
- Location to spawn this NPC- Returns:
- Whether this NPC was able to spawn at the location
-
spawn
Description copied from interface:NPC
Attempts to spawn this NPC.- Parameters:
at
- Location to spawn this NPCreason
- Reason for spawning- Returns:
- Whether this NPC was able to spawn at the location
-
teleport
Description copied from interface:NPC
An alternative tonpc.getEntity().getLocation()
that teleports passengers as well.- Specified by:
teleport
in interfaceNPC
- Overrides:
teleport
in classAbstractNPC
- Parameters:
location
- The destination locationreason
- The cause for teleporting
-
toString
-
update
public void update()- Overrides:
update
in classAbstractNPC
-