public function setNamedTag(Compound $tag) { if ($tag->getCount() === 0) { return $this->clearNamedTag(); } $this->cachedNBT = $tag; $this->tags = self::writeCompoundTag($tag); return $this; }
public static function matchTree(Compound $tag1, Compound $tag2) { if ($tag1->getName() !== $tag2->getName() or $tag1->getCount() !== $tag2->getCount()) { return false; } foreach ($tag1 as $k => $v) { if (!$v instanceof Tag) { continue; } if (!isset($tag2->{$k}) or !$tag2->{$k} instanceof $v) { return false; } if ($v instanceof Compound) { if (!self::matchTree($v, $tag2->{$k})) { return false; } } elseif ($v instanceof Enum) { if (!self::matchList($v, $tag2->{$k})) { return false; } } else { if ($v->getValue() !== $tag2->{$k}->getValue()) { return false; } } } return true; }