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

Plz Help!!! ERROR OVERLOAD!!!!!

Comments in 'Plugin Development' started by Samueljh1, Jan 11, 2015.

  1. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Hi, can someone help me?? I have a onPlayerMove listener (which works great) , but when I try to get a block at the player's coords I keep getting the SAME error.
    ..

    This is the getBlock code:

    $block = $level->getBlock(new Vec3($x,$y,$z));

    $id = $block->getID();

    It keeps saying undefined func "level". I have also done

    use pocketmine\level\Level
  2. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    You must declare $level = something; before use it :)
  3. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    So what would I do? I'm completely new to the api... :(
  4. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Can you post the full code? :)
  5. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Sorry, I can't right now, but the script is a player move listener, and inside that is the code above. That's all. (I've added an if statement to check if the ID is 9. (Water). That's all ;( (the error is for the code above only)
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $level = $player->getLevel(); in this case, where $player is the Player object from the event.
  7. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    OK, thanks I will try that :) . So will this allow $level->getBlock() ?
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes, read the documentation, $player->getLevel() returns a Level instance and Level has a member function getBlock(Vector3).
  9. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    OK thanks! Just in interest, why couldn't I use pocketmine\level ? Because I believe this is pocketmine\event\level
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The `use` statement is read at startup time, where if you use name\space\ClassName, ClassName in your code will become that full path you used. So actually you don't need to use in this case.
  11. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    What do you mean? Sorry I am such a noob :p
  12. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    :p
    Wait, so yo mean the ClassName will be an assigned variable? Eg: use something/1/2 then $2 will be a variable of /something/1/2 ?
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    no, class names are class names not variable names. Learn OOP.
    And it is backslash \ not forward slash /
  14. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    OOP? Lol typo with the "\". Sorry, I'm just so new to php -- I do java more xD

    Can u help me with one thing? Say I wanted to do get block etc. And I have imported pocketmine\block; how would I call the function pocketmine\block\getBlock() ??

    Lol that's pretty much what the main question of this thread is :p

    Thanks :)
  15. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Block::getBlock() if you have added a use statement and \pocketmine\block\Block::getBlock() if you haven't.
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is Block::get() not Block::getBlock() ;)
    Falk likes this.
  17. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Lol i just read this thread again. LOL xD

Share This Page

Advertisement