mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Updated Levels :D
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
|
||||
namespace pocketmine\level\generator\object;
|
||||
|
||||
use pocketmine\level\ChunkManager;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3 as Vector3;
|
||||
use pocketmine\math\VectorMath;
|
||||
@ -39,20 +40,20 @@ class Ore{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function canPlaceObject(Level $level, $x, $y, $z){
|
||||
return ($level->level->getBlockID($x, $y, $z) === 1);
|
||||
public function canPlaceObject(ChunkManager $level, $x, $y, $z){
|
||||
return ($level->getBlockIdAt($x, $y, $z) === 1);
|
||||
}
|
||||
|
||||
public function placeObject(Level $level, Vector3 $pos){
|
||||
public function placeObject(ChunkManager $level, $x, $y, $z){
|
||||
$clusterSize = (int) $this->type->clusterSize;
|
||||
$angle = $this->random->nextFloat() * M_PI;
|
||||
$offset = 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;
|
||||
$z2 = $pos->z + 8 - $offset->y;
|
||||
$y1 = $pos->y + $this->random->nextRange(0, 3) + 2;
|
||||
$y2 = $pos->y + $this->random->nextRange(0, 3) + 2;
|
||||
$x1 = $x + 8 + $offset->x;
|
||||
$x2 = $x + 8 - $offset->x;
|
||||
$z1 = $z + 8 + $offset->y;
|
||||
$z2 = $z + 8 - $offset->y;
|
||||
$y1 = $y + $this->random->nextRange(0, 3) + 2;
|
||||
$y2 = $y + $this->random->nextRange(0, 3) + 2;
|
||||
for($count = 0; $count <= $clusterSize; ++$count){
|
||||
$seedX = $x1 + ($x2 - $x1) * $count / $clusterSize;
|
||||
$seedY = $y1 + ($y2 - $y1) * $count / $clusterSize;
|
||||
@ -80,8 +81,8 @@ class Ore{
|
||||
$sizeZ = ($z + 0.5 - $seedZ) / $size;
|
||||
$sizeZ *= $sizeZ;
|
||||
|
||||
if(($sizeX + $sizeY + $sizeZ) < 1 and $level->level->getBlockID($x, $y, $z) === 1){
|
||||
$level->setBlockRaw(new Vector3($x, $y, $z), $this->type->material);
|
||||
if(($sizeX + $sizeY + $sizeZ) < 1 and $level->getBlockIdAt($x, $y, $z) === 1){
|
||||
$level->setBlockIdAt($x, $y, $z, $this->type->material);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user