43 private array $changedSlots = [];
45 public function __construct(
46 private int $requestId,
50 public function addSlot(
int $containerInterfaceId,
int $slotId) :
void{
51 $this->changedSlots[$containerInterfaceId][$slotId] = $slotId;
57 private function locateWindowAndSlot(
int $containerInterfaceId,
int $slotId) : ?array{
59 return $this->inventoryManager->locateWindowAndSlot($windowId, $slotId);
63 $responseInfosByContainer = [];
64 foreach($this->changedSlots as $containerInterfaceId => $slotIds){
65 if($containerInterfaceId === ContainerUIIds::CREATED_OUTPUT){
68 foreach($slotIds as $slotId){
69 $windowAndSlot = $this->locateWindowAndSlot($containerInterfaceId, $slotId);
70 if($windowAndSlot ===
null){
74 [$window, $slot] = $windowAndSlot;
76 $itemStackInfo = $this->inventoryManager->getItemStackInfo($window, $slot);
77 if($itemStackInfo ===
null){
80 $item = $window->getInventory()->getItem($slot);
86 $itemStackInfo->getStackId(),
87 $item->getCustomName(),
88 $item->getCustomName(),
89 $item instanceof
Durable ? $item->getDamage() : 0,
94 $responseContainerInfos = [];
95 foreach($responseInfosByContainer as $containerInterfaceId => $responseInfos){
99 return new ItemStackResponse(ItemStackResponse::RESULT_OK, $this->requestId, $responseContainerInfos);