Added CraftingManager::getCraftingRecipeFromIndex()

This commit is contained in:
Dylan K. Taylor 2023-03-19 22:14:23 +00:00
parent 34ced382db
commit 4864444440
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 5 additions and 1 deletions

View File

@ -167,6 +167,10 @@ class CraftingManager{
return $this->craftingRecipeIndex; return $this->craftingRecipeIndex;
} }
public function getCraftingRecipeFromIndex(int $index) : ?CraftingRecipe{
return $this->craftingRecipeIndex[$index] ?? null;
}
public function getFurnaceRecipeManager(FurnaceType $furnaceType) : FurnaceRecipeManager{ public function getFurnaceRecipeManager(FurnaceType $furnaceType) : FurnaceRecipeManager{
return $this->furnaceRecipeManagers[$furnaceType->id()]; return $this->furnaceRecipeManagers[$furnaceType->id()];
} }

View File

@ -173,7 +173,7 @@ final class ItemStackRequestExecutor{
throw new PacketHandlingException("Cannot craft a recipe less than 1 time"); throw new PacketHandlingException("Cannot craft a recipe less than 1 time");
} }
$craftingManager = $this->player->getServer()->getCraftingManager(); $craftingManager = $this->player->getServer()->getCraftingManager();
$recipe = $craftingManager->getCraftingRecipeIndex()[$recipeId] ?? null; $recipe = $craftingManager->getCraftingRecipeFromIndex($recipeId);
if($recipe === null){ if($recipe === null){
throw new PacketHandlingException("Unknown crafting recipe ID $recipeId"); throw new PacketHandlingException("Unknown crafting recipe ID $recipeId");
} }