pocketmine\item\Item::setCompoundTag PHP Method

setCompoundTag() public method

public setCompoundTag ( $tags )
    public function setCompoundTag($tags)
    {
        if ($tags instanceof CompoundTag) {
            $this->setNamedTag($tags);
        } else {
            $this->tags = $tags;
            $this->cachedNBT = null;
        }
        return $this;
    }

Usage Example

Example #1
0
 public static function clearCustomColorToArmor(Item $item)
 {
     if (!$item->hasCompoundTag()) {
         return;
     }
     $tag = $item->getNamedTag();
     if (isset($tag->customColor)) {
         unset($tag->customColor);
     }
     $item->setCompoundTag($tag);
     //
 }