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

Hi how to fixed trying to get property placedBlocks on non-object?

Discussion in 'General discussion' started by Hoangviphb999, Oct 9, 2020.

?

How to fix ?

  1. Pls help me

    1 vote(s)
    25.0%
  2. Pls

    3 vote(s)
    75.0%
  1. Hoangviphb999

    Hoangviphb999 Silverfish

    Messages:
    21
    GitHub:
    Hoangviphb999
    public function onExplode(EntityExplodeEvent $ev) : void{
    $entity = $ev->getEntity();
    if(!$entity instanceof PrimedTNT)return;
    $level = $entity->level;
    $game = true;
    foreach ($level->getPlayers() as $player) {
    if($g = $this->plugin->getPlayerGame($player) !== true){
    $game = $g;
    }
    }
    if($game == false)return;

    $newList = array();

    foreach($ev->getBlockList() as $block){
    if(in_array(Utils::vectorToString(":", $block->asVector3()), $game->placedBlocks)){
    $newList[] = $block;
    }
    }
    $ev->setBlockList($newList);
    }
     
  2. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    You're going to have to be more specific. What error do you get? What's the rest of your code look like?
     
    Primus likes this.
  3. Primus

    Primus Zombie Pigman

    Messages:
    749
    $game is obviously not what you expect it to be!

    var_dump($game); to see what you're getting and traceback manually to see where the error lays.
     
    EdwardHamHam likes this.
  4. IvanCraft623

    IvanCraft623 Baby Zombie

    Messages:
    105
    GitHub:
    IvanCraft623
    EdwardHamHam likes this.
  5. Hoangviphb999

    Hoangviphb999 Silverfish

    Messages:
    21
    GitHub:
    Hoangviphb999
  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.