mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32: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:
@ -621,32 +621,6 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
return $this->block !== null and $this->block->canBePlaced();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an entity can eat or drink this item.
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeConsumed() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this item can be consumed by the supplied Entity.
|
||||
* @param Entity $entity
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeConsumedBy(Entity $entity) : bool{
|
||||
return $this->canBeConsumed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the item is consumed by an Entity.
|
||||
* @param Entity $entity
|
||||
*/
|
||||
public function onConsume(Entity $entity){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block corresponding to this Item.
|
||||
* @return Block
|
||||
|
Reference in New Issue
Block a user