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

Remove all blocks with id *

Comments in 'Plugin Development' started by jjmc, Nov 4, 2015.

  1. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    Hi,
    I'm developing a mini game and want to reset the world after the game.
    Players can only build sandstone, so how can I remove (or replace with air) all the sandstone in the world?
  2. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    PHP:
    $lv $this->getServer()->getLevelByName("yourworld");
    for (
    $x = -999$x <= 1000$x++){
     for (
    $y 1$y <= 100$y++){
      for (
    $z = -999$z <= 100$z++){
        if (
    $lv->getBlockIdAt($x,$y,$z) == Item::SANDSTONE){ //no matter which sandstone you build
         
    $lv->setBlock(new Vector3($x,$y,$z), Block::get(0));
        }
       }
      }
     }
    This will lag your server for 20 minutes, so it isn't good way

    Or, use WorldResetting method. Backup your worlds at specified folder and then copy the region files
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    or if it is map generated by plugin or pocketmine you can simply generate new map with the same seed
    iDirtPlayzMC likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Or just don't let the world save.
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Any example?
  6. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    /save-off

    after

    PHP:
    if($this->getServer()->isLevelLoaded(/*LevelName*/)){
    $this->getServer()->unloadLevel(/*levelname*/);
    }
    if(!
    $this->getServer()->isLevelLoaded(/*LevelName*/)){
    $this->getServer()->loadLevel(/*LevelName*/);
    }
    world become back again ;)
    thebigsmileXD and jjmc like this.
  7. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Hmm.. You cant cancel levelsaveevent

    And only unloading them doesn't work either. Is there something like save-off for plugins? ->saveOff or so?
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    look how PocketMine does it :p

Share This Page

Advertisement