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

Plugin GameSelector Error

Discussion in 'Development' started by rektpixel, May 13, 2017.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    I have this error, idk how to fix it. please help
    This is the error in console:
    Code:
    [PocketMine] > "Could not pass event 'pocketmine\event\entity\EntityDamageByEntityEvent' to 'GameSelector v1': Argument 1 passed to pocketmine\tile\Chest::__construct() must be an instance of pocketmine\level\Level, instance of pocketmine\level\format\Chunk given, called in C:\Users\Admin\Creative Cloud Files\Desktop\PymePE\Lobby - PrymePE\plugins\GameSelector-master\src\GameSelector\Main.php on line 176 on GameSelector\Main
    [PocketMine] > TypeError: "Argument 1 passed to pocketmine\tile\Chest::__construct() must be an instance of pocketmine\level\Level, instance of pocketmine\level\format\Chunk given, called in C:\Users\Admin\Creative Cloud Files\Desktop\PymePE\Lobby - PrymePE\plugins\GameSelector-master\src\GameSelector\Main.php on line 176" (EXCEPTION) in "/src/pocketmine/tile/Chest" at line 44
    
    Here is the plugin code line 166 - 189:
    PHP:
        public function OnDamage(EntityDamageEvent $event){
            if(
    $event instanceof EntityDamageByEntityEvent){
                
    $player=$event->getDamager();
                
    $entity=$event->getEntity();
                if(
    $player instanceof Player and $this->mode==1){
                    
    $event->setCancelled(true);
                        
    $x=round($entity->getX());
                        
    $y=round($entity->getY() - 3);
                        
    $z=round($entity->getZ());
                        
    $player->getLevel()->setBlock(new Vector3($x$y$z), Block::get(54));
                        
    $chest = new Chest($player->getLevel()->getChunk($x >> 4$z >> 4true), new CompoundTag(false, array(new IntTag("x"$x), new IntTag("y"$y), new IntTag("z"$z), new StringTag("id"Tile::CHEST))));
                        
    $chest->setName($this->name);
                        
    $chest->saveNBT();
                        
    $player->getLevel()->addTile($chest);
                       
    $chest2=new ChestInventory($player->getLevel()->getTile(new Vector3($x$y$z)), $player);
                       
    $ch=$player->getLevel()->getTile(new Vector3($x$y$z));
                       
    $n=$this->name;
                       
    $ch->saveNBT();
                       
    $level=$player->getLevel()->getFolderName();
                       
    $this->config->setNested("Selectors.$n", ["x"=>$x"y"=>$y"z"=>$z"level"=>$level"Items"=>new ListTag("Items",$ch->getInventory()), "SelectorName"=>$n"FloatingText"=>false"FloatingTextName"=>$n]);
                       
    $this->config->setAll($this->config->getAll());
                       
    $this->config->save();
                       
    $player->sendMessage($this->prefix.c::GRAY."Entity Selected!");
                       
    $this->mode=0;
     
  2. KnownUnown

    KnownUnown Spider Jockey Poggit Reviewer

    Messages:
    47
    GitHub:
    knownunown
    Level::getChunk() returns Chunk. The error explains the rest ;)
     
  3. moska

    moska Baby Zombie

    Messages:
    105
    GitHub:
    supermaxalex
    This one needs to be :
    PHP:
    $chest = new Chest($player->getLevel(), new CompoundTag(false, array(new IntTag("x"$x), new IntTag("y"$y), new IntTag("z"$z), new StringTag("id"Tile::CHEST))));
     
  4. Miste

    Miste Baby Zombie

    Messages:
    109
    GitHub:
    Misteboss
    Maybe @Ad5001 can help you (I am not sure but i think he made this plugin)
     
  5. moska

    moska Baby Zombie

    Messages:
    105
    GitHub:
    supermaxalex
    It's just an API change.
     
    0x15f 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.