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

How do I set blocks

Discussion in 'Development' started by xXNiceAssassinlo YT, Aug 22, 2018.

  1. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    how do I set block without using $level->setBlock bc that lags
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Force a player to break the block. There is no other way. Level::sendBlocks() would help.
     
  3. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    I
    There is muqsit used a faster way
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Async tasks?
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    If you're talking about the method used in WorldStyler... it still comes at a cost. It isn't that efficient for micro block updates. You could use:
    • Level->setBlock(Vector3, Block, false, false) — skips light updates and neighbouring block updates
    • Level->setBlockIdAt() + Level->setBlockDataAt() — updates block data in chunk and updates level cache. this is what explosions use too. but note that that's not a free-of-cost block setter, it ignores various block and light updates and directly modifies the block data in the chunk. also don't forget to floor the coordinates before passing it as the parameters.
     
    HimbeersaftLP 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.