예제 #1
0
 public function __construct(array $options = [])
 {
     $this->preset = "2;7,2x3,2;1;";
     //$this->preset = "2;7,59x1,3x3,2;1;spawn(radius=10 block=89),decoration(treecount=80 grasscount=45)";
     $this->options = $options;
     $this->chunk = null;
     if (isset($this->options["decoration"])) {
         $ores = new Ore();
         $ores->setOreTypes([new object\OreType(new CoalOre(), 20, 16, 0, 128), new object\OreType(new IronOre(), 20, 8, 0, 64), new object\OreType(new RedstoneOre(), 8, 7, 0, 16), new object\OreType(new LapisOre(), 1, 6, 0, 32), new object\OreType(new GoldOre(), 2, 8, 0, 32), new object\OreType(new DiamondOre(), 1, 7, 0, 16), new object\OreType(new Dirt(), 20, 32, 0, 128), new object\OreType(new Gravel(), 10, 16, 0, 128)]);
         $this->populators[] = $ores;
     }
     /*if(isset($this->options["mineshaft"])){
     			$this->populators[] = new MineshaftPopulator(isset($this->options["mineshaft"]["chance"]) ? floatval($this->options["mineshaft"]["chance"]) : 0.01);
     		}*/
 }
예제 #2
0
 public function init(ChunkManager $level, Random $random)
 {
     $this->level = $level;
     $this->random = $random;
     $this->random->setSeed($this->level->getSeed());
     $this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
     $this->random->setSeed($this->level->getSeed());
     $this->selector = new BiomeSelector($this->random, function ($temperature, $rainfall) {
         if ($rainfall < 0.25) {
             if ($temperature < 0.7) {
                 return Biome::OCEAN;
             } elseif ($temperature < 0.85) {
                 return Biome::RIVER;
             } else {
                 return Biome::SWAMP;
             }
         } elseif ($rainfall < 0.6) {
             if ($temperature < 0.25) {
                 return Biome::ICE_PLAINS;
             } elseif ($temperature < 0.75) {
                 return Biome::PLAINS;
             } else {
                 return Biome::DESERT;
             }
         } elseif ($rainfall < 0.8) {
             if ($temperature < 0.25) {
                 return Biome::TAIGA;
             } elseif ($temperature < 0.75) {
                 return Biome::FOREST;
             } else {
                 return Biome::BIRCH_FOREST;
             }
         } else {
             if ($temperature < 0.25) {
                 return Biome::MOUNTAINS;
             } elseif ($temperature < 0.7) {
                 return Biome::SMALL_MOUNTAINS;
             } else {
                 return Biome::RIVER;
             }
         }
     }, Biome::getBiome(Biome::OCEAN));
     $this->selector->addBiome(Biome::getBiome(Biome::OCEAN));
     $this->selector->addBiome(Biome::getBiome(Biome::PLAINS));
     $this->selector->addBiome(Biome::getBiome(Biome::DESERT));
     $this->selector->addBiome(Biome::getBiome(Biome::MOUNTAINS));
     $this->selector->addBiome(Biome::getBiome(Biome::FOREST));
     $this->selector->addBiome(Biome::getBiome(Biome::TAIGA));
     $this->selector->addBiome(Biome::getBiome(Biome::SWAMP));
     $this->selector->addBiome(Biome::getBiome(Biome::RIVER));
     $this->selector->addBiome(Biome::getBiome(Biome::ICE_PLAINS));
     $this->selector->addBiome(Biome::getBiome(Biome::SMALL_MOUNTAINS));
     $this->selector->addBiome(Biome::getBiome(Biome::BIRCH_FOREST));
     $this->selector->recalculate();
     $cover = new GroundCover();
     $this->generationPopulators[] = $cover;
     $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 Stone(Stone::GRANITE), 20, 32, 0, 128), new OreType(new Stone(Stone::DIORITE), 20, 32, 0, 128), new OreType(new Stone(Stone::ANDESITE), 20, 32, 0, 128), new OreType(new Gravel(), 10, 16, 0, 128)]);
     $this->populators[] = $ores;
 }