From 11135c2fd8a5af01f2e78e133c647d7a05b7844c Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 Date: Sat, 22 Mar 2025 21:22:08 +0100 Subject: [PATCH] remove dead code --- src/crafting/AnvilCraftResult.php | 4 +--- src/crafting/CraftingManager.php | 1 - src/crafting/MaterialRepairRecipe.php | 11 ++++------- src/item/Armor.php | 5 ----- src/item/ArmorMaterial.php | 15 +-------------- src/item/VanillaArmorMaterials.php | 12 ++++++------ 6 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/crafting/AnvilCraftResult.php b/src/crafting/AnvilCraftResult.php index a9e0e620b..4e81a0bc6 100644 --- a/src/crafting/AnvilCraftResult.php +++ b/src/crafting/AnvilCraftResult.php @@ -28,10 +28,8 @@ use pocketmine\item\Item; /** * This class is here to hold the result of an anvil crafting process. */ -class AnvilCraftResult{ +final class AnvilCraftResult{ /** - * @param int $xpCost - * @param Item $output * @param Item|null $sacrificeResult If the given item is considered as null (count <= 0), the value will be set to null. */ public function __construct( diff --git a/src/crafting/CraftingManager.php b/src/crafting/CraftingManager.php index b8e595886..185630b62 100644 --- a/src/crafting/CraftingManager.php +++ b/src/crafting/CraftingManager.php @@ -34,7 +34,6 @@ use function count; use function implode; use function ksort; use function spl_object_id; -use function var_dump; use const SORT_STRING; class CraftingManager{ diff --git a/src/crafting/MaterialRepairRecipe.php b/src/crafting/MaterialRepairRecipe.php index 72edbe569..35397fca4 100644 --- a/src/crafting/MaterialRepairRecipe.php +++ b/src/crafting/MaterialRepairRecipe.php @@ -25,12 +25,10 @@ namespace pocketmine\crafting; use pocketmine\item\Durable; use pocketmine\item\Item; -use pocketmine\item\Tool; use function ceil; use function floor; use function max; use function min; -use function var_dump; /** * Represent a recipe that repair an item with a material in an anvil. @@ -39,7 +37,8 @@ class MaterialRepairRecipe implements AnvilRecipe{ public function __construct( private RecipeIngredient $input, private RecipeIngredient $material - ){ } + ){ + } public function getInput() : RecipeIngredient{ return $this->input; @@ -55,10 +54,8 @@ class MaterialRepairRecipe implements AnvilRecipe{ if($damage !== 0){ $quarter = min($damage, (int) floor($input->getMaxDurability() / 4)); $numberRepair = min($material->getCount(), (int) ceil($damage / $quarter)); - if($numberRepair > 0){ - // TODO: remove the material - $damage -= $quarter * $numberRepair; - } + $damage -= $quarter * $numberRepair; + return new AnvilCraftResult( $numberRepair, (clone $input)->setDamage(max(0, $damage)), diff --git a/src/item/Armor.php b/src/item/Armor.php index a4dda3689..63a8003ad 100644 --- a/src/item/Armor.php +++ b/src/item/Armor.php @@ -34,7 +34,6 @@ use pocketmine\nbt\tag\IntTag; use pocketmine\player\Player; use pocketmine\utils\Binary; use pocketmine\utils\Utils; -use function in_array; use function mt_rand; class Armor extends Durable{ @@ -173,8 +172,4 @@ class Armor extends Durable{ $tag->setInt(self::TAG_CUSTOM_COLOR, Binary::signInt($this->customColor->toARGB())) : $tag->removeTag(self::TAG_CUSTOM_COLOR); } - - public function isValidRepairMaterial(Item $material) : bool{ - return in_array($material->getTypeId(), $this->armorInfo->getMaterial()->getRepairMaterials(), true); - } } diff --git a/src/item/ArmorMaterial.php b/src/item/ArmorMaterial.php index dc0ddcbb8..d0ea33feb 100644 --- a/src/item/ArmorMaterial.php +++ b/src/item/ArmorMaterial.php @@ -27,13 +27,9 @@ use pocketmine\world\sound\Sound; class ArmorMaterial{ - /** - * @param int[] $repairMaterials - */ public function __construct( private readonly int $enchantability, - private readonly ?Sound $equipSound = null, - private readonly array $repairMaterials = [] + private readonly ?Sound $equipSound = null ){ } @@ -53,13 +49,4 @@ class ArmorMaterial{ public function getEquipSound() : ?Sound{ return $this->equipSound; } - - /** - * Returns the items that can be used to repair the armor - * - * @return int[] - */ - public function getRepairMaterials() : array{ - return $this->repairMaterials; - } } diff --git a/src/item/VanillaArmorMaterials.php b/src/item/VanillaArmorMaterials.php index d803f9f82..818273d20 100644 --- a/src/item/VanillaArmorMaterials.php +++ b/src/item/VanillaArmorMaterials.php @@ -69,12 +69,12 @@ final class VanillaArmorMaterials{ } protected static function setup() : void{ - self::register("leather", new ArmorMaterial(15, new ArmorEquipLeatherSound(), [ItemTypeIds::LEATHER])); + self::register("leather", new ArmorMaterial(15, new ArmorEquipLeatherSound())); self::register("chainmail", new ArmorMaterial(12, new ArmorEquipChainSound())); - self::register("iron", new ArmorMaterial(9, new ArmorEquipIronSound(), [ItemTypeIds::IRON_INGOT])); - self::register("turtle", new ArmorMaterial(9, new ArmorEquipGenericSound(), [ItemTypeIds::SCUTE])); - self::register("gold", new ArmorMaterial(25, new ArmorEquipGoldSound(), [ItemTypeIds::GOLD_INGOT])); - self::register("diamond", new ArmorMaterial(10, new ArmorEquipDiamondSound(), [ItemTypeIds::DIAMOND])); - self::register("netherite", new ArmorMaterial(15, new ArmorEquipNetheriteSound(), [ItemTypeIds::NETHERITE_INGOT])); + self::register("iron", new ArmorMaterial(9, new ArmorEquipIronSound())); + self::register("turtle", new ArmorMaterial(9, new ArmorEquipGenericSound())); + self::register("gold", new ArmorMaterial(25, new ArmorEquipGoldSound())); + self::register("diamond", new ArmorMaterial(10, new ArmorEquipDiamondSound())); + self::register("netherite", new ArmorMaterial(15, new ArmorEquipNetheriteSound())); } }