Closed EpicPinkCreeper closed 6 years ago
Dude want fix here
Change Fireball.php
To this code
<?php
namespace PiggyCustomEnchants\Entities;
use pocketmine\block\Block;
use pocketmine\entity\projectile\Projectile; use pocketmine\event\entity\EntityCombustByEntityEvent; use pocketmine\event\entity\EntityDamageByChildEntityEvent; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\ProjectileHitEvent; use pocketmine\level\MovingObjectPosition; use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\AddEntityPacket; use pocketmine\Player;
/**
@package PiggyCustomEnchants\Entities */ class Fireball extends Projectile { const NETWORK_ID = 94;
/**
@return bool */ public function onUpdate(int $currentTick) : bool { if ($this->closed) { return false; }
$tickDiff = $currentTick - $this->lastUpdate; if ($tickDiff <= 0 and !$this->justCreated) { return true; } $this->lastUpdate = $currentTick;
$hasUpdate = $this->entityBaseTick($tickDiff);
if ($this->isAlive()) {
$movingObjectPosition = null;
if (!$this->isCollided) {
$this->motionY -= $this->gravity;
}
$moveVector = new Vector3($this->x + $this->motionX, $this->y + $this->motionY, $this->z + $this->motionZ);
$list = $this->getLevel()->getCollidingEntities($this->boundingBox->addCoord($this->motionX, $this->motionY, $this->motionZ)->expand(1, 1, 1), $this);
$nearDistance = PHP_INT_MAX;
$nearEntity = null;
foreach ($list as $entity) {
if (/*!$entity->canCollideWith($this) or */
($entity === $this->getOwningEntity() and $this->ticksLived < 5)
) {
continue;
}
$axisalignedbb = $entity->boundingBox->grow(0.3, 0.3, 0.3);
$ob = $axisalignedbb->calculateIntercept($this, $moveVector);
if ($ob === null) {
continue;
}
$distance = $this->distanceSquared($ob->hitVector);
if ($distance < $nearDistance) {
$nearDistance = $distance;
$nearEntity = $entity;
}
}
if ($nearEntity !== null) {
$movingObjectPosition = MovingObjectPosition::fromEntity($nearEntity);
}
if ($movingObjectPosition !== null) {
if ($movingObjectPosition->entityHit !== null) {
$this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
$damage = 5;
if ($this->getOwningEntity() === null) {
$ev = new EntityDamageByEntityEvent($this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
} else {
$ev = new EntityDamageByChildEntityEvent($this->getOwningEntity(), $this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
}
$movingObjectPosition->entityHit->attack($ev);
$this->hadCollision = true;
$ev = new EntityCombustByEntityEvent($this, $movingObjectPosition->entityHit, 5);
$this->server->getPluginManager()->callEvent($ev);
if (!$ev->isCancelled()) {
$movingObjectPosition->entityHit->setOnFire(5);
}
$this->kill();
return true;
}
}
$this->move($this->motionX, $this->motionY, $this->motionZ);
if ($this->isCollided and !$this->hadCollision) {
$this->hadCollision = true;
$this->motionX = 0;
$this->motionY = 0;
$this->motionZ = 0;
$this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
if ($this->onGround) {
if ($this->getLevel()->getBlock($this)->canBeFlowedInto()) {
$this->getLevel()->setBlock($this, Block::get(Block::FIRE));
}
}
$this->kill();
}
if (!$this->onGround or abs($this->motionX) > 0.00001 or abs($this->motionY) > 0.00001 or abs($this->motionZ) > 0.00001) {
$f = sqrt(($this->motionX ** 2) + ($this->motionZ ** 2));
$this->yaw = (atan2($this->motionX, $this->motionZ) * 180 / M_PI);
$this->pitch = (atan2($this->motionY, $f) * 180 / M_PI);
$hasUpdate = true;
}
$this->updateMovement();
}
return $hasUpdate; }
/**
@param Player $player */ public function spawnTo(Player $player) { $pk = new AddEntityPacket(); $pk->type = Fireball::NETWORK_ID; $pk->entityRuntimeId = $this->getId(); $pk->position = $this->asVector3(); $pk->motion = $this->getMotion(); $pk->metadata = $this->dataProperties; $player->dataPacket($pk);
parent::spawnTo($player); }
}
Change PigProjectile.php to this
<?php
namespace PiggyCustomEnchants\Entities;
use pocketmine\entity\Entity; use pocketmine\entity\projectile\Projectile; use pocketmine\item\Item; use pocketmine\level\Level; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\AddEntityPacket; use pocketmine\Player;
/**
@package PiggyCustomEnchants\Entities */ class PigProjectile extends Projectile { private $porklevel = 1;
public $width = 0.5; public $height = 0.5; protected $gravity = 0.05; protected $drag = 0.01; protected $damage = 1.5; private $zombie = false;
const NETWORK_ID = 12;
/**
@param int $porklevel */ public function construct(Level $level, CompoundTag $nbt, Entity $shootingEntity = null, $porklevel = 1) { parent::construct($level, $nbt, $shootingEntity); if ($porklevel < 1) { $porklevel = 1; } if ($porklevel > 6) { $porklevel = 6; } switch ($porklevel) { case 1: $this->damage = 1.5; break; case 2: $this->damage = 2; break; case 3: $this->damage = 3; break; case 4: //Secret $this->damage = 3; $this->setNameTag("Dinnerbone"); break; case 5: //Secret $this->damage = 5; $this->zombie = true; break; case 6: //Secret $this->damage = 5;
$this->setNameTag("Dinnerbone");
$this->zombie = true;
break;
} $this->porklevel = $porklevel; }
/**
/**
@param Player $player */ public function spawnTo(Player $player) { $pk = new AddEntityPacket(); if ($this->zombie) { $pk->type = 36; } else { $pk->type = PigProjectile::NETWORK_ID; } $pk->entityRuntimeId = $this->getId(); $pk->position = $this->asVector3(); $pk->motion = $this->getMotion(); $pk->metadata = $this->dataProperties; $player->dataPacket($pk);
parent::spawnTo($player); }
/**
Please make sure your issue complies with these guidelines:
General
It crashed the server when I started it with the new pocketmine phar.
Version of PiggyCustomEnchants:
v1.0.2-1
Data Provider:
Steps to Reproduce the Issue
Extra Information