$sword = Item::get(Item::IRON_SWORD); if ($sword->getDamage() > 0) { echo "This sword has taken some damage."; }
$tool = Item::get(Item::DIAMOND_PICKAXE); $damagePercent = ($tool->getDamage() / $tool->getMaxDurability()) * 100; echo "This tool has taken " . $damagePercent . "% damage.";Package Library: The Item class is part of the PHP PocketMine library, which can be found at https://github.com/pmmp/PocketMine-MP.