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

Error in my Plugin

Discussion in 'Development' started by Jonas, May 9, 2017.

  1. Jonas

    Jonas Baby Zombie

    Messages:
    192
    My Plugin doesnt work. It will make that i can shot Snowballs on a rod. Here is the Error
    Code:
    [Server] [PocketMine] [12:36:31] CRITICAL> "Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'SoupFFA v1.0.0': Class pocketmine\nbt\tag\EnumTag not found on Main\SoupFFA
    [Server] [PocketMine] [12:36:31] CRITICAL> ClassNotFoundException: "Class pocketmine\nbt\tag\EnumTag not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144
    Here is the PlayerInteractEvent in my Code:
    PHP:
    public function onInteract(PlayerInteractEvent $event){
            if(
    $event->getItem()->getId() == 346){
                     
    $namedTag = new CompoundTag("", [
                                    
    "Pos" => new EnumTag("Pos", [
                                        new 
    DoubleTag(""$player->x),
                                        new 
    DoubleTag(""$player->$player->getEyeHeight()),
                                        new 
    DoubleTag(""$player->z)
                                    ]),
                                    
    "Motion" => new EnumTag("Motion", [
                                        new 
    DoubleTag("", -sin($player->yaw 180 M_PI) * cos($player->pitch 180 M_PI)),
                                        new 
    DoubleTag("", -sin($player->pitch 180 M_PI)),
                                        new 
    DoubleTag(""cos($player->yaw 180 M_PI) * cos($player->pitch 180 M_PI))
                                    ]),
                                    
    "Rotation" => new EnumTag("Rotation", [
                                        new 
    FloatTag(""$player->yaw),
                                        new 
    FloatTag(""$player->pitch)
                                    ]),
                                ]);
                            
    $ball = new SnowBall($player->chunk$namedTag$player);
                            
    $ball->setMotion($event->getMotion()->multiply(3));
                            
    $ball->spawnToAll();
                           
    $player->getLevel()->addSound(new BlazeShootSound($player), [$player]);
            }
        }
    PS. I have importet
    pocketmine\nbt\tag\DoubleTag, pocketmine\nbt\tag\FloatTag, pocketmine\nbt\tag\CompoundTag and pocketmine\nbt\tag\EnumTag
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    blind guessing you should update your IDE seems like parts of networking namespace have changed not sure if NBT are changed doe
     
  3. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  4. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Thanks
    Can you also help me with another error its the New error as i have EnumTag replace to ListTag. Here is the Error
    Code:
    [Server] [PocketMine] [13:41:06] CRITICAL> "Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'SoupFFA v1.0.0': Argument 1 passed to pocketmine\entity\Snowball::__construct() must be an instance of pocketmine\level\Level, instance of pocketmine\level\format\Chunk given, called in /storage/emulated/0/PocketMine/plugins/SoupFFA_v2.0.0/src/Main/SoupFFA.php on line 192 on Main\SoupFFA
    [Server] [PocketMine] [13:41:06] CRITICAL> TypeError: "Argument 1 passed to pocketmine\entity\Snowball::__construct() must be an instance of pocketmine\level\Level, instance of pocketmine\level\format\Chunk given, called in /storage/emulated/0/PocketMine/plugins/SoupFFA_v2.0.0/src/Main/SoupFFA.php on line 192" (EXCEPTION) in "/src/pocketmine/entity/Snowball" at line 39
    
     
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    :facepalm::facepalm::facepalm:
    Did you even read the error???
    This topic needs moved to facepalm...
     
  6. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Yes i read this. I ve imported pocketmine\entity\Snowball, pocketmine\level\format\Chunk and pocketmine\level\Level.
     
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    :facepalm:
    simply importing is not the solution. The use statements aren't even needed! You have to pass the Level object instead of the Chunk object. It's exactly as the error states!
    :facepalm::facepalm::facepalm::facepalm::facepalm::facepalm:
     
  8. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Sorry i don t understand. how can i make this?
     
  9. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    When you are creating the snowball, use the Level that you are spawning it in instead of the Chunk.
     
  10. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    Best way to get help is to provide a "working" code with only the important parts.


    Never ever do anything like this:
    Code:
    $event->getItem()->getId() == 346
    Editor: vim
     
  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.