32 private array $attributes = [];
34 public function __construct(){
35 $this->
register(Attribute::ABSORPTION, 0.00, 340282346638528859811704183484516925440.00, 0.00);
36 $this->
register(Attribute::SATURATION, 0.00, 20.00, 20.00);
37 $this->
register(Attribute::EXHAUSTION, 0.00, 5.00, 0.0,
false);
38 $this->
register(Attribute::KNOCKBACK_RESISTANCE, 0.00, 1.00, 0.00);
39 $this->
register(Attribute::HEALTH, 0.00, 20.00, 20.00);
40 $this->
register(Attribute::MOVEMENT_SPEED, 0.00, 340282346638528859811704183484516925440.00, 0.10);
41 $this->
register(Attribute::FOLLOW_RANGE, 0.00, 2048.00, 16.00,
false);
42 $this->
register(Attribute::HUNGER, 0.00, 20.00, 20.00);
43 $this->
register(Attribute::ATTACK_DAMAGE, 0.00, 340282346638528859811704183484516925440.00, 1.00,
false);
44 $this->
register(Attribute::EXPERIENCE_LEVEL, 0.00, 24791.00, 0.00);
45 $this->
register(Attribute::EXPERIENCE, 0.00, 1.00, 0.00);
46 $this->
register(Attribute::UNDERWATER_MOVEMENT, 0.0, 340282346638528859811704183484516925440.0, 0.02);
47 $this->
register(Attribute::LUCK, -1024.0, 1024.0, 0.0);
48 $this->
register(Attribute::FALL_DAMAGE, 0.0, 340282346638528859811704183484516925440.0, 1.0);
49 $this->
register(Attribute::HORSE_JUMP_STRENGTH, 0.0, 2.0, 0.7);
50 $this->
register(Attribute::ZOMBIE_SPAWN_REINFORCEMENTS, 0.0, 1.0, 0.0);
51 $this->
register(Attribute::LAVA_MOVEMENT, 0.0, 340282346638528859811704183484516925440.0, 0.02);
54 public function get(
string $id) : ?
Attribute{
55 return isset($this->attributes[$id]) ? clone $this->attributes[$id] :
null;
58 public function mustGet(
string $id) :
Attribute{
59 $result = $this->
get($id);
61 throw new \InvalidArgumentException(
"Attribute $id is not registered");
69 public function register(
string $id,
float $minValue,
float $maxValue,
float $defaultValue,
bool $shouldSend =
true) :
Attribute{
70 return $this->attributes[$id] = new
Attribute($id, $minValue, $maxValue, $defaultValue, $shouldSend);