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
Nested 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 Summary
Constructors -
Method Summary
Modifier 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.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
-
isDefaultTextShadow
public boolean isDefaultTextShadow() -
load
Description copied from class:TraitLoads a trait. -
onDespawn
public void onDespawn()Description copied from class:TraitCalled just before the attachedNPCis despawned.NPC.getEntity()will be non-null. -
onRemove
public void onRemove()Description copied from class:TraitCalled when a trait is removed from the attachedNPC. -
onSpawn
public 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. -
removeLine
public void removeLine(int idx) Removes the line at the specified index- Parameters:
idx-
-
run
public void run()Description copied from class:TraitCalled every tick if overridden. -
save
Description copied from class:TraitSaves a trait. -
setBackgroundColor
-
setDefaultBackgroundColor
-
setDefaultTextShadow
public void setDefaultTextShadow(boolean shadow) -
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
-
setTextShadow
public void setTextShadow(int idx, boolean shadow) -
setViewRange
public void setViewRange(int range)
-