DaPigGuy / PiggyCustomEnchants

An open source custom enchantment plugin for PocketMine-MP
https://piggydocs.aericio.net/PiggyCustomEnchants.html
Apache License 2.0
103 stars 118 forks source link

Server crash with the newest pocketmine phar - dump says it is from this #53

Closed EpicPinkCreeper closed 6 years ago

EpicPinkCreeper commented 6 years ago

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

  1. start the server using the newest pocketmine phar

Extra Information

Idk where to put the dump info so I guess I will put it here:

PocketMine-MP Crash Dump Sun Oct 22 15:46:34 CDT 2017

Error: Class 'pocketmine\entity\Projectile' not found
File: PiggyCustomEnchants_dev-80.phar/src/PiggyCustomEnchants/Entities/Fireball
Line: 23
Type: E_ERROR

THIS CRASH WAS CAUSED BY A PLUGIN
BAD PLUGIN: PiggyCustomEnchants v1.0.2-1

Code:
[14] use pocketmine\level\MovingObjectPosition;
[15] use pocketmine\math\Vector3;
[16] use pocketmine\network\mcpe\protocol\AddEntityPacket;
[17] use pocketmine\Player;
[18] 
[19] /**
[20]  * Class Fireball
[21]  * @package PiggyCustomEnchants\Entities
[22]  */
[23] class Fireball extends Projectile
[24] {
[25]     const NETWORK_ID = 94;
[26] 
[27]     /**
[28]      * @param $currentTick
[29]      * @return bool
[30]      */
[31]     public function onUpdate(int $currentTick) : bool
[32]     {
[33]         if ($this->closed) {

Backtrace:

PocketMine-MP version: 1.7dev #310 [Protocol 137; API 3.0.0-ALPHA9]
Git commit: 0000000000000000000000000000000000000000
uname -a: Windows NT DESKTOP-QIARTG9 10.0 build 15063 (Windows 10) AMD64
PHP Version: 7.2.0RC3
Zend version: 3.2.0-dev
OS : WINNT, win

Loaded plugins:
AdvancedKits 5.1.0-1 by luca28pet for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
AlwaysSpawn 2.2.3-3 by Philip Shilling for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
BlockPets 1.1.0 by BlockHorizons for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
EconomyAPI 5.7.1-3 by onebone for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
EconomyShop 2.0.8-5 by onebone for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
essentialsTP 1.2.0-2 by  for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
InvSee 1.2.0 by CapricornOfLynx for API(s) 3.0.0-ALPHA8, 3.0.0-ALPHA9
iProtector 3.1.0-3 by LDX for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
ItemCase 1.2.1 by aliuly for API(s) 3.0.0-ALPHA8, 3.0.0-ALPHA9
LockIt 1.3.4-2 by Awzaw for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
Parkour 1.5.6-3 by awzaw for API(s) 3.0.0-ALPHA8, 3.0.0-ALPHA9
PiggyCustomEnchants 1.0.2-1 by DaPigGuy for API(s) 3.0.0-ALPHA8, 3.0.0-ALPHA9
PurePerms 1.4.1-2 by 64FF00 & ProjectInfinity for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
Slapper 1.3.7 by jojoe77777 for API(s) 3.0.0-ALPHA9
TreasureChest 1.2.1-2 by Awzaw for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
VIPSlots 0.0.5 by iJoshuaHD for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
WorldProtect 2.3.5-3 by aliuly for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
XYZ 1.0.4 by unerds for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
EconomyAirport 2.0.4-2 by onebone for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
PureChat 1.4.10-3 by 64FF00 for API(s) 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9
xXNiceYT commented 6 years ago

Dude want fix here

xXNiceYT commented 6 years ago

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;

/**

  • Class Fireball
  • @package PiggyCustomEnchants\Entities */ class Fireball extends Projectile { const NETWORK_ID = 94;

    /**

    • @param $currentTick
    • @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); }

}

xXNiceYT commented 6 years ago

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;

/**

  • Class PigProjectile
  • @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;

    /**

    • PigProjectile constructor.
    • @param Level $level
    • @param CompoundTag $nbt
    • @param Entity|null $shootingEntity
    • @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 $currentTick
    • @return bool */ public function onUpdate(int $currentTick) : bool { $hasUpdate = parent::onUpdate($currentTick); if (!$this->hadCollision) { switch ($this->porklevel) { case 2: $this->getLevel()->dropItem($this, Item::get(Item::RAW_PORKCHOP, 0, 1)->setCustomName("Mysterious Raw Pork")); break; case 3: case 4: $this->getLevel()->dropItem($this, Item::get(Item::COOKED_PORKCHOP, 0, 1)->setCustomName("Mysterious Cooked Pork")); break; case 5: case 6: $this->getLevel()->dropItem($this, Item::get(Item::ROTTEN_FLESH, 0, 1)->setCustomName("Mysterious Rotten Pork")); break; } } else { $this->close(); } return $hasUpdate; }

    /**

    • @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); }

    /**

    • @return int */ public function getPorkLevel() { return $this->porklevel; } }