Let EntityItems alive

Discussion in 'Plugin Development' started by needspeed10, Sep 21, 2011.

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

    needspeed10

    Hi.

    EntityItems (dropped Items) are only 6000 ticks(=5 minutes) alive.
    I wanted to prevent my ItemEntity of beeing killed.
    So I tried this code:
    Code:java
    1. net.minecraft.server.EntityItem entityItem = (net.minecraft.server.EntityItem)((org.bukkit.craftbukkit.entity.CraftEntity)entity).getHandle();
    2. entityItem.b = 20;

    It's repeated every few ticks.
    The first five minutes it's working, but then the item is flickering.
    Any idea?
     
  2. Offline

    Afforess

    Probably because the counter also ran client side, where it died naturally. Try sending an entity killed and entity spawned every few minutes to trick the client...
     
  3. Offline

    needspeed10

    I was already aware of this option (works for me fine). Anyway I hoped, that it would work in somekind of this way better. Thank you all the same Afforess.

    However... For the users, who will watch this, here's the code:
    Code:java
    1. EntityItem entityItem = (EntityItem)((org.bukkit.craftbukkit.entity.CraftEntity)entity).getHandle();
    2. if(entityItem.b >= 5000)//if it lived more than 5000 ticks(250 seconds)
    3. {
    4. Entity newEntity = entity.getWorld().dropItem(entity.getLocation(), new ItemStack(Material.SLIME_BALL,1)); //can be every item ofcourse
    5. entityItem.die();
    6. this.entity = newEntity; //just to save it in a variable
    7. }
     
Thread Status:
Not open for further replies.

Share This Page