Hello! i tried to make keep inventory when the player dies it works in all cases except [VOID DEATH] so when the player fall out in the void his inventory become empty. I tried: PHP: public function onDeath(PlayerDeathEvent $event){$player = $event->getEntity();if($player instanceof EntityDamageEvent){if($player->getCause() == EntityDamageEvent::CAUSE_VOID){$event->setKeepInventory(true);}}} But it is not work. So how i can fix it?
All of your methods are wrong, PHP: public function ondeath(PlayerDeathEvent $event){ $player = $event->getPlayer(); if($player->getLastDamageCause()->getCause() == EntityDamageEvent::CAUSE_VOID){ $event->setKeepInventory(true); }} FAQ: $player->getLastDamageCause() returns an instance of EntityDamageEvent, so you can do $player->getLastDamageCause()->getCause() You can use both $player = $event->getEntity() or $player = $event->getPlayer(); as both returns same thing
Did either of you notice that the event causes the inventory only to be kept when the player dies in the void rather than "when the player fall out in the void his inventory become empty"
I tried this but i have a new proplem when i death my items back but when i tap on respawn button my inventory become empty!