33 public function __construct(
38 public function getType() :
OreType{
42 public function canPlaceObject(
ChunkManager $world,
int $x,
int $y,
int $z) :
bool{
43 return $world->
getBlockAt($x, $y, $z)->hasSameTypeId($this->type->replaces);
46 public function placeObject(
ChunkManager $world,
int $x,
int $y,
int $z) :
void{
47 $clusterSize = $this->type->clusterSize;
48 $angle = $this->random->nextFloat() * M_PI;
49 $offset = VectorMath::getDirection2D($angle)->multiply($clusterSize / 8);
50 $x1 = $x + 8 + $offset->x;
51 $x2 = $x + 8 - $offset->x;
52 $z1 = $z + 8 + $offset->y;
53 $z2 = $z + 8 - $offset->y;
54 $y1 = $y + $this->random->nextBoundedInt(3) + 2;
55 $y2 = $y + $this->random->nextBoundedInt(3) + 2;
56 for($count = 0; $count <= $clusterSize; ++$count){
57 $seedX = $x1 + ($x2 - $x1) * $count / $clusterSize;
58 $seedY = $y1 + ($y2 - $y1) * $count / $clusterSize;
59 $seedZ = $z1 + ($z2 - $z1) * $count / $clusterSize;
60 $size = ((sin($count * (M_PI / $clusterSize)) + 1) * $this->random->nextFloat() * $clusterSize / 16 + 1) / 2;
62 $startX = (int) ($seedX - $size);
63 $startY = (int) ($seedY - $size);
64 $startZ = (int) ($seedZ - $size);
65 $endX = (int) ($seedX + $size);
66 $endY = (int) ($seedY + $size);
67 $endZ = (int) ($seedZ + $size);
69 for($xx = $startX; $xx <= $endX; ++$xx){
70 $sizeX = ($xx + 0.5 - $seedX) / $size;
74 for($yy = $startY; $yy <= $endY; ++$yy){
75 $sizeY = ($yy + 0.5 - $seedY) / $size;
78 if($yy > 0 && ($sizeX + $sizeY) < 1){
79 for($zz = $startZ; $zz <= $endZ; ++$zz){
80 $sizeZ = ($zz + 0.5 - $seedZ) / $size;
83 if(($sizeX + $sizeY + $sizeZ) < 1 && $world->
getBlockAt($xx, $yy, $zz)->hasSameTypeId($this->type->replaces)){
84 $world->
setBlockAt($xx, $yy, $zz, $this->type->material);