Merge branch 'master' of github.com:pmmp/PocketMine-MP

This commit is contained in:
Dylan K. Taylor 2021-08-10 19:48:39 +01:00
commit 99e68fb5d3
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -46,7 +46,13 @@ class Bow extends Tool implements Releasable{
public function onReleaseUsing(Player $player) : ItemUseResult{ public function onReleaseUsing(Player $player) : ItemUseResult{
$arrow = VanillaItems::ARROW(); $arrow = VanillaItems::ARROW();
if($player->hasFiniteResources() and !$player->getInventory()->contains($arrow)){ $inventory = match(true){
$player->getOffHandInventory()->contains($arrow) => $player->getOffHandInventory(),
$player->getInventory()->contains($arrow) => $player->getInventory(),
default => null
};
if($player->hasFiniteResources() and $inventory === null){
return ItemUseResult::FAIL(); return ItemUseResult::FAIL();
} }
@ -110,7 +116,7 @@ class Bow extends Tool implements Releasable{
if($player->hasFiniteResources()){ if($player->hasFiniteResources()){
if(!$infinity){ //TODO: tipped arrows are still consumed when Infinity is applied if(!$infinity){ //TODO: tipped arrows are still consumed when Infinity is applied
$player->getInventory()->removeItem($arrow); $inventory?->removeItem($arrow);
} }
$this->applyDamage(1); $this->applyDamage(1);
} }