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. * @return float */ public function getTypeModifier() : float{ return $this->typeModifier; } /** * Returns the base EPF this enchantment type offers for the given enchantment level. * * @param int $level * * @return int */ 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. * * @param EntityDamageEvent $event * * @return bool */ public function isApplicable(EntityDamageEvent $event) : bool{ return $this->applicableDamageTypes === null or isset($this->applicableDamageTypes[$event->getCause()]); } }