Problem with onEntityDeath and onEntityDamage.

Discussion in 'Plugin Development' started by Taien, Nov 17, 2011.

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

    Taien

    So, I'm trying to make a plugin that stores a player's items when they die so that when they respawn their items are given back to them. This means that the player's items can't be dropped on the ground. Now, onEntityDeath fires after the items are dropped (or at least appears to) and so I can't use that. However, if I use onEntityDamage, which is what I am doing, I can't correctly determine when someone is going to die, because armor is not taken into account. Is there a way to determine how much armor absorption a person has without doing a ton of math? Or maybe another way to do this that I haven't thought of?

    Please assist. :(
     
  2. Offline

    nisovin

    The EntityDeathEvent fires before items are dropped. It has a getDrops() method that returns a List. You can clear that list to cancel all drops.
     
  3. Offline

    Taien

    Really? I looked into that a little and noticed there was no setDrops(List<ItemStack> list) so I figured that was impossible...but you're sure if I clear the list it will work? I'll give it a try.

    Worked! Thanks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
Thread Status:
Not open for further replies.

Share This Page