/** * @param Entity $projectile */ public function setProjectile(Entity $projectile) { if ($projectile !== $this->projectile) { if (count($this->projectile->getViewers()) === 0) { $this->projectile->kill(); $this->projectile->close(); } $this->projectile = $projectile; } }
public function spawnTo(Player $player) { $pk = $this->addEntityDataPacket($player); $pk->type = Egg::NETWORK_ID; $player->dataPacket($pk); parent::spawnTo($player); }
public function spawnTo(Player $player) { $pk = new AddEntityPacket(); $pk->type = Arrow::NETWORK_ID; $pk->eid = $this->getId(); $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->did = 0; //TODO: send motion here $player->dataPacket($pk); $player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ); parent::spawnTo($player); }
public function spawnTo(Player $player) { $pk = new AddEntityPacket(); $pk->type = Arrow::NETWORK_ID; $pk->eid = $this->getId(); $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->metadata = $this->dataProperties; $player->dataPacket($pk); parent::spawnTo($player); }
public function spawnTo(Player $player) { $pk = new AddEntityPacket(); $pk->type = Arrow::NETWORK_ID; $pk->eid = $this->getId(); $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->metadata = $this->dataProperties; $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); parent::spawnTo($player); }
public function spawnTo(Player $player) { $pk = $this->addEntityDataPacket($player); $pk->type = FishingHook::NETWORK_ID; $pk->owner = $this->shootingEntity; $player->dataPacket($pk); parent::spawnTo($player); }
public static function getArrowCollisionBlock(Projectile $p) { if ($p->isCollidedVertically) { $block = $p->getLevel()->getBlock($p->floor()); if ($block->getId() === 0) { $block = $p->getLevel()->getBlock($p->floor()->add(0, 1)); } if ($block->getId() === 0) { $block = $p->getLevel()->getBlock($p->floor()->subtract(1)); } return $block->getId() === 0 ? null : $block; } if ($p->isCollidedHorizontally) { $floor = $p->floor(); $pos = new Vector3($p->x - $floor->x >= 0.5 ? $floor->x + 1 : $floor->x - 1, $floor->y, $p->z - $floor->z >= 0.5 ? $floor->z + 1 : $floor->z - 1); $block = $p->getLevel()->getBlock($pos); return $block->getId() === 0 ? null : $block; } return null; }
public function spawnTo(Player $player) { $this->setDataProperty(self::DATA_NO_AI, self::DATA_TYPE_BYTE, 1); $pk = new AddEntityPacket(); $pk->eid = $this->getId(); $pk->type = FishingHook::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); }
public function spawnTo(Player $player) { if (!$this->owner instanceof Player) { $this->close(); return; } $pk = new AddEntityPacket(); $pk->eid = $this->getId(); $pk->type = FishingHook::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); }
public function onUpdate($currentTick) { if ($this->closed) { return false; } $this->timings->startTiming(); $hasUpdate = parent::onUpdate($currentTick); $bb = new AxisAlignedBB($x = $this->x - 0.5, $y = $this->y, $z = $this->z - 0.5, $x + 1, $y + 1, $z + 1); if ($this->age > 100 || count($this->level->getCollisionBlocks($bb = $this->getBoundingBox())) > 0) { $this->kill(); $this->close(); $hasUpdate = true; } else { $se = $this->shootingEntity; $list = $this->server->getOnlinePlayers(); foreach ($list as $p) { if ($p !== $se && $bb->intersectsWith($p->getBoundingBox())) { $armorTable = [Item::LEATHER_CAP => 1, Item::LEATHER_TUNIC => 3, Item::LEATHER_PANTS => 2, Item::LEATHER_BOOTS => 1, Item::CHAIN_HELMET => 1, Item::CHAIN_CHESTPLATE => 5, Item::CHAIN_LEGGINGS => 4, Item::CHAIN_BOOTS => 1, Item::GOLD_HELMET => 1, Item::GOLD_CHESTPLATE => 5, Item::GOLD_LEGGINGS => 3, Item::GOLD_BOOTS => 1, Item::IRON_HELMET => 2, Item::IRON_CHESTPLATE => 6, Item::IRON_LEGGINGS => 5, Item::IRON_BOOTS => 2, Item::DIAMOND_HELMET => 3, Item::DIAMOND_CHESTPLATE => 8, Item::DIAMOND_LEGGINGS => 6, Item::DIAMOND_BOOTS => 3]; $points = 0; foreach ($p->getInventory()->getArmorContents() as $index => $armor) { if (isset($armorTable[$armor->getID()])) { $points += $armorTable[$armor->getID()]; } } $p->knockBack($se, $finalDamage = 5 - floor(5 * $points * 0.04), sin($yaw = atan2($p->x - $se->x, $p->z - $se->z)), cos($yaw), 0.4); $p->attack($finalDamage); $this->kill(); $this->close(); $hasUpdate = true; break; } } } $this->timings->stopTiming(); return $hasUpdate; }
public function spawnTo(Player $player) { $pk = new AddItemEntityPacket(); $pk->eid = $this->id; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->roll = 0; $pk->item = $this->item; $player->dataPacket($pk); parent::spawnTo($player); }