mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Crops: micro optimization - check age before generating random number (faster)
I don't have any idea how much benefit this will provide in real terms, but it may be significant.
This commit is contained in:
parent
a195e940db
commit
9651b3f470
@ -92,8 +92,7 @@ abstract class Crops extends Flowable{
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
if(mt_rand(0, 2) === 1){
|
||||
if($this->age < 7){
|
||||
if($this->age < 7 and mt_rand(0, 2) === 1){
|
||||
$block = clone $this;
|
||||
++$block->age;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
@ -103,7 +102,6 @@ abstract class Crops extends Flowable{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user