mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Cleaned up ShapedRecipe handling, ShapedRecipe API changes
use shapes from json instead of just generating maps fix a ton of bugs
This commit is contained in:
@ -68,16 +68,12 @@ class CraftingManager{
|
||||
case 1:
|
||||
// TODO: handle multiple result items
|
||||
$first = $recipe["output"][0];
|
||||
$result = new ShapedRecipe(Item::jsonDeserialize($first), $recipe["height"], $recipe["width"]);
|
||||
|
||||
$shape = array_map(function(string $keys) : array{ return str_split($keys); }, $recipe["shape"]);
|
||||
$ingredients = array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["input"]);
|
||||
foreach($shape as $y => $row){
|
||||
foreach($row as $x => $ingredient){
|
||||
$result->addIngredient($x, $y, $ingredients[$ingredient] ?? Item::get(Item::AIR, 0, 0));
|
||||
}
|
||||
}
|
||||
$this->registerRecipe($result);
|
||||
$this->registerRecipe(new ShapedRecipe(
|
||||
Item::jsonDeserialize($first),
|
||||
$recipe["shape"],
|
||||
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["input"])
|
||||
));
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
|
Reference in New Issue
Block a user