PocketMine's SubChunkIteratorManager class can help cut down on many method calls. I used it on a decent system in the following picture That's 15.2 million blocks in almost a minute! P.S. There's no asynchronous-magic involved. Also P.S, Compared to XenialDan's MagicWE and MagicWE2, SubChunkIteratorManager is capable of performing way too fast. That very area takes more than 20 minutes for MagicWE. Why is it soo fast? It cuts down on block updates, updating cached blocks in Level class, notifying ChunkLoaders about block changes and much more. It's about executing just the required code in an expensive loop. Code: //Level->setBlock() for(loop 15 million blocks){ setBlockInChunk(block); checkNearbyBlocks(block); scheduleBlockUpdates(block); updateCachedBlocks(); foreach(players in chunk as player){ sendBlockUpdateTo(player) } } //Using SubChunkIteratorManager for(loop 15 million blocks){ setBlockInChunk(block); } updateCachedBlocks(); foreach(changedChunks as chunk){ foreach(players in chunk as player){ sendBlockUpdateTo(player); } }
All the players in the chunk (and also the players who can see the chunk) are sent UpdateBlockPacket which sends them the block graphic. It's an example code of things that Level->setBlock() executes vs. things that SubChunkIteratorManager executes. I'm working on a public WorldEdit plugin that uses PocketMine's SubChunkIteratorManager class.
where did you get the sendBlockUpdate? PHP: for($i =0; $i <= 15000000; $i++){ } how do you get players in chunk?
"Players in chunk" is not accurate. It should be "players using chunk", i.e. players who will receive changes in that chunk. For example, players very far away or players from another world will not see the chunk.