mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Bows can now use offhand arrows (#4356)
This commit is contained in:
parent
2cdd6e634f
commit
cf77b33c3b
@ -46,7 +46,13 @@ class Bow extends Tool implements Releasable{
|
||||
|
||||
public function onReleaseUsing(Player $player) : ItemUseResult{
|
||||
$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();
|
||||
}
|
||||
|
||||
@ -110,7 +116,7 @@ class Bow extends Tool implements Releasable{
|
||||
|
||||
if($player->hasFiniteResources()){
|
||||
if(!$infinity){ //TODO: tipped arrows are still consumed when Infinity is applied
|
||||
$player->getInventory()->removeItem($arrow);
|
||||
$inventory?->removeItem($arrow);
|
||||
}
|
||||
$this->applyDamage(1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user