Updated BedrockData submodule, new recipes.json format

This commit is contained in:
Dylan K. Taylor 2020-08-03 19:36:32 +01:00
parent f0a0c9a85f
commit 1f5e0bc96d
2 changed files with 28 additions and 33 deletions

View File

@ -54,39 +54,34 @@ class CraftingManager{
$recipes = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla" . DIRECTORY_SEPARATOR . "recipes.json"), true); $recipes = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla" . DIRECTORY_SEPARATOR . "recipes.json"), true);
$itemDeserializerFunc = \Closure::fromCallable([Item::class, 'jsonDeserialize']); $itemDeserializerFunc = \Closure::fromCallable([Item::class, 'jsonDeserialize']);
foreach($recipes as $recipe){
switch($recipe["type"]){ foreach($recipes["shapeless"] as $recipe){
case "shapeless":
if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics
break; continue;
} }
$this->registerShapelessRecipe(new ShapelessRecipe( $this->registerShapelessRecipe(new ShapelessRecipe(
array_map($itemDeserializerFunc, $recipe["input"]), array_map($itemDeserializerFunc, $recipe["input"]),
array_map($itemDeserializerFunc, $recipe["output"]) array_map($itemDeserializerFunc, $recipe["output"])
)); ));
break; }
case "shaped": foreach($recipes["shaped"] as $recipe){
if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics
break; continue;
} }
$this->registerShapedRecipe(new ShapedRecipe( $this->registerShapedRecipe(new ShapedRecipe(
$recipe["shape"], $recipe["shape"],
array_map($itemDeserializerFunc, $recipe["input"]), array_map($itemDeserializerFunc, $recipe["input"]),
array_map($itemDeserializerFunc, $recipe["output"]) array_map($itemDeserializerFunc, $recipe["output"])
)); ));
break; }
case "smelting": foreach($recipes["smelting"] as $recipe){
if($recipe["block"] !== "furnace"){ //TODO: filter others out for now to avoid breaking economics if($recipe["block"] !== "furnace"){ //TODO: filter others out for now to avoid breaking economics
break; continue;
} }
$this->registerFurnaceRecipe(new FurnaceRecipe( $this->registerFurnaceRecipe(new FurnaceRecipe(
Item::jsonDeserialize($recipe["output"]), Item::jsonDeserialize($recipe["output"]),
Item::jsonDeserialize($recipe["input"])) Item::jsonDeserialize($recipe["input"]))
); );
break;
default:
break;
}
} }
$this->buildCraftingDataCache(); $this->buildCraftingDataCache();

@ -1 +1 @@
Subproject commit 43edcfde6b9611b7c7d643be52332707cc10cd1b Subproject commit 767676e2b97843072220bad719c076b169c28fd3