mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Made block and item factory lists private to stop people doing stupid things with them
This commit is contained in:
@ -272,7 +272,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(Server $server, string $name, string $path, string $provider){
|
||||
$this->blockStates = BlockFactory::$fullList;
|
||||
$this->blockStates = BlockFactory::getBlockStatesArray();
|
||||
$this->levelId = static::$levelIdCounter++;
|
||||
$this->blockMetadata = new BlockMetadataStore($this);
|
||||
$this->server = $server;
|
||||
@ -304,19 +304,12 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", true);
|
||||
$this->cacheChunks = (bool) $this->server->getProperty("chunk-sending.cache-chunks", false);
|
||||
|
||||
$this->randomTickBlocks = \SplFixedArray::fromArray(array_filter(BlockFactory::$list->toArray(), function(Block $block = null){
|
||||
return $block !== null and $block->ticksRandomly();
|
||||
}));
|
||||
$this->randomTickBlocks->setSize(256);
|
||||
|
||||
$dontTickBlocks = $this->server->getProperty("chunk-ticking.disable-block-ticking", []);
|
||||
foreach($dontTickBlocks as $id){
|
||||
try{
|
||||
if(isset($this->randomTickBlocks[$id])){
|
||||
$this->randomTickBlocks[$id] = null;
|
||||
}
|
||||
}catch(\RuntimeException $e){
|
||||
//index out of bounds
|
||||
$this->randomTickBlocks = new \SplFixedArray(256);
|
||||
foreach($this->randomTickBlocks as $id => $null){
|
||||
$block = BlockFactory::get($id); //Make sure it's a copy
|
||||
if(!isset($dontTickBlocks[$id]) and $block->ticksRandomly()){
|
||||
$this->randomTickBlocks[$id] = $block;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user