1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Help? Class Not found? But its there

Discussion in 'Development' started by Remarkabless, Dec 6, 2017.

  1. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    PHP:
    namespace lightning;

    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\network\mcpe\protocol\AddEntityPacket;
    use 
    pocketmine\network\mcpe\protocol\EntityEventPacket;
    use 
    pocketmine\network\mcpe\protocol\MoveEntityPacket;
    use 
    pocketmine\network\mcpe\protocol\RemoveEntityPacket;
    use 
    pocketmine\network\mcpe\protocol\SetEntityDataPacket;
    use 
    pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;

    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
           
    }
           
            public function 
    addStrike(Player $player$height) {
                
    $level $player->getLevel();
                
    $light = new AddEntityPacket();
                
    $light->type 93;
                
    $light->EntityRuntimeId Entity::$entityCount++;
                
    $light->metadata = array();
                
    $light->position $p->asVector3()->add(0,$height,0);
                
    $light->yaw $player->getYaw();
                
    $light->pitch $player->getPitch();
                
    $player->getServer()->broadcastPacket($level->getPlayers(),$light);
               
            }

            public function 
    onDeath(PlayerDeathEvent $event) {
                
    $player $event->getEntity();
                    if(
    $player instanceof Player){
                        
    $this->addStrike($player,0);
                    }
            }
    }


    How can I add the main class? I dont really understand what the error is saying

    Error:
    Code:
    Server thread/CRITICAL Could not pass event 'pocketmine\event\player\PlayerDeathEvent' to 'ChestDrop v0.0.1': Class 'ChestDrop\AddEntityPacket' not found on ChestDrop\Main
    
    Thanks for the help in advance!
     
    Last edited: Dec 6, 2017
  2. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    You need
    PHP:
    use pocketmine\network\mcpe\protocol\AddEntityPacket;
     
  3. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    Read the code,I have it in there.
     
  4. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Where death function
     
    Levi likes this.
  5. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    Edited the post, posted it now
     
  6. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    The error you provided is not reproducable, although there are some other problems with your code:

    The 'e' in entityRuntimeId should not be capitalised:
    The $p variable is undefined, you should be using $player as it is the name you assigned to the player parameter.
    You also forgot to import pocketmine\entity\Entity;


    I've included the fixed code below but would encourage you to try and debug simple issues like this yourself. It'd also be helpful if you provided an error that is actually reproducible and relevant to the code next time.

    PHP:
    <?php

    namespace lightning;

    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\network\mcpe\protocol\AddEntityPacket;
    use 
    pocketmine\network\mcpe\protocol\EntityEventPacket;
    use 
    pocketmine\network\mcpe\protocol\MoveEntityPacket;
    use 
    pocketmine\network\mcpe\protocol\RemoveEntityPacket;
    use 
    pocketmine\network\mcpe\protocol\SetEntityDataPacket;
    use 
    pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\entity\Entity;

    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
           
        public function 
    addStrike(Player $player$height) {
            
    $level $player->getLevel();
            
    $light = new AddEntityPacket();
            
    $light->type 93;
            
    $light->entityRuntimeId Entity::$entityCount++;
            
    $light->metadata = array();
            
    $light->position $player->asVector3()->add(0,$height,0);
            
    $light->yaw $player->getYaw();
            
    $light->pitch $player->getPitch();
            
    $player->getServer()->broadcastPacket($level->getPlayers(), $light);   
        }

        public function 
    onDeath(PlayerDeathEvent $event) {
            
    $player $event->getEntity();
            if(
    $player instanceof Player) {
                
    $this->addStrike($player,0);
            }
        }

    }
     
  7. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    T
    Yeah this was a messed up version of the code, even though I fixed literally everything, I simply dont know what it means by cant find the AddEntityPacket Class when it is there
     
  8. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    The error seems like you haven't imported AddEntityPacket. I would double check to make sure even tho you said you have it.
     
  9. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    We have gone through this!
     
    jasonwynn10 likes this.
  10. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Karanpatel567 likes this.
  11. R4EVAELRM

    R4EVAELRM Witch

    Messages:
    73
    :facepalm:
     
    SOFe likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.