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

Solved entity create error!

Discussion in 'Development' started by KHAV, Aug 3, 2017.

  1. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    i am try to create entity but when i spawn it, it give me error:
    Code:
    [18:51:23] [Server thread/CRITICAL]: Unhandled exception executing command 'boss zombie' in boss: Argument 2 passed to pocketmine\entity\Entity::createEntity() must be an instance of pocketmine\level\Level, instance of pocketmine\level\format\Chunk given, called in C:\Users\Khaled\Desktop\PocketMine-MP\plugins\BossTest\src\BossTest\BossTest.php on line 75
    
    And this the code at line 75
    PHP:
    $mob Entity::createEntity(Zombie::NETWORK_ID$sender->chunk$nbt);
    $mob->setMaxHealth(500);
    $mob->setHealth(500);
    $mob->setScale(5);
    $mob->setNameTag("§8<§aTITAN§8>");
    $mob->spawnToAll();
     
    Jack Noordhuis likes this.
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you copied an outdated code, also next time try not to copy code and also read errors
     
    jasonwynn10, Muqsit and SOFe like this.
  3. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    sorry xD , ok can you give me the correct code?
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    I am not spoon feeding you,
    read the ERROR
    and the correct code should be very clear to you
     
    jasonwynn10, Muqsit, Marabou and 3 others like this.
  5. Enes5519

    Enes5519 Spider Jockey

    Messages:
    28
    GitHub:
    Enes5519
    PHP:
    $mob Entity::createEntity("Zombie"$sender->getLevel(), $nbt);
    $mob->setMaxHealth(500);
    $mob->setHealth(500);
    $mob->setScale(5);
    $mob->setNameTag("§8<§aTITAN§8>");
    $mob->spawnToAll();
    SOLVED ?
     
    KHAV likes this.
  6. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    Thank you !! Solved
     
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    Give a man a fish and you feed a man for a day
    Teach a man to fish and you feed a man for a lifetime
     
  8. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    Your issue is:
    [18:51:23] [Server thread/CRITICAL]: Unhandled exception executing command 'boss zombie' in boss: Argument 2 passed to pocketmine\entity\Entity::createEntity() must be an instance of pocketmine\level\Level, instance of pocketmine\level\format\Chunk given, called in C:\Users\Khaled\Desktop\PocketMine-MP\plugins\BossTest\src\BossTest\BossTest.php on line 75
    that's too much so lets narrow it down:
    Unhandled exception executing command 'boss zombie' in (plugin name): Argument 2 passed to pocketmine\entity\Entity::createEntity() must be an instance of pocketmine\level\Level, instance of pocketmine\level\format\Chunk given, called in file on line X
    still clueless?
    Argument 2 passed to pocketmine\entity\Entity::createEntity() must be an instance of pocketmine\level\Level, instance of pocketmine\level\format\Chunk given

    basically you given the wrong thing PMMP wanted
    it's like trying to give a key to a smart reader door
    PHP:
    # SmartDoor::open(SmartCard$card) is the method
    # looks like public function open(SmartCard$card){...} in class
    # but you did
    $key = new Key()
    $smartDoor->open($key)
    the smart door type hinted to need SmartCard not Key so it emits:
    Argument 1 passed to SmartDoor::Open() must be an instance of SmartCard, instance of Key given
    which is basically your issue of unknowingly passing wrong things
     
    jasonwynn10, SalmonDE and Sandertv like this.
  9. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    Thank you for your advice I will try to learn more!
     
  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.