mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-16 16:34:05 +00:00
Fix random block ticking losing randomness on third iteration
More expensive to do it this way, but this should be foolproof. The old method ran short by 4 or 5 bits, causing the Y coordinate of the third loop to be always < 8 and the Z coordinate to always be 0.
This commit is contained in:
parent
1b0ed0f1b8
commit
6553c82320
@ -968,11 +968,11 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
foreach($chunk->getSubChunks() as $Y => $subChunk){
|
foreach($chunk->getSubChunks() as $Y => $subChunk){
|
||||||
if(!$subChunk->isEmpty()){
|
if(!$subChunk->isEmpty()){
|
||||||
$k = mt_rand(0, 0x7fffffff);
|
for($i = 0; $i < 3; ++$i){
|
||||||
for($i = 0; $i < 3; ++$i, $k >>= 10){
|
$k = mt_rand(0, 0xfff);
|
||||||
$x = $k & 0x0f;
|
$x = $k & 0x0f;
|
||||||
$y = ($k >> 8) & 0x0f;
|
$y = ($k >> 4) & 0x0f;
|
||||||
$z = ($k >> 16) & 0x0f;
|
$z = ($k >> 8) & 0x0f;
|
||||||
|
|
||||||
$blockId = $subChunk->getBlockId($x, $y, $z);
|
$blockId = $subChunk->getBlockId($x, $y, $z);
|
||||||
if(isset($this->randomTickBlocks[$blockId])){
|
if(isset($this->randomTickBlocks[$blockId])){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user