Solved How to change the despawn delay/ticks for an Item Entity?

Discussion in 'Plugin Development' started by Steffion, Feb 11, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Steffion

    Hello all,

    I want to spawn an item that least for 5 seconds and is unable to pickup.
    This is my code:

    Code:
            Location location = new Location(null, player.getLocation().getX() + 5, player.getLocation().getY() + 5, player.getLocation().getZ());
            Item item = player.getWorld().dropItemNaturally(location, new ItemStack(Material.LEAVES, 5));
            item.setTicksLived(5900);
            item.setPickupDelay(5000);

    (its an example)

    But the SetTicksLived wont work? please help!

    Is this even possible though xD?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  2. Offline

    RealDope

    Spawn it, start a scheduler to remove it in 5 seconds.
     
  3. Offline

    Steffion

    RealDope Is there not a way to edit the Entity it self?
     
  4. maybe meta data but idk about that...maybe also take a look at showcase standalone...
     
  5. Offline

    Steffion

    CaptainBern Meta is more for the name and lore I thought. I will look at that.
    And also thanks for the tip of Showcase Standalone.
     
    CaptainBern likes this.
  6. yeah im not sure about the meta data
     
  7. Offline

    Steffion

    CaptainBern Maybe I should change the NBT-Value? Lets try that tomorrow !
     
  8. Offline

    Steffion

    I found a way to edit the "Age" of the Dropped entity with NTB edit.
    But still thanks CaptainBern.

    (Solved :))
     
  9. Offline

    Loogeh

    Steffion Can you share it with us please? I'm looking to do the same thing :)

    EDIT: Nevermind, found it out.
    Code:
    ((EntityItem) ((CraftItem) item).getHandle()).age = desired_age;
     
    biel likes this.
Thread Status:
Not open for further replies.

Share This Page