GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
NetherOreTop Class Reference

Public Member Functions

 __construct (Random $random, OreType $type)
 
 getType ()
 
 canPlaceObject (ChunkManager $level, $x, $y, $z)
 
 placeObject (ChunkManager $level, $x, $y, $z)
 

Data Fields

 $type
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Random  $random,
OreType  $type 
)

NetherOreTop constructor.

Parameters
Random$random
OreType$type
38  {
39  $this->type = $type;
40  $this->random = $random;
41  }

Member Function Documentation

◆ canPlaceObject()

canPlaceObject ( ChunkManager  $level,
  $x,
  $y,
  $z 
)
Parameters
ChunkManager$level
$x
$y
$z
Returns
bool
58  {
59  return ($level->getBlockIdAt($x, $y, $z) === 0);
60  }

◆ getType()

getType ( )
Returns
OreType
46  {
47  return $this->type;
48  }

◆ placeObject()

placeObject ( ChunkManager  $level,
  $x,
  $y,
  $z 
)
Parameters
ChunkManager$level
$x
$y
$z
68  {
69  $clusterSize = (int) $this->type->clusterSize;
70  $angle = $this->random->nextFloat() * M_PI;
71  $offset = VectorMath::getDirection2D($angle)->multiply($clusterSize)->divide(8);
72  $x1 = $x + 8 + $offset->x;
73  $x2 = $x + 8 - $offset->x;
74  $z1 = $z + 8 + $offset->y;
75  $z2 = $z + 8 - $offset->y;
76  $y1 = $y + $this->random->nextBoundedInt(3) + 2;
77  $y2 = $y + $this->random->nextBoundedInt(3) + 2;
78 
79  for($count = 0; $count <= $clusterSize; ++$count){
80  $seedX = $x1 + ($x2 - $x1) * $count / $clusterSize;
81  $seedY = $y1 + ($y2 - $y1) * $count / $clusterSize;
82  $seedZ = $z1 + ($z2 - $z1) * $count / $clusterSize;
83  $size = ((sin($count * (M_PI / $clusterSize)) + 1) * $this->random->nextFloat() * $clusterSize / 16 + 1) / 2;
84 
85  $startX = (int) ($seedX - $size);
86  $startY = (int) ($seedY - $size);
87  $startZ = (int) ($seedZ - $size);
88  $endX = (int) ($seedX + $size);
89  $endY = (int) ($seedY + $size);
90  $endZ = (int) ($seedZ + $size);
91  //echo "ORE: $startX, $startY, $startZ,, $endX, $endY, $endZ\n";
92  for($x = $startX; $x <= $endX; ++$x){
93  $sizeX = ($x + 0.5 - $seedX) / $size;
94  $sizeX *= $sizeX;
95 
96  if($sizeX < 1){
97  for($y = $startY; $y <= $endY; ++$y){
98  $sizeY = ($y + 0.5 - $seedY) / $size;
99  $sizeY *= $sizeY;
100 
101  if($y > 0 and ($sizeX + $sizeY) < 1){
102  for($z = $startZ; $z <= $endZ; ++$z){
103  $sizeZ = ($z + 0.5 - $seedZ) / $size;
104  $sizeZ *= $sizeZ;
105 
106  if(($sizeX + $sizeY + $sizeZ) < 1 and $level->getBlockIdAt($x, $y, $z) === 0){
107  $level->setBlockIdAt($x, $y, $z, $this->type->material->getId());
108  if($this->type->material->getDamage() !== 0){
109  $level->setBlockDataAt($x, $y, $z, $this->type->material->getDamage());
110  }
111  $level->updateBlockLight($x, $y, $z);
112  //echo "Placed to $x, $y, $z\n";
113  }
114  }
115  }
116  }
117  }
118  }
119  }
120  }

Field Documentation

◆ $type

$type

The documentation for this class was generated from the following file: