85 $this->cause = $cause;
86 if(is_array($damage)){
87 $this->modifiers = $damage;
90 self::MODIFIER_BASE => $damage
94 $this->originals = $this->modifiers;
96 if(!isset($this->modifiers[self::MODIFIER_BASE])){
97 throw new \InvalidArgumentException(
"BASE Damage modifier missing");
101 if($cause !== self::CAUSE_VOID and $cause !== self::CAUSE_SUICIDE){
112 if(
$entity instanceof Player and
$entity->getInventory() instanceof PlayerInventory){
114 case self::CAUSE_CONTACT:
115 case self::CAUSE_ENTITY_ATTACK:
116 case self::CAUSE_PROJECTILE:
117 case self::CAUSE_FIRE:
118 case self::CAUSE_LAVA:
119 case self::CAUSE_BLOCK_EXPLOSION:
120 case self::CAUSE_ENTITY_EXPLOSION:
121 case self::CAUSE_LIGHTNING:
123 foreach(
$entity->getInventory()->getArmorContents() as $index => $i){
125 $points += $i->getArmorValue();
126 $this->usedArmors[$index] = 1;
130 $this->
setRateDamage(1 - 0.04 * $points, self::MODIFIER_ARMOR);
135 case self::CAUSE_ENTITY_EXPLOSION:
136 case self::CAUSE_BLOCK_EXPLOSION:
139 case self::CAUSE_FIRE:
140 case self::CAUSE_LAVA:
143 case self::CAUSE_PROJECTILE:
149 foreach($this->usedArmors as $index => $cost){
150 $i =
$entity->getInventory()->getArmorItem($index);
157 if($spe_Prote !== null){
158 $this->EPF += 2 * $i->getEnchantmentLevel($spe_Prote);
163 case self::CAUSE_FALL:
165 $i =
$entity->getInventory()->getBoots();
171 case self::CAUSE_FIRE_TICK:
172 case self::CAUSE_SUFFOCATION:
173 case self::CAUSE_DROWNING:
174 case self::CAUSE_VOID:
175 case self::CAUSE_SUICIDE:
176 case self::CAUSE_MAGIC:
177 case self::CAUSE_CUSTOM:
178 case self::CAUSE_STARVATION:
183 if($this->EPF !== 0){
184 $this->EPF = min(20, ceil($this->EPF * mt_rand(50, 100) / 100));
185 $this->
setRateDamage(1 - 0.04 * $this->EPF, self::MODIFIER_PROTECTION);