mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 15:35:31 +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;
|
namespace pocketmine\inventory\transaction\action;
|
||||||
|
|
||||||
use pocketmine\event\player\PlayerDropItemEvent;
|
use pocketmine\event\player\PlayerDropItemEvent;
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\ItemFactory;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,15 +33,12 @@ use pocketmine\Player;
|
|||||||
*/
|
*/
|
||||||
class DropItemAction extends InventoryAction{
|
class DropItemAction extends InventoryAction{
|
||||||
|
|
||||||
/**
|
public function __construct(Item $targetItem){
|
||||||
* Verifies that the source item of a drop-item action must be air. This is not strictly necessary, just a sanity
|
parent::__construct(ItemFactory::get(Item::AIR, 0, 0), $targetItem);
|
||||||
* check.
|
}
|
||||||
*
|
|
||||||
* @param Player $source
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isValid(Player $source) : bool{
|
public function isValid(Player $source) : bool{
|
||||||
return $this->sourceItem->isNull();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPreExecute(Player $source) : bool{
|
public function onPreExecute(Player $source) : bool{
|
||||||
|
@ -170,7 +170,7 @@ class NetworkInventoryAction{
|
|||||||
throw new \UnexpectedValueException("Only expecting drop-item world actions from the client!");
|
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:
|
case self::SOURCE_CREATIVE:
|
||||||
switch($this->inventorySlot){
|
switch($this->inventorySlot){
|
||||||
case self::ACTION_MAGIC_SLOT_CREATIVE_DELETE_ITEM:
|
case self::ACTION_MAGIC_SLOT_CREATIVE_DELETE_ITEM:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user