mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Added Ores to objects
This commit is contained in:
parent
eeb8244f26
commit
c9c6d5a5f4
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
namespace PocketMine\Level\Generator;
|
||||
use PocketMine\Level;
|
||||
use PocketMine;
|
||||
|
||||
class Flat extends Generator{
|
||||
@ -122,7 +121,7 @@ class Flat extends Generator{
|
||||
}
|
||||
}
|
||||
|
||||
public function init(Level $level, Random $random){
|
||||
public function init(Level\Level $level, Utils\Random $random){
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
namespace PocketMine\Level\Generator;
|
||||
use PocketMine\Level;
|
||||
use PocketMine;
|
||||
|
||||
abstract class Generator{
|
||||
@ -43,7 +42,7 @@ abstract class Generator{
|
||||
|
||||
public abstract function __construct(array $settings = array());
|
||||
|
||||
public abstract function init(Level $level, Random $random);
|
||||
public abstract function init(Level\Level $level, Utils\Random $random);
|
||||
|
||||
public abstract function generateChunk($chunkX, $chunkZ);
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
namespace PocketMine\Level\Generator;
|
||||
use PocketMine\Level;
|
||||
use PocketMine;
|
||||
|
||||
class Normal extends Generator{
|
||||
@ -47,7 +46,7 @@ class Normal extends Generator{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function init(Level $level, Random $random){
|
||||
public function init(Level\Level $level, Utils\Random $random){
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
$this->random->setSeed($this->level->getSeed());
|
||||
@ -57,16 +56,16 @@ class Normal extends Generator{
|
||||
$this->noiseBase = new Noise\Simplex($this->random, 16);
|
||||
|
||||
|
||||
$ores = new OrePopulator();
|
||||
$ores = new Populator\Ore();
|
||||
$ores->setOreTypes(array(
|
||||
new Object\Ore\Type(new Block\CoalOre(), 20, 16, 0, 128),
|
||||
new Object\Ore\Type(New Block\IronOre(), 20, 8, 0, 64),
|
||||
new Object\Ore\Type(new Block\RedstoneOre(), 8, 7, 0, 16),
|
||||
new Object\Ore\Type(new Block\LapisOre(), 1, 6, 0, 32),
|
||||
new Object\Ore\Type(new Block\GoldOre(), 2, 8, 0, 32),
|
||||
new Object\Ore\Type(new Block\DiamondOre(), 1, 7, 0, 16),
|
||||
new Object\Ore\Type(new Block\Dirt(), 20, 32, 0, 128),
|
||||
new Object\Ore\Type(new Block\Gravel(), 10, 16, 0, 128),
|
||||
new Object\OreType(new Block\CoalOre(), 20, 16, 0, 128),
|
||||
new Object\OreType(New Block\IronOre(), 20, 8, 0, 64),
|
||||
new Object\OreType(new Block\RedstoneOre(), 8, 7, 0, 16),
|
||||
new Object\OreType(new Block\LapisOre(), 1, 6, 0, 32),
|
||||
new Object\OreType(new Block\GoldOre(), 2, 8, 0, 32),
|
||||
new Object\OreType(new Block\DiamondOre(), 1, 7, 0, 16),
|
||||
new Object\OreType(new Block\Dirt(), 20, 32, 0, 128),
|
||||
new Object\OreType(new Block\Gravel(), 10, 16, 0, 128),
|
||||
));
|
||||
$this->populators[] = $ores;
|
||||
|
||||
|
@ -19,11 +19,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class OreObject{
|
||||
namespace PocketMine\Level\Generator\Object;
|
||||
use PocketMine;
|
||||
|
||||
class Ore{
|
||||
private $random;
|
||||
public $type;
|
||||
|
||||
public function __construct(Random $random, OreType $type){
|
||||
public function __construct(Utils\Random $random, OreType $type){
|
||||
$this->type = $type;
|
||||
$this->random = $random;
|
||||
}
|
||||
@ -32,14 +35,14 @@ class OreObject{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function canPlaceObject(Level $level, $x, $y, $z){
|
||||
public function canPlaceObject(Level\Level $level, $x, $y, $z){
|
||||
return ($level->level->getBlockID($x, $y, $z) != AIR);
|
||||
}
|
||||
|
||||
public function placeObject(Level $level, Math\Vector3 $pos){
|
||||
public function placeObject(Level\Level $level, Math\Vector3 $pos){
|
||||
$clusterSize = (int) $this->type->clusterSize;
|
||||
$angle = $this->random->nextFloat() * M_PI;
|
||||
$offset = VectorMath::getDirection2D($angle)->multiply($clusterSize)->divide(8);
|
||||
$offset = Math\VectorMath::getDirection2D($angle)->multiply($clusterSize)->divide(8);
|
||||
$x1 = $pos->x + 8 + $offset->x;
|
||||
$x2 = $pos->x + 8 - $offset->x;
|
||||
$z1 = $pos->z + 8 + $offset->y;
|
@ -19,10 +19,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace PocketMine\Level\Generator\Object;
|
||||
use PocketMine;
|
||||
|
||||
class OreType{
|
||||
public $material, $clusterCount, $clusterSize, $maxHeight, $minHeight;
|
||||
|
||||
public function __construct(Block $material, $clusterCount, $clusterSize, $minHeight, $maxHeight){
|
||||
public function __construct(Block\Block $material, $clusterCount, $clusterSize, $minHeight, $maxHeight){
|
||||
$this->material = $material;
|
||||
$this->clusterCount = (int) $clusterCount;
|
||||
$this->clusterSize = (int) $clusterSize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user