22 public const RESULT_OK = 0;
23 public const RESULT_ERROR = 1;
32 private int $requestId,
33 private array $containerInfos = []
35 if($this->result !== self::RESULT_OK && count($this->containerInfos) !== 0){
36 throw new \InvalidArgumentException(
"Container infos must be empty if rejecting the request");
40 public function getResult() : int{ return $this->result; }
42 public function getRequestId() : int{ return $this->requestId; }
48 $result = $in->getByte();
49 $requestId = $in->readItemStackRequestId();
51 if($result === self::RESULT_OK){
53 $containerInfos[] = ItemStackResponseContainerInfo::read($in);
56 return new self($result, $requestId, $containerInfos);
60 $out->putByte($this->result);
61 $out->writeItemStackRequestId($this->requestId);
62 if($this->result === self::RESULT_OK){
64 foreach($this->containerInfos as $containerInfo){
65 $containerInfo->write($out);