mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Level: Optimize blockticking coordinate selection
generating 1 large bounded random costs the same as generating 4 small ones, so it makes more sense to do it like this instead. Note that prior to 7.1 this code would not work due to it not handling 64-bit appropriately.
This commit is contained in:
parent
5bf7350ee5
commit
c66dc7b273
@ -1089,11 +1089,12 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
foreach($chunk->getSubChunks() as $Y => $subChunk){
|
||||
if(!($subChunk instanceof EmptySubChunk)){
|
||||
$k = mt_rand(0, 0xfffffffff); //36 bits
|
||||
for($i = 0; $i < 3; ++$i){
|
||||
$k = mt_rand(0, 0xfff);
|
||||
$x = $k & 0x0f;
|
||||
$y = ($k >> 4) & 0x0f;
|
||||
$z = ($k >> 8) & 0x0f;
|
||||
$k >>= 12;
|
||||
|
||||
$blockId = $subChunk->getBlockId($x, $y, $z);
|
||||
if($this->randomTickBlocks[$blockId] !== null){
|
||||
|
Loading…
x
Reference in New Issue
Block a user