mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Fixed #1889 Players drop their inventory when they die
This commit is contained in:
@ -2178,6 +2178,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
parent::kill();
|
parent::kill();
|
||||||
|
|
||||||
|
if($this->inventory !== null){
|
||||||
|
$this->inventory->clearAll();
|
||||||
|
}
|
||||||
|
|
||||||
$message = $this->getName() ." died";
|
$message = $this->getName() ." died";
|
||||||
$cause = $this->getLastDamageCause();
|
$cause = $this->getLastDamageCause();
|
||||||
$ev = null;
|
$ev = null;
|
||||||
|
@ -80,6 +80,20 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
return $this->nameTag;
|
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(){
|
public function saveNBT(){
|
||||||
parent::saveNBT();
|
parent::saveNBT();
|
||||||
$this->namedtag->Inventory = new Enum("Inventory", []);
|
$this->namedtag->Inventory = new Enum("Inventory", []);
|
||||||
|
@ -259,6 +259,13 @@ class PlayerInventory extends BaseInventory{
|
|||||||
return $armor;
|
return $armor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clearAll(){
|
||||||
|
$limit = $this->getSize() + 4;
|
||||||
|
for($index = 0; $index < $limit; ++$index){
|
||||||
|
$this->clear($index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Player|Player[] $target
|
* @param Player|Player[] $target
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user