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
ConstructorsConstructorDescriptionCitizensNPC(UUID uuid, int id, String name, EntityController controller, NPCRegistry registry) -
Method Summary
Modifier and TypeMethodDescriptionbooleandespawn(DespawnReason reason) Despawns this NPC.voiddestroy()Permanently removes this NPC and all data about it from the registry it's attached to.voidfaceLocation(Location location) Faces a givenLocationif the NPC is spawned.getBlockBreaker(Block targetBlock, BlockBreaker.BlockBreakerConfiguration config) Creates aBlockBreakerthat 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.booleanReturns whether this NPC is flyable or not.booleanGets whether this NPC is currently spawned.booleanisUpdating(NPC.NPCUpdate update) voidbooleanvoidvoidscheduleUpdate(NPC.NPCUpdate update) voidSets theEntityTypeof this NPC.voidsetEntityController(EntityController newController) voidsetFlyable(boolean flyable) Sets whether this NPC is flyable or not.voidsetMoveDestination(Location destination) Set the destination location to walk towards in a straight line using Minecraft movement.protected voidsetNameInternal(String name) voidsetSneaking(boolean sneaking) booleanbooleanbooleanspawn(Location at, SpawnReason reason, Consumer<Entity> callback) Attempts to spawn this NPC.voidteleport(Location location, PlayerTeleportEvent.TeleportCause reason) An alternative tonpc.getEntity().getLocation()that teleports passengers as well.toString()voidupdate()Methods inherited from class net.citizensnpcs.api.npc.AbstractNPC
addRunnable, addTrait, addTrait, clone, copy, data, equals, getDefaultGoalController, getDefaultSpeechController, getEntityType, getFullName, getId, getItemProvider, getMinecraftUniqueId, getName, getOrAddTrait, getOwningRegistry, getRawName, getTrait, getTraitFor, getTraitNullable, getTraits, getUniqueId, hashCode, hasTrait, removeTrait, setItemProvider, setNameMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.citizensnpcs.api.npc.NPC
despawn, destroy, getTraitOptional, isHiddenFrom, isProtected, isPushableByFluids, setAlwaysUseNameHologram, setProtected, setUseMinecraftAI, spawn, spawn, useMinecraftAI
-
Constructor Details
-
CitizensNPC
public CitizensNPC(UUID uuid, int id, String name, EntityController controller, NPCRegistry registry)
-
-
Method Details
-
despawn
Description copied from interface:NPCDespawns 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:NPCPermanently removes this NPC and all data about it from the registry it's attached to.- Specified by:
destroyin interfaceNPC- Overrides:
destroyin classAbstractNPC
-
faceLocation
Description copied from interface:NPCFaces a givenLocationif the NPC is spawned. -
getBlockBreaker
public BlockBreaker getBlockBreaker(Block targetBlock, BlockBreaker.BlockBreakerConfiguration config) Description copied from interface:NPCCreates aBlockBreakerthat allows you to break blocks using the Minecraft breaking algorithm. -
getEntity
Description copied from interface:NPCGets the Bukkit entity associated with this NPC. This may benullifNPC.isSpawned()is false.- Returns:
- Entity associated with this NPC
-
getEntityController
-
getStoredLocation
Description copied from interface:NPCIf 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
nullif none was found.
-
isFlyable
public boolean isFlyable()Description copied from interface:NPCReturns whether this NPC is flyable or not.- Returns:
- Whether this NPC is flyable
-
isSpawned
public boolean isSpawned()Description copied from interface:NPCGets whether this NPC is currently spawned.- Returns:
- Whether this NPC is spawned
-
isUpdating
-
load
Description copied from interface:NPCLoads theNPCfrom the givenDataKey. This reloads all traits, respawns the NPC and sets it up for execution. Should not be called often.- Specified by:
loadin interfaceNPC- Overrides:
loadin classAbstractNPC- Parameters:
root- The root data key
-
requiresNameHologram
public boolean requiresNameHologram()- Specified by:
requiresNameHologramin interfaceNPC- Overrides:
requiresNameHologramin classAbstractNPC
-
save
Description copied from interface:NPCSaves theNPCto 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:
savein interfaceNPC- Overrides:
savein classAbstractNPC- Parameters:
root- The root data key
-
scheduleUpdate
-
setBukkitEntityType
Description copied from interface:NPCSets theEntityTypeof 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:NPCSets 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.- Parameters:
flyable-
-
setMoveDestination
Description copied from interface:NPCSet the destination location to walk towards in a straight line using Minecraft movement. Should be called every tick.- Parameters:
destination- The destinationLocation
-
setNameInternal
- Overrides:
setNameInternalin 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:NPCAttempts to spawn this NPC.- Parameters:
reason- Reason for spawningcallback- The callback to run once entity is spawned- Returns:
- Whether this NPC was able to spawn at the location
-
teleport
Description copied from interface:NPCAn alternative tonpc.getEntity().getLocation()that teleports passengers as well.- Specified by:
teleportin interfaceNPC- Overrides:
teleportin classAbstractNPC- Parameters:
location- The destination locationreason- The cause for teleporting
-
toString
-
update
public void update()- Overrides:
updatein classAbstractNPC
-