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

anyway to get all blocks on a chunk/Level of a Player but the for() ?

Discussion in 'Facepalm' started by Dicked, Jul 9, 2017.

  1. Dicked

    Dicked Shog Chips

    Messages:
    0
    Yo sup pmmp Devs, just wanted to ask how i can get all the blocks on a Level or a Chunk of a Player doesnt matter for what im going to make but the loop for() because it will lag the server i guess. ty
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    And the for() loop lags the server because getting all blocks on a chunk lacks by nature. Now what do you want?
     
  3. Dicked

    Dicked Shog Chips

    Messages:
    0
    i wanna get all Blocks on a chunk a player and hide them when he's like 10blocks away from them (AntiXray :v) . and all what i need is getting the blocks
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    You don't do it like that. When chunks are sent to the player, change the chunk into 100% air except the 10 blocks around the player. When the player moves, refresh the 10 blocks range, send old far blocks as air and new nearby blocks as-is.
    I may try to make a proof of concept for this.
     
    HimbeersaftLP and Thunder33345 like this.
  5. Dicked

    Dicked Shog Chips

    Messages:
    0
    i didnt mean change all the Blocks onlt ores and i will use the UpdateBlocksPacket and yea i was just lazy to do it like that xD
     
  6. Dicked

    Dicked Shog Chips

    Messages:
    0
    wait is it possible to register the DiamondBlock as a Tile to do Level::getTiles() etc.. ?
     
  7. Dicked

    Dicked Shog Chips

    Messages:
    0
    im sure that we can register a new Tile but will all the Diamond Blocks in the Level be a Tile (im not sure of that) ?
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    You should iterate over all blocks rather than trying to get all blocks together. for() lags, and getting all blocks together will both lag and kill your memory.
    And this thread is in Facepalm because it duplicates many other threads asking the exact same question.
     
  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.