diff --git a/src/block/Cake.php b/src/block/Cake.php index 200d2e2a3..4554c71a0 100644 --- a/src/block/Cake.php +++ b/src/block/Cake.php @@ -25,8 +25,8 @@ namespace pocketmine\block; use pocketmine\block\utils\BlockDataSerializer; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\FoodSource; use pocketmine\entity\Living; -use pocketmine\item\FoodSource; use pocketmine\item\Item; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; diff --git a/src/item/Consumable.php b/src/entity/Consumable.php similarity index 76% rename from src/item/Consumable.php rename to src/entity/Consumable.php index c4b809adc..650c1dd08 100644 --- a/src/item/Consumable.php +++ b/src/entity/Consumable.php @@ -21,25 +21,14 @@ declare(strict_types=1); -namespace pocketmine\item; +namespace pocketmine\entity; -use pocketmine\block\Block; use pocketmine\entity\effect\EffectInstance; -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 EffectInstance[] */ diff --git a/src/item/FoodSource.php b/src/entity/FoodSource.php similarity index 97% rename from src/item/FoodSource.php rename to src/entity/FoodSource.php index ddddb4a94..e30ece5d3 100644 --- a/src/item/FoodSource.php +++ b/src/entity/FoodSource.php @@ -21,7 +21,7 @@ declare(strict_types=1); -namespace pocketmine\item; +namespace pocketmine\entity; /** * Interface implemented by objects that can be consumed by players, giving them food and saturation. diff --git a/src/entity/Human.php b/src/entity/Human.php index b694f9013..9233b25d3 100644 --- a/src/entity/Human.php +++ b/src/entity/Human.php @@ -32,9 +32,7 @@ use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\player\PlayerExhaustEvent; use pocketmine\inventory\InventoryHolder; use pocketmine\inventory\PlayerInventory; -use pocketmine\item\Consumable; use pocketmine\item\enchantment\Enchantment; -use pocketmine\item\FoodSource; use pocketmine\item\Item; use pocketmine\item\Totem; use pocketmine\math\Vector3; diff --git a/src/entity/Living.php b/src/entity/Living.php index 27cf829aa..8675dd00a 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -39,7 +39,6 @@ use pocketmine\inventory\ArmorInventory; use pocketmine\inventory\CallbackInventoryListener; use pocketmine\inventory\Inventory; use pocketmine\item\Armor; -use pocketmine\item\Consumable; use pocketmine\item\Durable; use pocketmine\item\enchantment\Enchantment; use pocketmine\item\Item; diff --git a/src/item/BeetrootSoup.php b/src/item/BeetrootSoup.php index 267131739..4ddab67f2 100644 --- a/src/item/BeetrootSoup.php +++ b/src/item/BeetrootSoup.php @@ -37,7 +37,7 @@ class BeetrootSoup extends Food{ return 7.2; } - public function getResidue(){ + public function getResidue() : Item{ return VanillaItems::BOWL(); } } diff --git a/src/item/ConsumableItem.php b/src/item/ConsumableItem.php new file mode 100644 index 000000000..54e661877 --- /dev/null +++ b/src/item/ConsumableItem.php @@ -0,0 +1,38 @@ +potionId); } - public function getResidue(){ + public function getResidue() : Item{ return VanillaItems::GLASS_BOTTLE(); } } diff --git a/src/item/RabbitStew.php b/src/item/RabbitStew.php index 6117a0be1..294cc772b 100644 --- a/src/item/RabbitStew.php +++ b/src/item/RabbitStew.php @@ -37,7 +37,7 @@ class RabbitStew extends Food{ return 12; } - public function getResidue(){ + public function getResidue() : Item{ return VanillaItems::BOWL(); } } diff --git a/src/player/Player.php b/src/player/Player.php index c4891d155..304135230 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -73,7 +73,7 @@ use pocketmine\form\Form; use pocketmine\form\FormValidationException; use pocketmine\inventory\Inventory; use pocketmine\inventory\PlayerCursorInventory; -use pocketmine\item\Consumable; +use pocketmine\item\ConsumableItem; use pocketmine\item\enchantment\EnchantmentInstance; use pocketmine\item\enchantment\MeleeWeaponEnchantment; use pocketmine\item\Item; @@ -1489,7 +1489,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, */ public function consumeHeldItem() : bool{ $slot = $this->inventory->getItemInHand(); - if($slot instanceof Consumable){ + if($slot instanceof ConsumableItem){ $ev = new PlayerItemConsumeEvent($this, $slot); if($this->hasItemCooldown($slot)){ $ev->setCancelled(); diff --git a/tests/phpstan/configs/check-explicit-mixed-baseline.neon b/tests/phpstan/configs/check-explicit-mixed-baseline.neon index 0bcbced94..2d1b55268 100644 --- a/tests/phpstan/configs/check-explicit-mixed-baseline.neon +++ b/tests/phpstan/configs/check-explicit-mixed-baseline.neon @@ -180,11 +180,6 @@ parameters: count: 1 path: ../../../src/player/Player.php - - - message: "#^Parameter \\#1 \\.\\.\\.\\$slots of method pocketmine\\\\inventory\\\\BaseInventory\\:\\:addItem\\(\\) expects pocketmine\\\\item\\\\Item, mixed given\\.$#" - count: 1 - path: ../../../src/player/Player.php - - message: "#^Parameter \\#1 \\$description of method pocketmine\\\\command\\\\Command\\:\\:setDescription\\(\\) expects string, mixed given\\.$#" count: 1