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

Public Member Functions

 __construct (ChunkManager $level, Vector3 $chunk, Vector3 $start, Vector3 $end, Vector3 $target, $verticalSize, $horizontalSize)
 
 canPlace ()
 
 place ()
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( ChunkManager  $level,
Vector3  $chunk,
Vector3  $start,
Vector3  $end,
Vector3  $target,
  $verticalSize,
  $horizontalSize 
)

CaveNode constructor.

Parameters
ChunkManager$level
Vector3$chunk
Vector3$start
Vector3$end
Vector3$target
$verticalSize
$horizontalSize
232  {
233  $this->level = $level;
234  $this->chunk = $chunk;
235  $this->start = $this->clamp($start);
236  $this->end = $this->clamp($end);
237  $this->target = $target;
238  $this->verticalSize = $verticalSize;
239  $this->horizontalSize = $horizontalSize;
240  }

Member Function Documentation

◆ canPlace()

canPlace ( )
Returns
bool
258  {
259  for($x = $this->start->getFloorX(); $x < $this->end->getFloorX(); $x++){
260  for($z = $this->start->getFloorZ(); $z < $this->end->getFloorZ(); $z++){
261  for($y = $this->end->getFloorY() + 1; $y >= $this->start->getFloorY() - 1; $y--){
262  $blockId = $this->level->getBlockIdAt($this->chunk->getX() + $x, $y, $this->chunk->getZ() + $z);
263  if($blockId == Block::WATER or $blockId == Block::STILL_WATER){
264  return false;
265  }
266  if($y != ($this->start->getFloorY() - 1) and $x != ($this->start->getFloorX()) and $x != ($this->end->getFloorX() - 1) and $z != ($this->start->getFloorZ()) and $z != ($this->end->getFloorZ() - 1)){
267  $y = $this->start->getFloorY();
268  }
269  }
270  }
271  }
272  return true;
273  }

◆ place()

place ( )
275  {
276  for($x = $this->start->getFloorX(); $x < $this->end->getFloorX(); $x++){
277  $xOffset = ($this->chunk->getX() + $x + 0.5 - $this->target->getX()) / $this->horizontalSize;
278  for($z = $this->start->getFloorZ(); $z < $this->end->getFloorZ(); $z++){
279  $zOffset = ($this->chunk->getZ() + $z + 0.5 - $this->target->getZ()) / $this->horizontalSize;
280  if(($xOffset * $xOffset + $zOffset * $zOffset) >= 1){
281  continue;
282  }
283  for($y = $this->end->getFloorY() - 1; $y >= $this->start->getFloorY(); $y--){
284  $yOffset = ($y + 0.5 - $this->target->getY()) / $this->verticalSize;
285  if($yOffset > -0.7 and ($xOffset * $xOffset + $yOffset * $yOffset + $zOffset * $zOffset) < 1){
286  $xx = $this->chunk->getX() + $x;
287  $zz = $this->chunk->getZ() + $z;
288  $blockId = $this->level->getBlockIdAt($xx, $y, $zz);
289  if($blockId == Block::STONE or $blockId == Block::DIRT or $blockId == Block::GRASS){
290  if($y < 10){
291  $this->level->setBlockIdAt($xx, $y, $zz, Block::STILL_LAVA);
292  }else{
293  if($blockId == Block::GRASS and $this->level->getBlockIdAt($xx, $y - 1, $zz) == Block::DIRT){
294  $this->level->setBlockIdAt($xx, $y - 1, $zz, Block::GRASS);
295  }
296  $this->level->setBlockIdAt($xx, $y, $zz, Block::AIR);
297  }
298  }
299  }
300  }
301  }
302  }
303  }

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