58 $this->abilityId = VarInt::readSignedInt($in);
60 $valueType = Byte::readUnsigned($in);
64 $boolValue = CommonTypes::getBool($in);
65 $floatValue = LE::readFloat($in);
67 $this->abilityValue = match($valueType){
68 self::VALUE_TYPE_BOOL => $boolValue,
69 self::VALUE_TYPE_FLOAT => $floatValue,
75 VarInt::writeSignedInt($out, $this->abilityId);
77 [$valueType, $boolValue, $floatValue] = match(
true){
78 is_bool($this->abilityValue) => [self::VALUE_TYPE_BOOL, $this->abilityValue, 0.0],
79 is_float($this->abilityValue) => [self::VALUE_TYPE_FLOAT,
false, $this->abilityValue],
80 default =>
throw new \LogicException(
"Unreachable")
82 Byte::writeUnsigned($out, $valueType);
83 CommonTypes::putBool($out, $boolValue);
84 LE::writeFloat($out, $floatValue);