120        [$windowId, $slotId] = 
ItemStackContainerIdTranslator::translate($info->getContainerName()->getContainerId(), $this->inventoryManager->getCurrentWindowId(), $info->getSlotId());
 
  121        $windowAndSlot = $this->inventoryManager->locateWindowAndSlot($windowId, $slotId);
 
  122        if($windowAndSlot === 
null){
 
  123            throw new ItemStackRequestProcessException(
"No open inventory matches container UI ID: " . $info->getContainerName()->getContainerId() . 
", slot ID: " . $info->getSlotId());
 
  125        [$inventory, $slot] = $windowAndSlot;
 
  127            throw new ItemStackRequestProcessException(
"No such inventory slot :" . $this->prettyInventoryAndSlot($inventory, $slot));
 
  130        if($info->getStackId() !== $this->request->getRequestId()){ 
 
  131            $this->matchItemStack($inventory, $slot, $info->getStackId());
 
  134        return [$this->builder->getInventory($inventory), $slot];
 
 
  153            return $this->takeCreatedItem($count);
 
  155        $this->requestSlotInfos[] = $slotInfo;
 
  156        [$inventory, $slot] = $this->getBuilderInventoryAndSlot($slotInfo);
 
  162        $existingItem = $inventory->
getItem($slot);
 
  163        if($existingItem->getCount() < $count){
 
  164            throw new ItemStackRequestProcessException($this->prettyInventoryAndSlot($inventory, $slot) . 
": Cannot take $count items from a stack of " . $existingItem->getCount());
 
  167        $removed = $existingItem->pop($count);
 
  168        $inventory->
setItem($slot, $existingItem);
 
 
  207        if($item !== null && $item->isNull()){
 
  210        if($this->nextCreatedItem !== 
null){
 
  213            if($this->createdItemFromCreativeInventory && $this->createdItemsTakenCount > 0){
 
  214                $this->nextCreatedItem->setCount($this->createdItemsTakenCount);
 
  216            }elseif($this->createdItemsTakenCount < $this->nextCreatedItem->getCount()){
 
  217                throw new ItemStackRequestProcessException(
"Not all of the previous created item was taken");
 
  220        $this->nextCreatedItem = $item;
 
  221        $this->createdItemFromCreativeInventory = $creative;
 
  222        $this->createdItemsTakenCount = 0;
 
 
  229        if($this->specialTransaction !== null){
 
  232        if($repetitions < 1){
 
  235        if($repetitions > 256){
 
  239            throw new ItemStackRequestProcessException(
"Cannot craft a recipe more than 256 times");
 
  241        $craftingManager = $this->player->getServer()->getCraftingManager();
 
  242        $recipeIndex = $recipeId - CraftingDataCache::RECIPE_ID_OFFSET;
 
  243        $recipe = $craftingManager->getCraftingRecipeFromIndex($recipeIndex);
 
  244        if($recipe === 
null){
 
  245            throw new ItemStackRequestProcessException(
"No such crafting recipe index: $recipeIndex");
 
  248        $this->specialTransaction = 
new CraftingTransaction($this->player, $craftingManager, [], $recipe, $repetitions);
 
  254        $craftingResults = $recipe->getResultsFor($this->player->getCraftingGrid());
 
  255        foreach($craftingResults as $k => $craftingResult){
 
  256            $craftingResult->setCount($craftingResult->getCount() * $repetitions);
 
  257            $this->craftingResults[$k] = $craftingResult;
 
  259        if(count($this->craftingResults) === 1){
 
  261            $this->setNextCreatedItem($this->craftingResults[array_key_first($this->craftingResults)]);
 
 
  315            $this->transferItems($action->getSource(), $action->getDestination(), $action->getCount());
 
  317            $this->requestSlotInfos[] = $action->getSlot1();
 
  318            $this->requestSlotInfos[] = $action->getSlot2();
 
  320            [$inventory1, $slot1] = $this->getBuilderInventoryAndSlot($action->getSlot1());
 
  321            [$inventory2, $slot2] = $this->getBuilderInventoryAndSlot($action->getSlot2());
 
  323            $item1 = $inventory1->getItem($slot1);
 
  324            $item2 = $inventory2->getItem($slot2);
 
  325            $inventory1->setItem($slot1, $item2);
 
  326            $inventory2->setItem($slot2, $item1);
 
  327        }elseif($action instanceof DropStackRequestAction){
 
  329            $dropped = $this->removeItemFromSlot($action->getSource(), $action->getCount());
 
  330            $this->builder->addAction(
new DropItemAction($dropped));
 
  332        }elseif($action instanceof DestroyStackRequestAction){
 
  333            $destroyed = $this->removeItemFromSlot($action->getSource(), $action->getCount());
 
  334            $this->builder->addAction(
new DestroyItemAction($destroyed));
 
  336        }elseif($action instanceof CreativeCreateStackRequestAction){
 
  337            $item = $this->player->getCreativeInventory()->getItem($action->getCreativeItemId());
 
  339                throw new ItemStackRequestProcessException(
"No such creative item index: " . $action->getCreativeItemId());
 
  342            $this->setNextCreatedItem($item, 
true);
 
  343        }elseif($action instanceof CraftRecipeStackRequestAction){
 
  344            $window = $this->player->getCurrentWindow();
 
  345            if($window instanceof EnchantInventory){
 
  346                $optionId = $this->inventoryManager->getEnchantingTableOptionIndex($action->getRecipeId());
 
  347                if($optionId !== 
null && ($option = $window->getOption($optionId)) !== 
null){
 
  348                    $this->specialTransaction = 
new EnchantingTransaction($this->player, $option, $optionId + 1);
 
  349                    $this->setNextCreatedItem($window->getOutput($optionId));
 
  352                $this->beginCrafting($action->getRecipeId(), $action->getRepetitions());
 
  354        }elseif($action instanceof CraftRecipeAutoStackRequestAction){
 
  355            $this->beginCrafting($action->getRecipeId(), $action->getRepetitions());
 
  356        }elseif($action instanceof CraftingConsumeInputStackRequestAction){
 
  357            $this->assertDoingCrafting();
 
  358            $this->removeItemFromSlot($action->getSource(), $action->getCount()); 
 
  360        }elseif($action instanceof CraftingCreateSpecificResultStackRequestAction){
 
  361            $this->assertDoingCrafting();
 
  363            $nextResultItem = $this->craftingResults[$action->getResultIndex()] ?? 
null;
 
  364            if($nextResultItem === 
null){
 
  365                throw new ItemStackRequestProcessException(
"No such crafting result index: " . $action->getResultIndex());
 
  367            $this->setNextCreatedItem($nextResultItem);
 
  368        }elseif($action instanceof DeprecatedCraftingResultsStackRequestAction){
 
  370        }elseif($action instanceof MineBlockStackRequestAction){
 
  371            $slot = $action->getHotbarSlot();
 
  372            $this->requestSlotInfos[] = 
new ItemStackRequestSlotInfo(
new FullContainerName(ContainerUIIds::HOTBAR), $slot, $action->getStackId());
 
  373            $inventory = $this->player->getInventory();
 
  375            $predictedDamage = $action->getPredictedDurability();
 
  376            if($usedItem instanceof Durable && $predictedDamage >= 0 && $predictedDamage <= $usedItem->getMaxDurability()){
 
  377                $usedItem->setDamage($predictedDamage);
 
  378                $this->inventoryManager->addPredictedSlotChange($inventory, $slot, $usedItem);
 
  381            throw new ItemStackRequestProcessException(
"Unhandled item stack request action");