mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 22:45:28 +00:00
Fixed #1889 Players drop their inventory when they die
This commit is contained in:
parent
3c231118a6
commit
34711dc346
@ -2178,6 +2178,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return;
|
||||
}
|
||||
parent::kill();
|
||||
|
||||
if($this->inventory !== null){
|
||||
$this->inventory->clearAll();
|
||||
}
|
||||
|
||||
$message = $this->getName() ." died";
|
||||
$cause = $this->getLastDamageCause();
|
||||
$ev = null;
|
||||
|
@ -80,6 +80,20 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
return $this->nameTag;
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
$drops = [];
|
||||
if($this->inventory instanceof PlayerInventory){
|
||||
foreach($this->inventory->getContents() as $item){
|
||||
$drops[] = $item;
|
||||
}
|
||||
|
||||
foreach($this->inventory->getArmorContents() as $item){
|
||||
$drops[] = $item;
|
||||
}
|
||||
}
|
||||
return $drops;
|
||||
}
|
||||
|
||||
public function saveNBT(){
|
||||
parent::saveNBT();
|
||||
$this->namedtag->Inventory = new Enum("Inventory", []);
|
||||
|
@ -259,6 +259,13 @@ class PlayerInventory extends BaseInventory{
|
||||
return $armor;
|
||||
}
|
||||
|
||||
public function clearAll(){
|
||||
$limit = $this->getSize() + 4;
|
||||
for($index = 0; $index < $limit; ++$index){
|
||||
$this->clear($index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player|Player[] $target
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user