Disable random ticking for some blocks depending on their states

we don't need to waste CPU time attempting to tick fully grown crops.
This commit is contained in:
Dylan K. Taylor 2023-09-29 12:45:37 +01:00
parent ca69f08da0
commit 390cc3060a
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
8 changed files with 11 additions and 11 deletions

View File

@ -99,7 +99,7 @@ class CocoaBlock extends Transparent{
}
public function ticksRandomly() : bool{
return true;
return $this->age < self::MAX_AGE;
}
public function onRandomTick() : void{

View File

@ -62,7 +62,7 @@ abstract class Crops extends Flowable{
}
public function ticksRandomly() : bool{
return true;
return $this->age < self::MAX_AGE;
}
public function onRandomTick() : void{

View File

@ -97,7 +97,7 @@ final class DoublePitcherCrop extends DoublePlant{
}
public function ticksRandomly() : bool{
return true;
return $this->age < self::MAX_AGE && !$this->top;
}
public function onRandomTick() : void{

View File

@ -110,7 +110,7 @@ class Leaves extends Transparent{
}
public function ticksRandomly() : bool{
return true;
return !$this->noDecay && $this->checkDecay;
}
public function onRandomTick() : void{

View File

@ -59,10 +59,6 @@ class NetherVines extends Flowable{
return true;
}
public function ticksRandomly() : bool{
return true;
}
public function canClimb() : bool{
return true;
}
@ -98,6 +94,10 @@ class NetherVines extends Flowable{
return false;
}
public function ticksRandomly() : bool{
return $this->age < self::MAX_AGE;
}
public function onRandomTick() : void{
if(mt_rand(1, 10) === 1 && $this->age < self::MAX_AGE){
if($this->getSide($this->growthFace)->canBeReplaced()){

View File

@ -42,7 +42,7 @@ class NetherWartPlant extends Flowable{
}
public function ticksRandomly() : bool{
return true;
return $this->age < self::MAX_AGE;
}
public function onRandomTick() : void{

View File

@ -70,7 +70,7 @@ class RedstoneOre extends Opaque{
}
public function ticksRandomly() : bool{
return true;
return $this->lit;
}
public function onRandomTick() : void{

View File

@ -102,7 +102,7 @@ class SweetBerryBush extends Flowable{
}
public function ticksRandomly() : bool{
return true;
return $this->age < self::STAGE_MATURE;
}
public function onRandomTick() : void{