From e9683ff5d2d6110715da7019183011a678c0c33b Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 7 Jun 2013 19:04:02 +0200 Subject: [PATCH] Fixed eating --- src/Player.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Player.php b/src/Player.php index 27d6ba94b..6d12754af 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1407,13 +1407,15 @@ class Player{ RAW_FISH => 2, ); - if($this->entity->getHealth() < 20 and isset($items[$this->getSlot($this->slot)->getID()])){ - if($this->removeItem($this->getSlot($this->slot)->getID(), $this->getSlot($this->slot)->getMetadata(), 1, false) === true){ - $this->dataPacket(MC_ENTITY_EVENT, array( - "eid" => 0, - "event" => 9, - )); - $this->entity->heal($items[$this->getSlot($this->slot)->getID()], "eating"); + if($this->entity->getHealth() < 20 and isset($items[($slot = $this->getSlot($this->slot))->getID()])){ + $this->dataPacket(MC_ENTITY_EVENT, array( + "eid" => 0, + "event" => 9, + )); + $this->entity->heal($items[$slot->getID()], "eating"); + --$slot->count; + if($slot->count <= 0){ + $this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false); } } break;