Hey there, I would like to remove an NBT tag from an item. PHP: //Item $item$tag = new CompoundTag("", []);$tag->ench = new ListTag('ench', []);$item->setNamedTag($tag); That was my code to make an item *shine* without enchants. Now how do I remove the tag "ench" from $item? I have tried... PHP: unset($item->getNamedTag()->ench);Player::getInventory()->setItemInHand($item);//unset because you can check if item had the ench tag with isset($item->getNamedTag()->ench); :3
Bite item to remove and re-add. PHP: Player::getInventory()->removeItem($item1);Player::getInventory()->addItem($slot, $item2);
Just set the items named tag to an empty compound tag or call Item::clearNamedTag(). PHP: $item->clearNamedTag();// or$item->setNamedTag(new CompoundTag("", []));
Thanks a lot. I was actually right, but thank you for that. I was about to search for clearing the nbts. Actually unset() does work. I just forgot to setNamedTag() again. For the future visitors.. PHP: $nbt = $item->getNamedTag();unset($nbt->ench);$item->setNamedTag($nbt);