How in removeItem make items disappear only one number, but not immediately a 64 ? $item->setCount(1); or $item = Item::get(263, 0, 1); //doesn't work
A little more information would have assisted him, understanding how this works . So basically, the code, @wolfdale posted above gets the Inventory of $player (in this case, you can define $player with whatever event you want to define it as, Example: Lets say, I decided to utilise PlayerDeathEvent, and define $player as $event->getPlayer();, this basically means that your code will be activated as soon as the players dies, as we made a public function and defined $event with PlayerDeath Event). You can tell (with basic knowledge) that getInventory() would get the Inventory of the player that died. removeItem is also quite as it seems, as you are using it to remove a certain item from that players inventory. When @wolfdale utilised Item::get(), (also known as getItem() ), it allowed him to get a specified item. Finally, the numbers inside Item::get are basically id, meta, amount, so therefore, in this case, the 1 of the items with the id 263, would be removed, after a player dies (Meta is usually 0). Final code, if I decided to use PlayerDeathEvent PHP: public function(PlayerDeathEvent $event){$player = $event->getPlayer();$player->getInventory()->removeItem(Item::get(263, 0, 1);} If you want more information, on how these functions work together to produce a final working code (Example: Player extends Human etc..), you can simply message me here, or on the contact methods listed below
I wrote. It does not work because it is consumed immediately stack (64), and I need to consume one coal.
Item::get() and getItem() have the same function, but you have to use ->getItem(), unlike Item::get, whereas Item::get is certainly more efficient than ->getItem()