mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
DropItemAction: don't require a source item in constructor
This commit is contained in:
parent
ec332e3e60
commit
f41a731493
@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\inventory\transaction\action;
|
||||
|
||||
use pocketmine\event\player\PlayerDropItemEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\Player;
|
||||
|
||||
/**
|
||||
@ -31,15 +33,12 @@ use pocketmine\Player;
|
||||
*/
|
||||
class DropItemAction extends InventoryAction{
|
||||
|
||||
/**
|
||||
* Verifies that the source item of a drop-item action must be air. This is not strictly necessary, just a sanity
|
||||
* check.
|
||||
*
|
||||
* @param Player $source
|
||||
* @return bool
|
||||
*/
|
||||
public function __construct(Item $targetItem){
|
||||
parent::__construct(ItemFactory::get(Item::AIR, 0, 0), $targetItem);
|
||||
}
|
||||
|
||||
public function isValid(Player $source) : bool{
|
||||
return $this->sourceItem->isNull();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onPreExecute(Player $source) : bool{
|
||||
|
@ -170,7 +170,7 @@ class NetworkInventoryAction{
|
||||
throw new \UnexpectedValueException("Only expecting drop-item world actions from the client!");
|
||||
}
|
||||
|
||||
return new DropItemAction($this->oldItem, $this->newItem);
|
||||
return new DropItemAction($this->newItem);
|
||||
case self::SOURCE_CREATIVE:
|
||||
switch($this->inventorySlot){
|
||||
case self::ACTION_MAGIC_SLOT_CREATIVE_DELETE_ITEM:
|
||||
|
Loading…
x
Reference in New Issue
Block a user