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

Solved Applying setBiomeColour To Every Grass Block In The World

Comments in 'Plugin Development' started by Calrizer, Jul 21, 2015.

  1. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
    Hi,
    Today I'm working on fixing the annoying black grass blocks when you import a MCPC anvil world and to fix it applying setBiomeColour to every grass block in the world fixes this. I think this would be done by using a function similar to getting all the players in a world:
    PHP:
    foreach($this->getServer->getLevelByName($world)->getPlayers() as $p){ 
    But instead of the 'getPlayers as $p' there could be a feature like 'getBlocks() as $b' then use an if statement to detect if the blocks are an instance of grass blocks.

    Any help is appreciated,

    -Calrizer
    Last edited: Jul 21, 2015
  2. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,429
    Plugins:
    14
    For starters, a function like Level::getBlocks() would cause so much lag that the server would crash if you tried to use it. Second, I believe that setBiomeColor is non-dependent on Y coordinates.
    PEMapModder likes this.
  3. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
    You are correct that the set biome colour doesn't need a Y coordinate only X and Z and the function will only happen upon the initialisation of the server so there will only be one lag spike which the players would not experience.
  4. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,429
    Plugins:
    14
    Oh, I see. Well, you could try some for loops... I'm not sure how big this world is, but here, customize it as you need. (You'll probably also want to choose a better color. :p)
    PHP:
    for($x = -100$x <= 100$x++) {
      for(
    $z = -100$z <= 100$z++) {
        
    $level->setBiomeColor($x,$z,0,255,0);
      }
    }
    PEMapModder and Calrizer like this.
  5. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
    Yeah that works great and the best thing is you only need to run it one then the changes are saved so you can delete the code after you use it.

    For those of you wanting the default grass colour the RGB is: 127, 169, 76
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    thebigsmileXD and Calrizer like this.
  7. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
  8. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    when you use only setBiomeColor() it crash a server
    look at PaintMyLawn
  10. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
    I haven't been having any problems with it, if anything it fixed a lot of problems!
  11. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    so what is this code in PaintMyLawn?
    PHP:
    $index Level::chunkHash($x$z);
                        
    Cache::remove("world:".($level->getName()).":" $index);
                        foreach(
    $level->getUsingChunk($x >> 4$z >> 4) as $player){
                
    $player->unloadChunk($x >> 4$z >> 4);
                        }
  12. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
    It looks like it takes chunks that are not in use and unloads and removes them, I'm guessing to prevent the server crashing from a user trying to set the ground to a colour on an unloaded/corrupted chunk, which could crash the server.
  13. lucasvitegui
    Offline

    lucasvitegui Active Member

    Joined:
    Apr 18, 2015
    Posts:
    191
    Minecraft User:
    lucasviteguiBR
    Is there a tool that repair the black grass ?
  14. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Lag can be solved by using method that Falk uses in his plugin MineReset.
    Creeperface likes this.
  15. lucasvitegui
    Offline

    lucasvitegui Active Member

    Joined:
    Apr 18, 2015
    Posts:
    191
    Minecraft User:
    lucasviteguiBR
    it's not because lag.. i converted a map from anvil to mcregion and all the grass are black.. So did you get success replacing it to green ?
  16. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Thats thr point while code turns all grass to green it lags, lags, lags.
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    thebigsmileXD likes this.
  18. itmedevcraft_
    Offline

    itmedevcraft_ New Member

    Joined:
    Oct 27, 2015
    Posts:
    6
    Minecraft User:
    itmedevcraft_
    Where would you put that code? In PocketMine-MP.phar? A plugin? Lol
  19. Calrizer
    Offline

    Calrizer Active Member

    Joined:
    Jan 17, 2015
    Posts:
    102
    Minecraft User:
    callumdrain
    You'd put it in a plugin. Just put it in when you call the server enable.
    itmedevcraft_ likes this.
  20. itmedevcraft_
    Offline

    itmedevcraft_ New Member

    Joined:
    Oct 27, 2015
    Posts:
    6
    Minecraft User:
    itmedevcraft_
    Ok, thank you

Share This Page

Advertisement