jobukkit
jobukkit

Reputation: 2670

How to move a dropped item?

After having dropped an item using world.dropItem() or world.dropItemNaturally(), how do I move it?

Upvotes: 0

Views: 1059

Answers (1)

MrLore
MrLore

Reputation: 3780

The method org.bukkit.entity.Item#teleport(Location location) will allow you to teleport the item to another position. You'd use it like this:

final Location dropLocation = new Location(world, x, y, z);
final Location teleportLocation = new Location(world, x + 1, y + 1, z + 1);

final Item dropped = world.dropItem(dropLocation, new ItemStack(Block.anvil));
dropped.teleport(teleportLocation);

Though you may need to use a timer to do this, or it may happen too fast to notice.

Upvotes: 3

Related Questions