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 Jul 26, 2014 · 11 revisions

You can create floating/holographic items in the same way you create text holograms, passing an ItemStack instead of Strings.

 

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 FloatingItem floatingItem = HolographicDisplaysAPI.createFloatingItem(plugin, loc, itemStack);

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

A FloatingItem has many methods in common with a Hologram, can also be touch.