GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
Ore 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 
)

Ore 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) === 1) or ($level->getBlockIdAt($x, $y, $z) === 87));
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  for($count = 0; $count <= $clusterSize; ++$count){
79  $seedX = $x1 + ($x2 - $x1) * $count / $clusterSize;
80  $seedY = $y1 + ($y2 - $y1) * $count / $clusterSize;
81  $seedZ = $z1 + ($z2 - $z1) * $count / $clusterSize;
82  $size = ((sin($count * (M_PI / $clusterSize)) + 1) * $this->random->nextFloat() * $clusterSize / 16 + 1) / 2;
83 
84  $startX = (int) ($seedX - $size);
85  $startY = (int) ($seedY - $size);
86  $startZ = (int) ($seedZ - $size);
87  $endX = (int) ($seedX + $size);
88  $endY = (int) ($seedY + $size);
89  $endZ = (int) ($seedZ + $size);
90 
91  for($x = $startX; $x <= $endX; ++$x){
92  $sizeX = ($x + 0.5 - $seedX) / $size;
93  $sizeX *= $sizeX;
94 
95  if($sizeX < 1){
96  for($y = $startY; $y <= $endY; ++$y){
97  $sizeY = ($y + 0.5 - $seedY) / $size;
98  $sizeY *= $sizeY;
99 
100  if($y > 0 and ($sizeX + $sizeY) < 1){
101  for($z = $startZ; $z <= $endZ; ++$z){
102  $sizeZ = ($z + 0.5 - $seedZ) / $size;
103  $sizeZ *= $sizeZ;
104 
105  if(($sizeX + $sizeY + $sizeZ) < 1 and (($level->getBlockIdAt($x, $y, $z) === 1) or ($level->getBlockIdAt($x, $y, $z) === 87))){
106  $level->setBlockIdAt($x, $y, $z, $this->type->material->getId());
107  if($this->type->material->getDamage() !== 0){
108  $level->setBlockDataAt($x, $y, $z, $this->type->material->getDamage());
109  }
110  }
111  }
112  }
113  }
114  }
115  }
116  }
117  }

Field Documentation

◆ $type

$type

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