Greetings fellow developers and forum user, I am looking for a little assistance, as I am trying to develop a plugin for private use. I want the Entity (in this case, a player) to drop an item, when he dies (PlayerDeathEvent). However, I am unsure, how to actually "get the item to drop, after the player dies". I know how to define $player and how it dies. Regards, Zombie
If you're talking about player, use $ev->setDrops(array(Item::get(1,0,2),Item::get(198,0,1))); If you are talking about entity, use EntityDeathEvent and last damage cause
Can you please explain why you used... just want to make it clear for me and future Pocketmine developers. PHP: (array(Item::get(1,0,2),Item::get(198,0,1))); I am also clearly point at "get(1,0,2)"
#ReadTheDocs array() is creating an array. Item::get() is in the docs, it will return an Item instance. Google :: since knowing that will help. 1 is the id, 0 is the meta and 2 is the amount.
There is no difference, except that you handle different events (EntityDeathEvent and PlayerDeathEvent).
From PlayerDeathEvent you can change items that will be dropped with function setDrops($items) - $items is an array that must contain Item Objects, so you must create array: PHP: $items = array(); Then add the Item objects Item has function named get() that requires 3 attributes - id, meta/damage, ammount: PHP: // use pocketmine\item\Item;$items = array(Item::get(1, 0, 12), Item::get(264, 0, 6)); Now you've made array with items you want to set when player dies, now its time to set them as drops: PHP: $event->setDrops($items);