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 SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic interfaceAPI for rendering holograms.static classstatic classstatic classstatic classstatic classA helper class that models a hologram as a single entity that represents a single line in game.static classstatic classstatic class
- 
Field Summary
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds a new hologram line which will displayed over an NPC's head.voidaddLine(String text, HologramTrait.HologramRenderer hr) voidaddTemporaryLine(String text, int ticks) Adds a new hologram line which will displayed over an NPC's head.voidaddTemporaryLine(String text, int ticks, HologramTrait.HologramRenderer hr) voidclear()Clears all hologram linesDeprecated.doublegetLines()Deprecated.intvoidinsertLine(int idx, String text) booleanvoidLoads a trait.voidCalled just before the attachedNPCis despawned.voidonRemove()Called when a trait is removed from the attachedNPC.voidonSpawn()Called when anNPCis spawned.voidremoveLine(int idx) Removes the line at the specified indexvoidrun()Called every tick if overridden.voidSaves a trait.voidsetBackgroundColor(int idx, Color color) voidsetDefaultBackgroundColor(Color color) voidsetDefaultTextShadow(boolean shadow) voidSets the hologram line at a specific indexvoidsetLineHeight(double height) Sets the line heightvoidSets the margin of a line at a specific indexvoidsetTextShadow(int idx, boolean shadow) voidsetViewRange(int range) Methods inherited from class net.citizensnpcs.api.trait.TraitgetName, getNPC, isRunImplemented, linkToNPC, onAttach, onCopy, onDespawn, onPreSpawn, onRemove
- 
Constructor Details- 
HologramTraitpublic HologramTrait()
 
- 
- 
Method Details- 
addLineAdds a new hologram line which will displayed over an NPC's head.- Parameters:
- text- The new line to add
 
- 
addLine
- 
addTemporaryLineAdds 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 add
- ticks- The number of ticks to last for
 
- 
addTemporaryLine
- 
clearpublic void clear()Clears all hologram lines
- 
getDefaultBackgroundColor
- 
getHologramEntitiesDeprecated.
- 
getHologramRenderers
- 
getLineHeightpublic double getLineHeight()- Returns:
- The line height between each hologram line, in blocks
 
- 
getLines- Returns:
- the hologram lines, in bottom-up order
 
- 
getNameEntityDeprecated.
- 
getNameRenderer
- 
getViewRangepublic int getViewRange()
- 
insertLine
- 
isDefaultTextShadowpublic boolean isDefaultTextShadow()
- 
loadDescription copied from class:TraitLoads a trait.
- 
onDespawnpublic void onDespawn()Description copied from class:TraitCalled just before the attachedNPCis despawned.NPC.getEntity()will be non-null.
- 
onRemovepublic void onRemove()Description copied from class:TraitCalled when a trait is removed from the attachedNPC.
- 
onSpawnpublic void onSpawn()Description copied from class:TraitCalled when anNPCis spawned.NPC.getEntity()will return null until this is called. This is also called onAttach when the NPC is already spawned.
- 
removeLinepublic void removeLine(int idx) Removes the line at the specified index- Parameters:
- idx-
 
- 
runpublic void run()Description copied from class:TraitCalled every tick if overridden.
- 
saveDescription copied from class:TraitSaves a trait.
- 
setBackgroundColor
- 
setDefaultBackgroundColor
- 
setDefaultTextShadowpublic void setDefaultTextShadow(boolean shadow) 
- 
setLineSets the hologram line at a specific index- Parameters:
- idx- The index
- text- The new line
 
- 
setLineHeightpublic void setLineHeight(double height) Sets the line height- Parameters:
- height- The line height in blocks
- See Also:
 
- 
setMarginSets the margin of a line at a specific index- Parameters:
- idx- The line index
- type- The margin type, top or bottom
- margin- The margin
 
- 
setTextShadowpublic void setTextShadow(int idx, boolean shadow) 
- 
setViewRangepublic void setViewRange(int range) 
 
-