Split CreativeInventoryAction into two new action types

This commit is contained in:
Dylan K. Taylor
2019-06-15 14:40:15 +01:00
parent 4bbf1d56dc
commit a94541c531
4 changed files with 99 additions and 82 deletions

View File

@ -23,7 +23,8 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types;
use pocketmine\inventory\transaction\action\CreativeInventoryAction;
use pocketmine\inventory\transaction\action\CreateItemAction;
use pocketmine\inventory\transaction\action\DestroyItemAction;
use pocketmine\inventory\transaction\action\DropItemAction;
use pocketmine\inventory\transaction\action\InventoryAction;
use pocketmine\inventory\transaction\action\SlotChangeAction;
@ -183,17 +184,13 @@ class NetworkInventoryAction{
case self::SOURCE_CREATIVE:
switch($this->inventorySlot){
case self::ACTION_MAGIC_SLOT_CREATIVE_DELETE_ITEM:
$type = CreativeInventoryAction::TYPE_DELETE_ITEM;
break;
return new DestroyItemAction($this->newItem);
case self::ACTION_MAGIC_SLOT_CREATIVE_CREATE_ITEM:
$type = CreativeInventoryAction::TYPE_CREATE_ITEM;
break;
return new CreateItemAction($this->oldItem);
default:
throw new \UnexpectedValueException("Unexpected creative action type $this->inventorySlot");
}
return new CreativeInventoryAction($this->oldItem, $this->newItem, $type);
case self::SOURCE_CRAFTING_GRID:
case self::SOURCE_TODO:
//These types need special handling.