Class HologramTrait

java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.HologramTrait
All Implemented Interfaces:
Runnable, Listener

public class HologramTrait extends Trait
Persists a hologram attached to the NPC.
  • Constructor Details

    • HologramTrait

      public HologramTrait()
  • Method Details

    • addLine

      public void addLine(String text)
      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

      public HologramTrait.HologramDirection getDirection()
      Returns:
      The direction that hologram lines are displayed in
    • getHologramEntities

      public Collection<ArmorStand> 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

      public List<String> getLines()
      Returns:
      the hologram lines, in bottom-up order
    • getNameEntity

      public ArmorStand 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 attached NPC is despawned. NPC.getEntity() will be non-null.
      Overrides:
      onDespawn in class Trait
    • onRemove

      public void onRemove()
      Description copied from class: Trait
      Called when a trait is removed from the attached NPC.
      Overrides:
      onRemove in class Trait
    • onSpawn

      public void onSpawn()
      Description copied from class: Trait
      Called when an NPC is spawned. NPC.getEntity() will return null until this is called. This is also called onAttach when the NPC is already spawned.
      Overrides:
      onSpawn in class Trait
    • 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.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Trait
    • setDirection

      public void setDirection(HologramTrait.HologramDirection direction)
      Parameters:
      direction - The new direction
      See Also:
    • setLine

      public void setLine(int idx, String text)
      Sets the hologram line at a specific index
      Parameters:
      idx - The index
      text - The new line
    • setLineHeight

      public void setLineHeight(double height)
      Sets the line height
      Parameters:
      height - The line height in blocks
      See Also: