From 7a5df07ee51a906ee43b4e633ee97d57ea7fa041 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 25 May 2013 22:36:13 +0200 Subject: [PATCH] Fixed #220 Players now drop items on death [gh#220] --- src/world/Entity.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/world/Entity.php b/src/world/Entity.php index bc5327da97..5d41ab199a 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -73,7 +73,6 @@ class Entity extends Position{ $this->health = 20; $this->dmgcounter = array(0, 0, 0); $this->air = 300; - $this->onground = true; $this->fire = 0; $this->crouched = false; $this->invincible = false; @@ -129,7 +128,18 @@ class Entity extends Position{ } public function getDrops(){ - if($this->class === ENTITY_OBJECT){ + if($this->class === ENTITY_PLAYER){ + $inv = array(); + $air = BlockAPI::getItem(AIR, 0, 0); + for($i = 0; $i < 36; ++$i){ + $slot = $this->player->getSlot($i); + $this->player->setSlot($i, $air); + if($slot->getID() !== AIR and $slot->count > 0){ + $inv[] = array($slot->getID(), $slot->getMetadata(), $slot->count); + } + } + return $inv; + }elseif($this->class === ENTITY_OBJECT){ switch($this->type){ case OBJECT_PAINTING: return array(