예제 #1
0
파일: Pet.php 프로젝트: flaxues/BuddyPets
 public function __construct(FullChunk $chunk, CompoundTag $nbt, PetOwner $petOwner)
 {
     // if $petOwner is null pocketmine is probably trying to reload a saved
     // version of this entity which we do not want anymore - as it is not cancellable ( I think ? )
     // just let it create and the update function will despawn the entity immediatley when it finds
     // it to have no targetPlayer
     if (is_null($petOwner)) {
         parent::__construct($chunk, $nbt);
         $this->close();
         return;
     }
     // TODO Catch error
     $this->petOwner = $petOwner;
     $this->petName_unformatted = $petOwner->petProperties->petName;
     $this->ownerName = $this->petOwner->player->getName();
     $this->petName = Main::translateColors("&", "&c[" . $this->ownerName . "] &f" . $this->petName_unformatted);
     $this->petType = $petOwner->petType;
     $location = $this->petOwner->player->getLocation();
     $nbt = new CompoundTag("", [new ListTag("Pos", [new DoubleTag("", $location->x), new DoubleTag("", $location->y), new DoubleTag("", $location->z)]), new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), new ListTag("Rotation", [new FloatTag("", $location->yaw), new FloatTag("", $location->pitch)])]);
     $nbt->CustomName = new StringTag("CustomName", $this->petName);
     $nbt->CustomNameVisible = new ByteTag("CustomNameVisible", 1);
     $chunk = $location->getLevel()->getChunk($location->x >> 4, $location->z >> 4);
     $this->setNameTagVisible(true);
     parent::__construct($chunk, $nbt);
     $this->setNameTagVisible(true);
     $this->dataProperties = array_replace($this->dataProperties, $this->petType->meta);
     $this->spawnToAll();
     return true;
 }
예제 #2
0
 private function criticalError($errmsg)
 {
     $errmsg = Main::translateColors("&", Main::PREFIX . $errmsg);
     $this->plugin->getServer()->getInstance()->getLogger()->critical($errmsg);
     $this->plugin->getServer()->getInstance()->shutdown();
 }