Make players not drop certain items on death?

Discussion in 'Plugin Development' started by Phinary, Jul 14, 2012.

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

    Phinary

    I want to give each player a wool hat when they spawn, the issue is that after a lot of people die, there is a ton of wool everywhere. I was wondering if it is possible to make it so that the player does not drop the wool when they die, but they do drop all their other items. I was trying to do stuff with onPlayerDeath events but I couldn't find a way to modify the drops when someone dies. Can someone please help me out?

    Thanks
     
  2. you can modifty drops on the entityDeathEvent
     
  3. Offline

    Phinary

    How would I do this? It seems to let me get the drops, but it doesn't let me modify them.
     
  4. event.getDrops.clear()
    removed al drops, and then you say you can modify?
     
  5. Offline

    Kodfod

    Or you could save all the items in an array and remove items from a config then drop the rest
     
  6. Offline

    Phinary

    Okay so, I tried doing this:

    public void onEntityDeath(EntityDeathEvent event) {
    if (event.getEntity() instanceof Player) {
    event.getDrops().remove(103);
    }
    }

    From minecraft wiki, 103 should be the slot of the helmet, so it should make them not drop their helmet? Is this wrong? It doesn't seem to work
     
  7. Offline

    CubixCoders

    My guess is that that is removing the item Id "103" on death, if you want it to be only at a certain time use a Boolean and then do
    if(Boolean){
    event.getDrops.remove(20);
    }
    Just a guess
     
  8. Offline

    Ne0nx3r0

    Sorry to resurrect the thread, but would this also work?

    Code:
        public void onEntityDeath(EntityDeathEvent e)
        {
            if(e.getEntity() instanceof Player)
            {
                for(ItemStack isDrop : e.getDrops())
                {
                    if(condition)
                    {
                        e.getDrops().remove(isDrop);
                    }
                }
            }
        }
    
     
Thread Status:
Not open for further replies.

Share This Page