mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
Updated light filter values
This commit is contained in:
parent
66ba327e62
commit
3930f379cf
@ -531,6 +531,8 @@ class Block extends Position implements Metadatable{
|
|||||||
/** @var \SplFixedArray */
|
/** @var \SplFixedArray */
|
||||||
public static $light = null;
|
public static $light = null;
|
||||||
/** @var \SplFixedArray */
|
/** @var \SplFixedArray */
|
||||||
|
public static $lightFilter = null;
|
||||||
|
/** @var \SplFixedArray */
|
||||||
public static $solid = null;
|
public static $solid = null;
|
||||||
/** @var \SplFixedArray */
|
/** @var \SplFixedArray */
|
||||||
public static $transparent = null;
|
public static $transparent = null;
|
||||||
@ -562,6 +564,7 @@ class Block extends Position implements Metadatable{
|
|||||||
if(self::$list === null){
|
if(self::$list === null){
|
||||||
self::$list = new \SplFixedArray(256);
|
self::$list = new \SplFixedArray(256);
|
||||||
self::$light = new \SplFixedArray(256);
|
self::$light = new \SplFixedArray(256);
|
||||||
|
self::$lightFilter = new \SplFixedArray(256);
|
||||||
self::$solid = new \SplFixedArray(256);
|
self::$solid = new \SplFixedArray(256);
|
||||||
self::$transparent = new \SplFixedArray(256);
|
self::$transparent = new \SplFixedArray(256);
|
||||||
self::$list[self::AIR] = Air::class;;
|
self::$list[self::AIR] = Air::class;;
|
||||||
@ -712,13 +715,29 @@ class Block extends Position implements Metadatable{
|
|||||||
self::$list[self::GLOWING_OBSIDIAN] = GlowingObsidian::class;
|
self::$list[self::GLOWING_OBSIDIAN] = GlowingObsidian::class;
|
||||||
self::$list[self::NETHER_REACTOR] = NetherReactor::class;
|
self::$list[self::NETHER_REACTOR] = NetherReactor::class;
|
||||||
|
|
||||||
foreach(self::$list as $class){
|
foreach(self::$list as $id => $class){
|
||||||
if($class !== null){
|
if($class !== null){
|
||||||
/** @var Block $block */
|
/** @var Block $block */
|
||||||
$block = new $class();
|
$block = new $class();
|
||||||
self::$solid[$block->getId()] = (bool) $block->isSolid;
|
self::$solid[$id] = (bool) $block->isSolid;
|
||||||
self::$transparent[$block->getId()] = (bool) $block->isTransparent;
|
self::$transparent[$id] = (bool) $block->isTransparent;
|
||||||
self::$light[$block->getId()] = (int) $block->lightLevel;
|
self::$light[$id] = (int) $block->lightLevel;
|
||||||
|
|
||||||
|
if($block->isSolid){
|
||||||
|
if($block->isTransparent){
|
||||||
|
if($block instanceof Liquid or $block instanceof Ice){
|
||||||
|
self::$lightFilter[$id] = 2;
|
||||||
|
}else{
|
||||||
|
self::$lightFilter[$id] = 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
self::$lightFilter[$id] = 15;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
self::$lightFilter[$id] = 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
self::$lightFilter[$id] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,13 +574,13 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$x = $player->x >> 4;
|
$x = $player->x >> 4;
|
||||||
$z = $player->z >> 4;
|
$z = $player->z >> 4;
|
||||||
|
|
||||||
$index = "$x:$z";
|
$index = Level::chunkHash($x, $z);
|
||||||
$existingPlayers = max(0, isset($this->chunkTickList[$index]) ? $this->chunkTickList[$index] : 0);
|
$existingPlayers = max(0, isset($this->chunkTickList[$index]) ? $this->chunkTickList[$index] : 0);
|
||||||
$this->chunkTickList[$index] = $existingPlayers + 1;
|
$this->chunkTickList[$index] = $existingPlayers + 1;
|
||||||
for($chunk = 0; $chunk < $chunksPerPlayer; ++$chunk){
|
for($chunk = 0; $chunk < $chunksPerPlayer; ++$chunk){
|
||||||
$dx = mt_rand(-$randRange, $randRange);
|
$dx = mt_rand(-$randRange, $randRange);
|
||||||
$dz = mt_rand(-$randRange, $randRange);
|
$dz = mt_rand(-$randRange, $randRange);
|
||||||
$hash = ($dx + $x) .":". ($dz + $z);
|
$hash = Level::chunkHash($dx + $x, $dz + $z);
|
||||||
if(!isset($this->chunkTickList[$hash]) and $this->isChunkLoaded($dx + $x, $dz + $z)){
|
if(!isset($this->chunkTickList[$hash]) and $this->isChunkLoaded($dx + $x, $dz + $z)){
|
||||||
$this->chunkTickList[$hash] = -1;
|
$this->chunkTickList[$hash] = -1;
|
||||||
}
|
}
|
||||||
@ -973,9 +973,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
/** @var Vector3 $node */
|
/** @var Vector3 $node */
|
||||||
$node = $lightPropagationQueue->dequeue();
|
$node = $lightPropagationQueue->dequeue();
|
||||||
|
|
||||||
$blockId = $this->getBlockIdAt($node->x, $node->y, $node->z);
|
$lightLevel = $this->getBlockLightAt($node->x, $node->y, $node->z) - (int) Block::$lightFilter[$this->getBlockIdAt($node->x, $node->y, $node->z)];
|
||||||
$decrease = (Block::$solid[$blockId] and !Block::$transparent[$blockId]) ? 15 : 1;
|
|
||||||
$lightLevel = $this->getBlockLightAt($node->x, $node->y, $node->z) - $decrease;
|
|
||||||
|
|
||||||
if($lightLevel >= 1){
|
if($lightLevel >= 1){
|
||||||
$this->computeSpreadBlockLight($node->x - 1, $node->y, $node->z, $lightLevel, $lightPropagationQueue, $visited);
|
$this->computeSpreadBlockLight($node->x - 1, $node->y, $node->z, $lightLevel, $lightPropagationQueue, $visited);
|
||||||
@ -1666,7 +1664,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return Chunk
|
* @return Chunk
|
||||||
*/
|
*/
|
||||||
public function getChunk($x, $z, $create = false){
|
public function getChunk($x, $z, $create = false){
|
||||||
if(isset($this->chunks[$index = "$x:$z"])){
|
if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){
|
||||||
return $this->chunks[$index];
|
return $this->chunks[$index];
|
||||||
}elseif($this->loadChunk($x, $z, $create) and $this->chunks[$index] instanceof FullChunk){
|
}elseif($this->loadChunk($x, $z, $create) and $this->chunks[$index] instanceof FullChunk){
|
||||||
return $this->chunks[$index];
|
return $this->chunks[$index];
|
||||||
@ -1690,7 +1688,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
public function generateChunkCallback($x, $z, FullChunk $chunk){
|
public function generateChunkCallback($x, $z, FullChunk $chunk){
|
||||||
$oldChunk = $this->getChunk($x, $z);
|
$oldChunk = $this->getChunk($x, $z);
|
||||||
unset($this->chunkGenerationQueue["$x:$z"]);
|
unset($this->chunkGenerationQueue[Level::chunkHash($x, $z)]);
|
||||||
$this->setChunk($x, $z, $chunk);
|
$this->setChunk($x, $z, $chunk);
|
||||||
$chunk = $this->getChunk($x, $z);
|
$chunk = $this->getChunk($x, $z);
|
||||||
if($chunk instanceof FullChunk and (!($oldChunk instanceof FullChunk) or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){
|
if($chunk instanceof FullChunk and (!($oldChunk instanceof FullChunk) or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){
|
||||||
@ -1711,7 +1709,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$this->chunks[$index] = $chunk;
|
$this->chunks[$index] = $chunk;
|
||||||
}
|
}
|
||||||
if(ADVANCED_CACHE == true){
|
if(ADVANCED_CACHE == true){
|
||||||
Cache::remove("world:" . $this->getID() . ":$x:$z");
|
Cache::remove("world:" . $this->getID() . ":". Level::chunkHash($x, $z));
|
||||||
}
|
}
|
||||||
$chunk->setChanged();
|
$chunk->setChanged();
|
||||||
}
|
}
|
||||||
@ -1739,7 +1737,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isChunkLoaded($x, $z){
|
public function isChunkLoaded($x, $z){
|
||||||
return isset($this->chunks["$x:$z"]) or $this->provider->isChunkLoaded($x, $z);
|
return isset($this->chunks[Level::chunkHash($x, $z)]) or $this->provider->isChunkLoaded($x, $z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2159,8 +2157,8 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
|
|
||||||
public function generateChunk($x, $z){
|
public function generateChunk($x, $z){
|
||||||
if(!isset($this->chunkGenerationQueue["$x:$z"])){
|
if(!isset($this->chunkGenerationQueue[Level::chunkHash($x, $z)])){
|
||||||
$this->chunkGenerationQueue["$x:$z"] = true;
|
$this->chunkGenerationQueue[Level::chunkHash($x, $z)] = true;
|
||||||
$this->server->getGenerationManager()->requestChunk($this, $x, $z);
|
$this->server->getGenerationManager()->requestChunk($this, $x, $z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user