Package net.citizensnpcs.trait
Class HologramTrait
java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.HologramTrait
Persists a hologram attached to the NPC.
-
Nested Class Summary
Nested Classes -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new hologram line which will displayed over an NPC's head.void
clear()
Clears all hologram linesNote: this is implementation-specific and may be removed at a later date.double
getLines()
Note: this is implementation-specific and may be removed at a later date.void
Called just before the attachedNPC
is despawned.void
onRemove()
Called when a trait is removed from the attachedNPC
.void
onSpawn()
Called when anNPC
is spawned.void
removeLine
(int idx) Removes the line at the specified indexvoid
run()
Called every tick if overridden.void
setDirection
(HologramTrait.HologramDirection direction) void
Sets the hologram line at a specific indexvoid
setLineHeight
(double height) Sets the line heightMethods inherited from class net.citizensnpcs.api.trait.Trait
getName, getNPC, isRunImplemented, linkToNPC, load, onAttach, onCopy, onPreSpawn, save
-
Constructor Details
-
HologramTrait
public HologramTrait()
-
-
Method Details
-
addLine
Adds a new hologram line which will displayed over an NPC's head.- Parameters:
text
- The new line to add
-
clear
public void clear()Clears all hologram lines -
getDirection
- Returns:
- The direction that hologram lines are displayed in
-
getHologramEntities
Note: this is implementation-specific and may be removed at a later date. -
getLineHeight
public double getLineHeight()- Returns:
- The line height between each hologram line, in blocks
-
getLines
- Returns:
- the hologram lines, in bottom-up order
-
getNameEntity
Note: this is implementation-specific and may be removed at a later date. -
onDespawn
public void onDespawn()Description copied from class:Trait
Called just before the attachedNPC
is despawned.NPC.getEntity()
will be non-null. -
onRemove
public void onRemove()Description copied from class:Trait
Called when a trait is removed from the attachedNPC
. -
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. -
removeLine
public void removeLine(int idx) Removes the line at the specified index- Parameters:
idx
-
-
run
public void run()Description copied from class:Trait
Called every tick if overridden. -
setDirection
- Parameters:
direction
- The new direction- See Also:
-
setLine
Sets the hologram line at a specific index- Parameters:
idx
- The indextext
- The new line
-
setLineHeight
public void setLineHeight(double height) Sets the line height- Parameters:
height
- The line height in blocks- See Also:
-