mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 00:09:39 +00:00
Rename Chunk::getWritableSubChunk() -> Chunk::getSubChunkChecked()
this is not specific to 'writable', it's just an opt-in to checked bounds so that an EmptySubChunk will never be received.
This commit is contained in:
parent
5701e733cc
commit
b270029161
@ -152,7 +152,7 @@ class Chunk{
|
||||
* Sets the blockstate at the given coordinate by internal ID.
|
||||
*/
|
||||
public function setFullBlock(int $x, int $y, int $z, int $block) : void{
|
||||
$this->getWritableSubChunk($y >> 4)->setFullBlock($x, $y & 0xf, $z, $block);
|
||||
$this->getSubChunkChecked($y >> 4)->setFullBlock($x, $y & 0xf, $z, $block);
|
||||
$this->dirtyFlags |= self::DIRTY_FLAG_TERRAIN;
|
||||
}
|
||||
|
||||
@ -516,9 +516,9 @@ class Chunk{
|
||||
return $this->subChunks[$y];
|
||||
}
|
||||
|
||||
public function getWritableSubChunk(int $y) : SubChunk{
|
||||
public function getSubChunkChecked(int $y) : SubChunk{
|
||||
if($y < 0 || $y >= $this->subChunks->getSize()){
|
||||
throw new \InvalidArgumentException("Cannot get subchunk $y for writing");
|
||||
throw new \InvalidArgumentException("Invalid subchunk Y coordinate $y");
|
||||
}
|
||||
return $this->subChunks[$y];
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ class Flat extends Generator{
|
||||
|
||||
$count = count($this->structure);
|
||||
for($sy = 0; $sy < $count; $sy += 16){
|
||||
$subchunk = $this->chunk->getWritableSubChunk($sy >> 4);
|
||||
$subchunk = $this->chunk->getSubChunkChecked($sy >> 4);
|
||||
for($y = 0; $y < 16 and isset($this->structure[$y | $sy]); ++$y){
|
||||
$id = $this->structure[$y | $sy];
|
||||
|
||||
|
@ -104,10 +104,10 @@ class LightPopulationTask extends AsyncTask{
|
||||
$blockLightArrays = igbinary_unserialize($this->resultBlockLightArrays);
|
||||
|
||||
foreach($skyLightArrays as $y => $array){
|
||||
$chunk->getWritableSubChunk($y)->setBlockSkyLightArray($array);
|
||||
$chunk->getSubChunkChecked($y)->setBlockSkyLightArray($array);
|
||||
}
|
||||
foreach($blockLightArrays as $y => $array){
|
||||
$chunk->getWritableSubChunk($y)->setBlockLightArray($array);
|
||||
$chunk->getSubChunkChecked($y)->setBlockLightArray($array);
|
||||
}
|
||||
$chunk->setLightPopulated();
|
||||
}
|
||||
|
@ -111,10 +111,10 @@ class SkyLightUpdate extends LightUpdate{
|
||||
$lowestClearSubChunk = ($highestHeightMapPlusOne >> 4) + (($highestHeightMapPlusOne & 0xf) !== 0 ? 1 : 0);
|
||||
$chunkHeight = $chunk->getSubChunks()->count();
|
||||
for($y = 0; $y < $lowestClearSubChunk && $y < $chunkHeight; $y++){
|
||||
$chunk->getWritableSubChunk($y)->setBlockSkyLightArray(LightArray::fill(0));
|
||||
$chunk->getSubChunkChecked($y)->setBlockSkyLightArray(LightArray::fill(0));
|
||||
}
|
||||
for($y = $lowestClearSubChunk, $yMax = $chunkHeight; $y < $yMax; $y++){
|
||||
$chunk->getWritableSubChunk($y)->setBlockSkyLightArray(LightArray::fill(15));
|
||||
$chunk->getSubChunkChecked($y)->setBlockSkyLightArray(LightArray::fill(15));
|
||||
}
|
||||
|
||||
$lightSources = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user