Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Floating items

filoghost edited this page Apr 10, 2021 · 11 revisions

You can create floating items in the same way you create text lines, by using the method appendItemLine(...).  

Example

A floating melon block created above a player's head, 5 seconds later the melon block turns into a melon slice.

Location loc = player.getLocation().add(0.0, 2.0, 0.0);
ItemStack itemStack = new ItemStack(Material.MELON_BLOCK);
final Hologram hologram = HologramsAPI.createHologram(plugin, loc);
ItemLine itemLine = hologram.appendItemLine(itemStack);

new BukkitRunnable() {
	@Override
	public void run() {
		itemLine.setItemStack(new ItemStack(Material.MELON));
	}
}.runTaskLater(plugin, 5 * 20);