Picked up items can now be added to offhand slots. (#4360)

This commit is contained in:
Rush2929
2021-08-23 04:36:12 +09:00
committed by GitHub
parent cd9af7f9f6
commit 1ce9474fce
2 changed files with 10 additions and 8 deletions

View File

@ -174,10 +174,11 @@ class Arrow extends Projectile{
}
$item = VanillaItems::ARROW();
$playerInventory = $player->getInventory();
if(!$playerInventory->canAddItem($item)){
$playerInventory = null;
}
$playerInventory = match(true){
$player->getOffHandInventory()->getItem(0)->canStackWith($item) => $player->getOffHandInventory(),
$player->getInventory()->canAddItem($item) => $player->getInventory(),
default => null
};
$ev = new EntityItemPickupEvent($player, $this, $item, $playerInventory);
if($player->hasFiniteResources() and $playerInventory === null){