Fixed request rejecting

This commit is contained in:
Dylan K. Taylor
2023-03-20 01:35:03 +00:00
parent eece6c4433
commit 4e55433ed8
5 changed files with 17 additions and 14 deletions

View File

@@ -541,7 +541,10 @@ class InGamePacketHandler extends PacketHandler{
$this->session->getLogger()->debug(implode("\n", Utils::printableExceptionInfo($e)));
}
return $executor->buildItemStackResponse($result);
if(!$result){
return new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $request->getRequestId());
}
return $executor->buildItemStackResponse();
}
public function handleItemStackRequest(ItemStackRequestPacket $packet) : bool{

View File

@@ -349,12 +349,12 @@ final class ItemStackRequestExecutor{
return $transaction;
}
public function buildItemStackResponse(bool $success) : ItemStackResponse{
public function buildItemStackResponse() : ItemStackResponse{
$builder = new ItemStackResponseBuilder($this->request->getRequestId(), $this->inventoryManager);
foreach($this->requestSlotInfos as $requestInfo){
$builder->addSlot($requestInfo->getContainerId(), $requestInfo->getSlotId());
}
return $builder->build($success);
return $builder->build();
}
}

View File

@@ -65,7 +65,7 @@ final class ItemStackResponseBuilder{
return [$inventory, $slot];
}
public function build(bool $success) : ItemStackResponse{
public function build() : ItemStackResponse{
$responseInfosByContainer = [];
foreach($this->changedSlots as $containerInterfaceId => $slotIds){
if($containerInterfaceId === ContainerUIIds::CREATED_OUTPUT){
@@ -107,6 +107,6 @@ final class ItemStackResponseBuilder{
$responseContainerInfos[] = new ItemStackResponseContainerInfo($containerInterfaceId, $responseInfos);
}
return new ItemStackResponse($success ? ItemStackResponse::RESULT_OK : ItemStackResponse::RESULT_ERROR, $this->requestId, $responseContainerInfos);
return new ItemStackResponse(ItemStackResponse::RESULT_OK, $this->requestId, $responseContainerInfos);
}
}