Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace twilight\duels\entities;
- use pocketmine\entity\Effect;
- use pocketmine\entity\EffectInstance;
- use pocketmine\entity\Human;
- use pocketmine\level\particle\GenericParticle;
- use pocketmine\level\particle\Particle;
- use pocketmine\level\Position;
- use pocketmine\math\Vector3;
- use twilight\duels\Loader;
- use twilight\utilities\ParticleIds;
- use twilight\utilities\SoundIds;
- /**
- * Class HealBall
- * @package twilight\duels\entities
- */
- class HealBall extends Human
- {
- public $age = 0;
- public $heal = 0;
- public $time = 0;
- public function onUpdate(int $currentTick): bool
- {
- ++$this->age;
- ++$this->heal;
- $this->yaw += 15;
- $this->setPosition(new Position($this->x, $this->namedtag->getInt('yy'), $this->z, $this->level));
- $this->getLevel()->addParticle(new DropperParticle($this->asVector3()->add(mt_rand(1, 10) / 10, mt_rand(1, 10) / 10, - mt_rand(1, 10) / 10), 124, 252, 0));
- $this->getLevel()->addParticle(new DropperParticle($this->asVector3()->add(- mt_rand(1, 10) / 10, mt_rand(1, 10) / 10, mt_rand(1, 10) / 10), 127, 255, 0));
- if ($this->heal == 40) {
- $this->heal = 0;
- foreach ($this->getLevel()->getPlayers() as $player) {
- if ($player->getLowerCaseName() == Loader::getInstance()->getServer()->getPlayerExact($this->namedtag->getString('owner'))->getLowerCaseName()) {
- if ($player->getX() > ($this->x - 3) && $player->getX() < ($this->x + 3) && $player->getY() > ($this->y - 3) && $player->getY() < ($this->y + 3) && $player->getZ() > ($this->z - 3) && $player->getZ() < ($this->z + 3)) {
- $player->addEffect(new EffectInstance(Effect::getEffect(Effect::REGENERATION), 40, 1, false));
- }
- }
- }
- }
- if ($this->age >= 180) {
- ++$this->time;
- if (1 - (($this->time * 100 / (1 * 20)) / 100) > 0) {
- $this->setScale(1 - (($this->time * 100 / (1 * 20)) / 100));
- }
- }
- if ($this->age == 200) {
- $this->flagForDespawn();
- addParticle(ParticleIds::MOB_BLOCK_SPAWN, $this->asPosition(), $this->getLevel()->getPlayers());
- playSound(SoundIds::RANDOM_TOAST, $this->asVector3(), $this->getLevel()->getPlayers());
- }
- return parent::onUpdate($currentTick);
- }
- }
- class DropperParticle extends GenericParticle
- {
- public function __construct(Vector3 $pos, int $r, int $g, int $b, int $a = 255)
- {
- parent::__construct($pos, Particle::TYPE_MOB_SPELL_INSTANTANEOUS, (($a & 0xff) << 24) | (($r & 0xff) << 16) | (($g & 0xff) << 8) | ($b & 0xff));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement