Consumables refactor (#1796)

* Removed broken EntityEatEvents - these don't fit the pattern since they only apply to Human entities anyway. PlayerItemConsumeEvent and PlayerInteractEvent can be used for cancellation purposes, and plugins can do custom stuff without mess.

* Restrict item consuming to Living entities only

* Added FoodSource->requiresHunger()

* Only items implementing the Consumable interface can now be consumed.

* The effects from consuming items are now generic-ized by way of the Living->consume() function. This is overridden in Human to allow applying food and hunger.

* Fixed the hardcoded mess for buckets
This commit is contained in:
Dylan K. Taylor
2017-12-23 13:03:41 +00:00
committed by GitHub
parent 329fe7d844
commit 6e1df36188
14 changed files with 113 additions and 306 deletions

View File

@ -23,9 +23,18 @@ declare(strict_types=1);
namespace pocketmine\item;
/**
* Interface implemented by objects that can be consumed by players, giving them food and saturation.
*/
interface FoodSource extends Consumable{
public function getFoodRestore() : int;
public function getSaturationRestore() : float;
/**
* Returns whether a Human eating this FoodSource must have a non-full hunger bar.
* @return bool
*/
public function requiresHunger() : bool;
}