public function onRename(Player $player, Item $resultItem) : bool
{
if (!$resultItem->deepEquals($this->getItem(self::TARGET), true, false, true)) {
//Item does not match target item. Everything must match except the tags.
return false;
}
if ($player->getXpLevel() < $resultItem->getRepairCost()) {
//Not enough exp
return false;
}
$player->takeXpLevel($resultItem->getRepairCost());
$this->clearAll();
if (!$player->getServer()->allowInventoryCheats and !$player->isCreative()) {
if (!$player->getFloatingInventory()->canAddItem($resultItem)) {
return false;
}
$player->getFloatingInventory()->addItem($resultItem);
}
return true;
}