Package net.citizensnpcs.trait
Class HologramTrait
java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.HologramTrait
Manages a set of holograms attached to the NPC. Holograms are lines of text or items that follow the NPC at
some offset (typically vertically offset).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static interface
API for rendering holograms.static class
static class
static class
static class
static class
A helper class that models a hologram as a single entity that represents a single line in game.static class
static class
static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new hologram line which will displayed over an NPC's head.void
addLine
(String text, HologramTrait.HologramRenderer hr) void
addTemporaryLine
(String text, int ticks) Adds a new hologram line which will displayed over an NPC's head.void
addTemporaryLine
(String text, int ticks, HologramTrait.HologramRenderer hr) void
clear()
Clears all hologram linesDeprecated.double
getLines()
Deprecated.int
void
insertLine
(int idx, String text) void
Loads a trait.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
Saves a trait.void
setBackgroundColor
(int idx, Color color) void
setDefaultBackgroundColor
(Color color) void
Sets the hologram line at a specific indexvoid
setLineHeight
(double height) Sets the line heightvoid
Sets the margin of a line at a specific indexvoid
setViewRange
(int range) Methods inherited from class net.citizensnpcs.api.trait.Trait
getName, getNPC, isRunImplemented, linkToNPC, onAttach, onCopy, onDespawn, onPreSpawn, onRemove
-
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
-
addLine
-
addTemporaryLine
Adds a new hologram line which will displayed over an NPC's head. It will not persist to disk and will last for the specified amount of ticks.- Parameters:
text
- The new line to addticks
- The number of ticks to last for
-
addTemporaryLine
-
clear
public void clear()Clears all hologram lines -
getDefaultBackgroundColor
-
getHologramEntities
Deprecated. -
getHologramRenderers
-
getLineHeight
public double getLineHeight()- Returns:
- The line height between each hologram line, in blocks
-
getLines
- Returns:
- the hologram lines, in bottom-up order
-
getNameEntity
Deprecated. -
getNameRenderer
-
getViewRange
public int getViewRange() -
insertLine
-
load
Description copied from class:Trait
Loads a trait. -
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. -
save
Description copied from class:Trait
Saves a trait. -
setBackgroundColor
-
setDefaultBackgroundColor
-
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:
-
setMargin
Sets the margin of a line at a specific index- Parameters:
idx
- The line indextype
- The margin type, top or bottommargin
- The margin
-
setViewRange
public void setViewRange(int range)
-