typeModifier = $typeModifier; if($applicableDamageTypes !== null){ $this->applicableDamageTypes = array_flip($applicableDamageTypes); } } /** * Returns the multiplier by which this enchantment type's EPF increases with each enchantment level. */ public function getTypeModifier() : float{ return $this->typeModifier; } /** * Returns the base EPF this enchantment type offers for the given enchantment level. */ public function getProtectionFactor(int $level) : int{ return (int) floor((6 + $level ** 2) * $this->typeModifier / 3); } /** * Returns whether this enchantment type offers protection from the specified damage source's cause. */ public function isApplicable(EntityDamageEvent $event) : bool{ return $this->applicableDamageTypes === null or isset($this->applicableDamageTypes[$event->getCause()]); } }