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

setBlockIdAt

Discussion in 'Help' started by Kkora, Dec 21, 2018.

  1. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    Do you know why this code not working?
    PHP:
    for($x 5$x 10$x++){
                for(
    $z 5$z 10$z++){
                    
    $level->setBlockIdAt($vec->$x67$vec->$zBlock::STONE);
                    
    $wool_color1 6;
                    
    $wool1 Block::get(35$wool_color1);
                    
    $level->setBlockIdAt($vec->$x72$vec->$zBlock::$wool1); // 72
                
    }
            }
    And the Output:
    Code:
    2018-12-21 [12:50:17] [Server thread/INFO]: Preparing level "sb"
    2018-12-21 [12:50:17] [Server thread/NOTICE]: Spawn terrain for level "sb" is being generated in the background
    2018-12-21 [12:50:18] [Asynchronous Worker #1 thread/CRITICAL]: TypeError: "Argument 4 passed to pocketmine\level\SimpleChunkManager::setBlockIdAt() must be of the type integer, object given, called in E:\PMMP\PocketMine\plugins\SkyBlock\src\SkyBlock\SkyBlockStructure.php on line 43" (EXCEPTION) in "/src/pocketmine/level/SimpleChunkManager" at line 71
    2018-12-21 [12:50:18] [Server thread/CRITICAL]: Could not execute asynchronous task PopulationTask: Task crashed
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    PHP:
    var_dump(Block::$wool1)
    It's probably what you don't expect.

    Solution: Replace "Block::$wool1" with "$wool1"
     
    corytortoise likes this.
  3. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    Still have the same error.
     
  4. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    setBlockIdAt only expects the block id, if you want to set the block data too:
    PHP:
    $level->setBlockIdAt($vec->$x72$vec->$zBlock::WOOL);
    $level->setBlockDataAt($vec->$x72$vec->$z$wool_color1);
     
    corytortoise and Primus like this.
  5. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    still error:
    Code:
    2018-12-22 [17:44:41] [Server thread/CRITICAL]: Could not execute asynchronous task PopulationTask: Task crashed
    2018-12-22 [17:44:41] [Server thread/INFO]: Created world called sbb
    2018-12-22 [17:44:41] [Asynchronous Worker #2 thread/CRITICAL]: TypeError: "Argument 4 passed to pocketmine\level\SimpleChunkManager::setBlockIdAt() must be of the type integer, object given, called in E:\PMMP\PocketMine\plugins\SkyBlock\src\skyblock\SkyBlockStructure.php on line 43" (EXCEPTION) in "/src/pocketmine/level/SimpleChunkManager" at line 71
    
     
  6. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    If you used my code it would not have this error, there is no way Block::WOOL is an object
    Show me the whole function that you are using at
    SkyBlockStructure.php on line 43
    and which version of pmmp are you using
     
    Primus likes this.
  7. Primus

    Primus Zombie Pigman

    Messages:
    749
    My apologies. I got confused by recent API changes. You must pass integer, which is block/item id, which is numeric. And to pass meta/variant value, You can do second call to SimpleChunkManager::setBlockDataAt(...)
     
    corytortoise 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.