public function spawnTo(Player $player) { $pk = new AddEntityPacket(); $pk->eid = $this->getId(); $pk->type = Mooshroom::NETWORK_ID; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->speedX = $this->motionX; $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; $player->dataPacket($pk); parent::spawnTo($player); }
/** * @param Position $pos 出生位置坐标(世界) * @param int $maxHealth 最高血量 * @param int $health 血量 * 出生一只牛在某坐标 * * @return Cow */ public function getCow(Position $pos, $maxHealth = 20, $health = 20) { $chunk = $pos->level->getChunk($pos->x >> 4, $pos->z >> 4, false); $nbt = $this->getNBT(); $zo = new Cow($chunk, $nbt); $zo->setPosition($pos); $zo->setMaxHealth($maxHealth); $zo->setHealth($health); return $zo; //$this->getLogger()->info("生成了一只牛"); }