Hello all. I'm working on Wolves in PureEntitiesX and keep running into issues when setting collar colors. Everything looks correct when the interaction happens, but when you log out and back in the wolf is shaded the color of the collar. PHP: public function setCollarColor($collarColor) { if ($this->isTamed()) { $this->collarColor = $collarColor; // ID may be the reason for collar color bug. $this->setDataProperty(self::DATA_COLOUR, self::DATA_TYPE_BYTE, $collarColor); // collar color RED (because it's tamed!) } } Code can be found here: https://github.com/RevivalPMMP/Pure.../pureentities/entity/monster/walking/Wolf.php
Save the colour code in the form of ByteTag in the entity's NBT. Set the colour during Entity::initEntity() from the entity's NBT.
Thanks for the info Muqsit. I read through the NBT thread started by Thunder33345. https://forums.pmmp.io/threads/how-do-you-properly-set-nbt.1182/ I'm not sure about how to apply the info you've given me. Here are the relevant sections of code: PHP: public function initEntity() { parent::initEntity(); $this->fireProof = false; $this->setDamage([0, 3, 4, 6]); $this->breedableClass = new BreedingComponent($this); $this->loadFromNBT(); $this->setAngry($this->isAngry() ? $this->angryValue : 0, true); $this->setSitting($this->isSitting()); $this->setTamed($this->isTamed()); if ($this->isTamed()) { $this->mapOwner(); if ($this->owner === null) { PureEntities::logOutput("Wolf($this): is tamed but player not online. Cannot set tamed owner. Will be set when player logs in ..", PureEntities::NORM); } } $this->setCollarColor($this->getCollarColor()); $this->breedableClass->init(); $this->teleportDistance = PluginConfiguration::getInstance()->getTamedTeleportBlocks(); $this->followDistance = PluginConfiguration::getInstance()->getTamedPlayerMaxDistance(); } PHP: public function loadFromNBT() { if (PluginConfiguration::getInstance()->getEnableNBT()) { if (isset($this->namedtag->Angry)) { $this->angryValue = (int)$this->namedtag[self::NBT_KEY_ANGRY]; } if (isset($this->namedtag->CollarColor)) { $this->collarColor = $this->namedtag[self::NBT_KEY_COLLAR_COLOR]; } if (isset($this->namedtag->Sitting)) { $this->sitting = $this->namedtag[self::NBT_KEY_SITTING] === 1; } if (isset($this->namedtag->OwnerName)) { $this->ownerName = $this->namedtag[self::NBT_SERVER_KEY_OWNER_NAME]; $this->tamed = true; } if ($this->ownerName !== null) { foreach ($this->getLevel()->getPlayers() as $levelPlayer) { if (strcasecmp($levelPlayer->getName(), $this->namedtag->OwnerName) == 0) { $this->owner = $levelPlayer; break; } } } } $this->breedableClass->saveNBT(); } PHP: public function saveNBT() { if (PluginConfiguration::getInstance()->getEnableNBT()) { parent::saveNBT(); $this->namedtag->Angry = new IntTag(self::NBT_KEY_ANGRY, $this->angryValue); $this->namedtag->CollarColor = new ByteTag(self::NBT_KEY_COLLAR_COLOR, $this->collarColor); // set collar color $this->namedtag->Sitting = new IntTag(self::NBT_KEY_SITTING, $this->sitting ? 1 : 0); if ($this->getOwnerName() !== null) { $this->namedtag->OwnerName = new StringTag(self::NBT_SERVER_KEY_OWNER_NAME, $this->getOwnerName()); // only for our own (server side) } if ($this->owner !== null) { $this->namedtag->OwnerUUID = new StringTag(self::NBT_KEY_OWNER_UUID, $this->owner->getUniqueId()->toString()); // set owner UUID } } $this->breedableClass->saveNBT(); } This is what I currently have with the addition of the code provided in the first post. Should I be doing something different?