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"]){
case 0:
// TODO: handle multiple result items
if(count($recipe["output"]) === 1){
$first = $recipe["output"][0];
$result = new ShapelessRecipe(Item::get($first["id"], $first["damage"], $first["count"], $first["nbt"]));
$first = $recipe["output"][0];
$result = new ShapelessRecipe(Item::get($first["id"], $first["damage"], $first["count"], $first["nbt"]));
foreach($recipe["input"] as $ingredient){
$result->addIngredient(Item::get($ingredient["id"], $ingredient["damage"], $ingredient["count"], $first["nbt"]));
}
$this->registerRecipe($result);
foreach($recipe["input"] as $ingredient){
$result->addIngredient(Item::get($ingredient["id"], $ingredient["damage"], $ingredient["count"], $first["nbt"]));
}
$this->registerRecipe($result);
break;
case 1:
// TODO: handle multiple result items
if(count($recipe["output"]) === 1){
$first = $recipe["output"][0];
$result = new ShapedRecipe(Item::get($first["id"], $first["damage"], $first["count"], $first["nbt"]), $recipe["height"], $recipe["width"]);
$first = $recipe["output"][0];
$result = new ShapedRecipe(Item::get($first["id"], $first["damage"], $first["count"], $first["nbt"]), $recipe["height"], $recipe["width"]);
$shape = array_chunk($recipe["input"], $recipe["width"]);
foreach($shape as $y => $row){
foreach($row as $x => $ingredient){
$result->addIngredient($x, $y, Item::get($ingredient["id"], ($ingredient["damage"] < 0 ? -1 : $ingredient["damage"]), $ingredient["count"], $ingredient["nbt"]));
}
$shape = array_chunk($recipe["input"], $recipe["width"]);
foreach($shape as $y => $row){
foreach($row as $x => $ingredient){
$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;
case 2:
case 3: