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 Jun 4, 2022 · 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);
HolographicDisplaysAPI api = HolographicDisplaysAPI.get(plugin);
final Hologram hologram = api.createHologram(loc);
ItemHologramLine itemLine = hologram.getLines().appendItem(itemStack);

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