setRandomAmount() public method

public setRandomAmount ( $amount )
Exemplo n.º 1
0
 public function init(GenerationChunkManager $level, Random $random)
 {
     $this->level = $level;
     $this->random = $random;
     $this->random->setSeed($this->level->getSeed());
     $this->noiseHills = new Simplex($this->random, 3, 0.1, 12);
     $this->noiseBase = new Simplex($this->random, 16, 0.6, 16);
     $ores = new Ore();
     $ores->setOreTypes([new OreType(new CoalOre(), 20, 16, 0, 128), new OreType(new IronOre(), 20, 8, 0, 64), new OreType(new RedstoneOre(), 8, 7, 0, 16), new OreType(new LapisOre(), 1, 6, 0, 32), new OreType(new GoldOre(), 2, 8, 0, 32), new OreType(new DiamondOre(), 1, 7, 0, 16), new OreType(new Dirt(), 20, 32, 0, 128), new OreType(new Gravel(), 10, 16, 0, 128)]);
     $this->populators[] = $ores;
     $trees = new Tree();
     $trees->setBaseAmount(1);
     $trees->setRandomAmount(1);
     $this->populators[] = $trees;
     $tallGrass = new TallGrass();
     $tallGrass->setBaseAmount(5);
     $tallGrass->setRandomAmount(0);
     $this->populators[] = $tallGrass;
 }
Exemplo n.º 2
0
 public function init(GenerationChunkManager $level, Random $random)
 {
     $this->level = $level;
     $this->random = $random;
     $this->random->setSeed($this->level->getSeed());
     $this->noiseHills = new Simplex($this->random, 3, 0.1, 12);
     $this->noiseBase = new Simplex($this->random, 16, 0.6, 16);
     $this->parsePreset($this->preset);
     if (isset($this->cfg["decoration"])) {
         $ores = new Ore();
         $ores->setOreTypes([new OreType(new CoalOre(), 20, 16, 0, 128), new OreType(new IronOre(), 20, 8, 0, 64), new OreType(new RedstoneOre(), 8, 7, 0, 16), new OreType(new LapisOre(), 1, 6, 0, 32), new OreType(new GoldOre(), 2, 8, 0, 32), new OreType(new DiamondOre(), 1, 7, 0, 16), new OreType(new Dirt(), 20, 32, 0, 128), new OreType(new Gravel(), 10, 16, 0, 128)]);
         $this->populators[] = $ores;
         if (isset($this->cfg["decoration"]["treecount"])) {
             $tc = explode(":", $this->cfg["decoration"]["treecount"]);
             if (!isset($tc[0])) {
                 $tc[0] = 0;
             }
             if (!isset($tc[1])) {
                 $tc[0] = 0;
             }
             if ($tc[0] != 0 && $tc[1] != 0) {
                 $trees = new Tree();
                 $trees->setBaseAmount($tc[0]);
                 $trees->setRandomAmount($tc[1]);
                 $this->populators[] = $trees;
             }
         }
         if (isset($this->cfg["decoration"]["grasscount"])) {
             $tc = explode(":", $this->cfg["decoration"]["grasscount"]);
             if (!isset($tc[0])) {
                 $tc[0] = 0;
             }
             if (!isset($tc[1])) {
                 $tc[0] = 0;
             }
             if ($tc[0] != 0 && $tc[1] != 0) {
                 $tallGrass = new TallGrass();
                 $tallGrass->setBaseAmount($tc[0]);
                 $tallGrass->setRandomAmount($tc[1]);
                 $this->populators[] = $tallGrass;
             }
         }
         if (isset($this->cfg["decoration"]["desertplant"])) {
             $tc = explode(":", $this->cfg["decoration"]["desertplant"]);
             if (!isset($tc[0])) {
                 $tc[0] = 0;
             }
             if (!isset($tc[1])) {
                 $tc[0] = 0;
             }
             if ($tc[0] != 0 && $tc[1] != 0) {
                 $cacti = new DesertPlant();
                 $cacti->setBaseAmount($tc[0]);
                 $cacti->setRandomAmount($tc[1]);
                 $this->populators[] = $cacti;
             }
         }
     }
     if (isset($this->cfg["dsq"])) {
         $dsq = $this->cfg["dsq"];
     } else {
         $dsq = array();
     }
     // Define some suitable defaults
     $min = isset($dsq["min"]) ? intval($dsq["min"]) : 32;
     $max = isset($dsq["max"]) ? intval($dsq["max"]) : 120;
     if ($min > $max) {
         list($min, $max) = array($max, $min);
     }
     //$this->waterLevel = isset($dsq["water"])?
     //intval($dsq["water"]):$min+($max-$min)/3;
     //$off = floatval(isset($dsq["off"]) ? intval($dsq["off"]) : 100);
     $this->waterBlock = isset($dsq["waterblock"]) ? intval($dsq["waterblock"]) : Block::STILL_WATER;
     //$this->dotsz = floatval(isset($dsq["dotsz"]) ? $dsq["dotsz"] : 0.9);
     //$this->dotoff= array('x'=>intval((1.0-$this->dotsz)*$this->rnd()
     //*self::DSQ_SIZE),
     //'y'=>intval((1.0-$this->dotsz)*$this->rnd()
     //*self::DSQ_SIZE));
     //$fn = isset($dsq["fn"]) ? $dsq["fn"] : "linear";
     //$fndat = explode(":",isset($dsq["fdat"]) ? $dsq["fdat"] : 1);
     // Strata map...
     $this->strata = array();
     if (isset($dsq["strata"])) {
         $strata = explode(":", $dsq["strata"]);
     } else {
         $strata = array();
     }
     $i = 0;
     for ($y = 0; $y < 128; ++$y) {
         if (isset($strata[$i])) {
             if ($strata[$i] > $y) {
                 $this->strata[$y] = $i;
             } else {
                 $this->strata[$y] = ++$i;
             }
         } else {
             $this->strata[$y] = $i;
         }
     }
 }