Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved what is wrong ? - Block under Player

Comments in 'Plugin Development' started by PaulchenHD, May 21, 2016.

  1. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    I have a problem with my code :) thx for helping ;)
    Code:
    PHP:
      public function onMove(PlayerMoveEvent $event){
      
    $player $event->getPlayer();
      
    $block $player->getLevel()->getBlock($player->floor()->subtract(010));
      if(
    $block->getId() === 1) {
      
    $player->getLevel()->setBlock(new Vector3($block->getX(), $block->getY(), $block->getZ()), Block::AIR);
      }
      }
    }
    Error:
    PHP:
    [20:51:41] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerMoveEvent' to 'test v1': Argument 2 passed to pocketmine\level\Level::setBlock() must be an instance of pocketmine\block\Block, integer given, called in C:\Users\User\Downloads\PocketMine-MP\plugins\test\src\test\Main.php on line 21 and defined on test\Main
    [20:51:41] [Server thread/NOTICE]: InvalidArgumentException: "
    Argument 2 passed to pocketmine\level\Level::setBlock() must be an instance of pocketmine\block\Blockinteger givencalled in C:\Users\User\Downloads\PocketMine-MP\plugins\test\src\test\Main.php on line 21 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/level/Level" at line 1582
  2. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Maybe:
    PHP:
    $airblock = new Block(0);
    $player->getLevel()->setBlock(new Vector3($block->getX(), $block->getY(), $block->getZ()), $airblock);
    :D
    PaulchenHD likes this.
  3. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    thanks it works <3 :D | Dankieeee es funktioniert :D <3
    abxyHD and cake23 like this.
  4. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    <3
    PaulchenHD likes this.

Share This Page

Advertisement