30    public const MC_PREFIX = 
"minecraft:";
 
   32    public const ABSORPTION = self::MC_PREFIX . 
"absorption";
 
   33    public const SATURATION = self::MC_PREFIX . 
"player.saturation";
 
   34    public const EXHAUSTION = self::MC_PREFIX . 
"player.exhaustion";
 
   35    public const KNOCKBACK_RESISTANCE = self::MC_PREFIX . 
"knockback_resistance";
 
   36    public const HEALTH = self::MC_PREFIX . 
"health";
 
   37    public const MOVEMENT_SPEED = self::MC_PREFIX . 
"movement";
 
   38    public const FOLLOW_RANGE = self::MC_PREFIX . 
"follow_range";
 
   39    public const HUNGER = self::MC_PREFIX . 
"player.hunger";
 
   40    public const FOOD = self::HUNGER;
 
   41    public const ATTACK_DAMAGE = self::MC_PREFIX . 
"attack_damage";
 
   42    public const EXPERIENCE_LEVEL = self::MC_PREFIX . 
"player.level";
 
   43    public const EXPERIENCE = self::MC_PREFIX . 
"player.experience";
 
   44    public const UNDERWATER_MOVEMENT = self::MC_PREFIX . 
"underwater_movement";
 
   45    public const LUCK = self::MC_PREFIX . 
"luck";
 
   46    public const FALL_DAMAGE = self::MC_PREFIX . 
"fall_damage";
 
   47    public const HORSE_JUMP_STRENGTH = self::MC_PREFIX . 
"horse.jump_strength";
 
   48    public const ZOMBIE_SPAWN_REINFORCEMENTS = self::MC_PREFIX . 
"zombie.spawn_reinforcements";
 
   49    public const LAVA_MOVEMENT = self::MC_PREFIX . 
"lava_movement";
 
   51    protected float $currentValue;
 
   52    protected bool $desynchronized = 
true;
 
   54    public function __construct(
 
   56        protected float $minValue,
 
   57        protected float $maxValue,
 
   58        protected float $defaultValue,
 
   59        protected bool $shouldSend = 
true 
   61        if($minValue > $maxValue || $defaultValue > $maxValue || $defaultValue < $minValue){
 
   62            throw new \InvalidArgumentException(
"Invalid ranges: min value: $minValue, max value: $maxValue, $defaultValue: $defaultValue");
 
   64        $this->currentValue = $this->defaultValue;
 
   67    public function getMinValue() : 
float{
 
   68        return $this->minValue;
 
   75        if($minValue > ($max = $this->getMaxValue())){
 
   76            throw new \InvalidArgumentException(
"Minimum $minValue is greater than the maximum $max");
 
   79        if($this->minValue !== $minValue){
 
   80            $this->desynchronized = 
true;
 
   81            $this->minValue = $minValue;
 
 
   86    public function getMaxValue() : float{
 
   87        return $this->maxValue;
 
   94        if($maxValue < ($min = $this->getMinValue())){
 
   95            throw new \InvalidArgumentException(
"Maximum $maxValue is less than the minimum $min");
 
   98        if($this->maxValue !== $maxValue){
 
   99            $this->desynchronized = 
true;
 
  100            $this->maxValue = $maxValue;
 
 
  105    public function getDefaultValue() : float{
 
  106        return $this->defaultValue;
 
  113        if($defaultValue > $this->getMaxValue() || $defaultValue < $this->getMinValue()){
 
  114            throw new \InvalidArgumentException(
"Default $defaultValue is outside the range " . $this->getMinValue() . 
" - " . $this->getMaxValue());
 
  117        if($this->defaultValue !== $defaultValue){
 
  118            $this->desynchronized = 
true;
 
  119            $this->defaultValue = $defaultValue;
 
 
  124    public function resetToDefault() : void{
 
  125        $this->setValue($this->getDefaultValue(), true);
 
  128    public function getValue() : float{
 
  129        return $this->currentValue;
 
  135    public function setValue(
float $value, 
bool $fit = 
false, 
bool $forceSend = 
false){
 
  136        if($value > $this->getMaxValue() || $value < $this->getMinValue()){
 
  138                throw new \InvalidArgumentException(
"Value $value is outside the range " . $this->getMinValue() . 
" - " . $this->getMaxValue());
 
  140            $value = min(max($value, $this->getMinValue()), $this->getMaxValue());
 
  143        if($this->currentValue !== $value){
 
  144            $this->desynchronized = 
true;
 
  145            $this->currentValue = $value;
 
  147            $this->desynchronized = 
true;
 
 
  153    public function getId() : string{
 
  157    public function isSyncable() : bool{
 
  158        return $this->shouldSend;
 
  161    public function isDesynchronized() : bool{
 
  162        return $this->shouldSend && $this->desynchronized;
 
  165    public function markSynchronized(
bool $synced = 
true) : void{
 
  166        $this->desynchronized = !$synced;