You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
goflishMC edited this page Aug 20, 2023
·
2 revisions
"hologram" is a Hologram object we've already created. Read the API basic tutorial if you haven't yet.
Let's start by adding five lines to the hologram:
for (int i = 1; i <= 5; i++) {
hologram.getLines().appendText(Integer.toString(i));
}
Let's insert a bedrock block before the first line, then change it to grass:
ItemLine itemLine = hologram.getLines().insertItem(0, new ItemStack(Material.BEDROCK));
itemLine.setItemStack(new ItemStack(Material.GRASS));
We want to change the last line with a sponge now:
hologram.getLines().remove(hologram.size() - 1); // Remember how arrays work, it's the same here
hologram.getLines().appendItem(new ItemStack(Material.SPONGE));
Use the javadocs to see all the methods. These are just some basic ones.
Notes:
Indexes start from 0, as in normal arrays.
If you specify an invalid index, an ArrayOutOfBoundsException will be raised.