Assemble 1.21.0

This commit is contained in:
Dylan K. Taylor
2024-06-13 18:41:41 +01:00
parent 08c6e63aac
commit f121654452
21 changed files with 251 additions and 160 deletions

View File

@ -195,7 +195,7 @@ class ParserPacketHandler extends PacketHandler{
* @return mixed[]
*/
private static function objectToOrderedArray(object $object) : array{
$result = (array) $object;
$result = (array) ($object instanceof \JsonSerializable ? $object->jsonSerialize() : $object);
ksort($result, SORT_STRING);
foreach($result as $property => $value){
@ -335,21 +335,25 @@ class ParserPacketHandler extends PacketHandler{
}
}
}
$unlockingIngredients = $entry->getUnlockingRequirement()->getUnlockingIngredients();
return new ShapedRecipeData(
array_map(fn(array $array) => implode('', $array), $shape),
$outputsByKey,
array_map(fn(ItemStack $output) => $this->itemStackToJson($output), $entry->getOutput()),
$entry->getBlockName(),
$entry->getPriority()
$entry->getPriority(),
$unlockingIngredients !== null ? array_map(fn(RecipeIngredient $input) => $this->recipeIngredientToJson($input), $unlockingIngredients) : []
);
}
private function shapelessRecipeToJson(ShapelessRecipe $recipe) : ShapelessRecipeData{
$unlockingIngredients = $recipe->getUnlockingRequirement()->getUnlockingIngredients();
return new ShapelessRecipeData(
array_map(fn(RecipeIngredient $input) => $this->recipeIngredientToJson($input), $recipe->getInputs()),
array_map(fn(ItemStack $output) => $this->itemStackToJson($output), $recipe->getOutputs()),
$recipe->getBlockName(),
$recipe->getPriority()
$recipe->getPriority(),
$unlockingIngredients !== null ? array_map(fn(RecipeIngredient $input) => $this->recipeIngredientToJson($input), $unlockingIngredients) : []
);
}