[ VanillaItems::DIAMOND_PICKAXE(), VanillaItems::DIAMOND(), null ]; yield "Repair one damage" => [ VanillaItems::DIAMOND_PICKAXE()->setDamage(1), VanillaItems::DIAMOND(), new AnvilCraftResult(1, VanillaItems::DIAMOND_PICKAXE(), null) ]; yield "Repair one damage with more materials than expected" => [ VanillaItems::DIAMOND_PICKAXE()->setDamage(1), VanillaItems::DIAMOND()->setCount(2), new AnvilCraftResult(1, VanillaItems::DIAMOND_PICKAXE(), VanillaItems::DIAMOND()) ]; $diamondPickaxeQuarter = (int) floor(VanillaItems::DIAMOND_PICKAXE()->getMaxDurability() / 4); yield "Repair one quarter" => [ VanillaItems::DIAMOND_PICKAXE()->setDamage($diamondPickaxeQuarter), VanillaItems::DIAMOND()->setCount(1), new AnvilCraftResult(1, VanillaItems::DIAMOND_PICKAXE(), null) ]; yield "Repair one quarter plus 1" => [ VanillaItems::DIAMOND_PICKAXE()->setDamage($diamondPickaxeQuarter + 1), VanillaItems::DIAMOND()->setCount(1), new AnvilCraftResult(1, VanillaItems::DIAMOND_PICKAXE()->setDamage(1), null) ]; yield "Repair more than one quarter" => [ VanillaItems::DIAMOND_PICKAXE()->setDamage($diamondPickaxeQuarter * 2), VanillaItems::DIAMOND()->setCount(2), new AnvilCraftResult(2, VanillaItems::DIAMOND_PICKAXE(), null) ]; yield "Repair more than one quarter with more materials than expected" => [ VanillaItems::DIAMOND_PICKAXE()->setDamage($diamondPickaxeQuarter * 2), VanillaItems::DIAMOND()->setCount(3), new AnvilCraftResult(2, VanillaItems::DIAMOND_PICKAXE(), VanillaItems::DIAMOND()->setCount(1)) ]; } /** * @dataProvider materialRepairRecipe */ public function testMaterialRepairRecipe(Item $base, Item $material, ?AnvilCraftResult $expected) : void{ $recipe = new MaterialRepairRecipe( new ExactRecipeIngredient((clone $base)->setCount(1)), new ExactRecipeIngredient((clone $material)->setCount(1)) ); $result = $recipe->getResultFor($base, $material); if($expected === null){ self::assertNull($result, "Recipe did not match expected result"); return; }else{ self::assertNotNull($result, "Recipe did not match expected result"); } self::assertEquals($expected->getXpCost(), $result->getXpCost(), "XP cost did not match expected result"); self::assertTrue($expected->getOutput()->equalsExact($result->getOutput()), "Recipe output did not match expected result"); $sacrificeResult = $expected->getSacrificeResult(); if($sacrificeResult !== null){ $resultExpected = $result->getSacrificeResult(); self::assertNotNull($resultExpected, "Recipe sacrifice result did not match expected result"); self::assertTrue($sacrificeResult->equalsExact($resultExpected), "Recipe sacrifice result did not match expected result"); }else{ self::assertNull($result->getSacrificeResult(), "Recipe sacrifice result did not match expected result"); } } }