mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +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{
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user