Fixed missing Cake recipe

TODO: add support for multiple crafting recipe result items
This commit is contained in:
Dylan K. Taylor 2017-03-04 15:03:53 +00:00
parent 15f098074a
commit 663cb514e2

View File

@ -54,30 +54,26 @@ class CraftingManager{
switch($recipe["type"]){ switch($recipe["type"]){
case 0: case 0:
// TODO: handle multiple result items // TODO: handle multiple result items
if(count($recipe["output"]) === 1){ $first = $recipe["output"][0];
$first = $recipe["output"][0]; $result = new ShapelessRecipe(Item::get($first["id"], $first["damage"], $first["count"], $first["nbt"]));
$result = new ShapelessRecipe(Item::get($first["id"], $first["damage"], $first["count"], $first["nbt"]));
foreach($recipe["input"] as $ingredient){ foreach($recipe["input"] as $ingredient){
$result->addIngredient(Item::get($ingredient["id"], $ingredient["damage"], $ingredient["count"], $first["nbt"])); $result->addIngredient(Item::get($ingredient["id"], $ingredient["damage"], $ingredient["count"], $first["nbt"]));
}
$this->registerRecipe($result);
} }
$this->registerRecipe($result);
break; break;
case 1: case 1:
// TODO: handle multiple result items // TODO: handle multiple result items
if(count($recipe["output"]) === 1){ $first = $recipe["output"][0];
$first = $recipe["output"][0]; $result = new ShapedRecipe(Item::get($first["id"], $first["damage"], $first["count"], $first["nbt"]), $recipe["height"], $recipe["width"]);
$result = new ShapedRecipe(Item::get($first["id"], $first["damage"], $first["count"], $first["nbt"]), $recipe["height"], $recipe["width"]);
$shape = array_chunk($recipe["input"], $recipe["width"]); $shape = array_chunk($recipe["input"], $recipe["width"]);
foreach($shape as $y => $row){ foreach($shape as $y => $row){
foreach($row as $x => $ingredient){ foreach($row as $x => $ingredient){
$result->addIngredient($x, $y, Item::get($ingredient["id"], ($ingredient["damage"] < 0 ? -1 : $ingredient["damage"]), $ingredient["count"], $ingredient["nbt"])); $result->addIngredient($x, $y, Item::get($ingredient["id"], ($ingredient["damage"] < 0 ? -1 : $ingredient["damage"]), $ingredient["count"], $ingredient["nbt"]));
}
} }
$this->registerRecipe($result);
} }
$this->registerRecipe($result);
break; break;
case 2: case 2:
case 3: case 3: