Merge branch 'master' into api3/network

This commit is contained in:
Dylan K. Taylor
2017-03-08 20:35:41 +00:00
12 changed files with 197 additions and 38 deletions

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: