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

Public Member Functions

 __construct ($seed, $waterHeight=0)
 
 getWaterHeight ()
 
 getBlockIdAt (int $x, int $y, int $z)
 
 setBlockIdAt (int $x, int $y, int $z, int $id)
 
 getBlockDataAt (int $x, int $y, int $z)
 
 setBlockDataAt (int $x, int $y, int $z, int $data)
 
 getBlockLightAt (int $x, int $y, int $z)
 
 setBlockLightAt (int $x, int $y, int $z, int $level)
 
 getChunk (int $chunkX, int $chunkZ)
 
 setChunk (int $chunkX, int $chunkZ, Chunk $chunk=null)
 
 cleanChunks ()
 
 getSeed ()
 
- Public Member Functions inherited from ChunkManager
 updateBlockLight (int $x, int $y, int $z)
 

Protected Attributes

 $chunks = []
 
 $seed
 
 $waterHeight = 0
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $seed,
  $waterHeight = 0 
)

SimpleChunkManager constructor.

Parameters
$seed
int$waterHeight
44  {
45  $this->seed = $seed;
46  $this->waterHeight = $waterHeight;
47  }

Member Function Documentation

◆ cleanChunks()

cleanChunks ( )
281  {
282  $this->chunks = [];
283  }

◆ getBlockDataAt()

getBlockDataAt ( int  $x,
int  $y,
int  $z 
)

Gets the raw block metadata

Parameters
int$x
int$y
int$z
Returns
int 0-15

Implements ChunkManager.

95  : int{
96  if($chunk = $this->getChunk($x >> 4, $z >> 4)){
97  return $chunk->getBlockData($x & 0xf, $y & Level::Y_MASK, $z & 0xf);
98  }
99  return 0;
100  }

◆ getBlockIdAt()

getBlockIdAt ( int  $x,
int  $y,
int  $z 
)

Gets the raw block id.

Parameters
int$x
int$y
int$z
Returns
int 0-255

Implements ChunkManager.

65  : int{
66  if($chunk = $this->getChunk($x >> 4, $z >> 4)){
67  return $chunk->getBlockId($x & 0xf, $y & Level::Y_MASK, $z & 0xf);
68  }
69  return 0;
70  }

◆ getBlockLightAt()

getBlockLightAt ( int  $x,
int  $y,
int  $z 
)

Gets the raw block light level

Parameters
int$x
int$y
int$z
Returns
int 0-15

Implements ChunkManager.

125  : int{
126  if($chunk = $this->getChunk($x >> 4, $z >> 4)){
127  return $chunk->getBlockLight($x & 0x0f, $y & 0x7f, $z & 0x0f);
128  }
129  return 0;
130  }

◆ getChunk()

getChunk ( int  $chunkX,
int  $chunkZ 
)
Parameters
int$chunkX
int$chunkZ
Returns
Chunk|null

Implements ChunkManager.

264  {
265  return isset($this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunks[$index] : null;
266  }

◆ getSeed()

getSeed ( )

Gets the level seed

Returns
int|string

Implements ChunkManager.

290  {
291  return $this->seed;
292  }

◆ getWaterHeight()

getWaterHeight ( )
Returns
int
52  : int{
53  return $this->waterHeight;
54  }

◆ setBlockDataAt()

setBlockDataAt ( int  $x,
int  $y,
int  $z,
int  $data 
)

Sets the raw block metadata.

Parameters
int$x
int$y
int$z
int$data0-15

Implements ChunkManager.

110  {
111  if($chunk = $this->getChunk($x >> 4, $z >> 4)){
112  $chunk->setBlockData($x & 0xf, $y & Level::Y_MASK, $z & 0xf, $data);
113  }
114  }

◆ setBlockIdAt()

setBlockIdAt ( int  $x,
int  $y,
int  $z,
int  $id 
)

Sets the raw block id.

Parameters
int$x
int$y
int$z
int$id0-255

Implements ChunkManager.

80  {
81  if($chunk = $this->getChunk($x >> 4, $z >> 4)){
82  $chunk->setBlockId($x & 0xf, $y & Level::Y_MASK, $z & 0xf, $id);
83  }
84  }

◆ setBlockLightAt()

setBlockLightAt ( int  $x,
int  $y,
int  $z,
int  $level 
)

Sets the raw block light level.

Parameters
int$x
int$y
int$z
int$level0-15

Implements ChunkManager.

140  {
141  if($chunk = $this->getChunk($x >> 4, $z >> 4)){
142  $chunk->setBlockLight($x & 0x0f, $y & 0x7f, $z & 0x0f, $level & 0x0f);
143  }
144  }

◆ setChunk()

setChunk ( int  $chunkX,
int  $chunkZ,
Chunk  $chunk = null 
)
Parameters
int$chunkX
int$chunkZ
Chunk$chunk

Implements ChunkManager.

273  {
274  if($chunk === null){
275  unset($this->chunks[Level::chunkHash($chunkX, $chunkZ)]);
276  return;
277  }
278  $this->chunks[Level::chunkHash($chunkX, $chunkZ)] = $chunk;
279  }

Field Documentation

◆ $chunks

$chunks = []
protected

◆ $seed

$seed
protected

◆ $waterHeight

$waterHeight = 0
protected

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