AgeableTrait: fixed incorrect number of bits

the original method breaks if MAX_AGE is 0 or any power of 2.
This commit is contained in:
Dylan K. Taylor 2023-09-29 12:05:39 +01:00
parent 31cd096b4b
commit fe543a4789
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -35,7 +35,7 @@ trait AgeableTrait{
protected int $age = 0;
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->boundedInt((int) ceil(log(self::MAX_AGE, 2)), 0, self::MAX_AGE, $this->age);
$w->boundedInt(((int) log(self::MAX_AGE, 2)) + 1, 0, self::MAX_AGE, $this->age);
}
public function getAge() : int{ return $this->age; }