mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 03:06:55 +00:00
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:
@ -23,14 +23,32 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\entity\Effect;
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
/**
|
||||
* Interface implemented by objects that can be consumed by mobs.
|
||||
*/
|
||||
interface Consumable{
|
||||
|
||||
/**
|
||||
* Returns the leftover that this Consumable produces when it is consumed. For Items, this is usually air, but could
|
||||
* be an Item to add to a Player's inventory afterwards (such as a bowl).
|
||||
*
|
||||
* @return Item|Block|mixed
|
||||
*/
|
||||
public function getResidue();
|
||||
|
||||
/**
|
||||
* @return Effect[]
|
||||
*/
|
||||
public function getAdditionalEffects() : array;
|
||||
|
||||
/**
|
||||
* Called when this Consumable is consumed by mob, after standard resulting effects have been applied.
|
||||
*
|
||||
* @param Living $consumer
|
||||
*/
|
||||
public function onConsume(Living $consumer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user