From fd764f22a6319003740937abaf80a69849b82f0e Mon Sep 17 00:00:00 2001 From: Az928 Date: Wed, 18 Oct 2017 15:52:50 +0600 Subject: [PATCH] Major fixes --- src/VanillaEnchants/handlers/BlastProtection.php | 5 ++--- src/VanillaEnchants/handlers/DepthStrider.php | 2 +- src/VanillaEnchants/handlers/FeatherFalling.php | 2 +- src/VanillaEnchants/handlers/FireProtection.php | 3 --- src/VanillaEnchants/handlers/Power.php | 2 +- src/VanillaEnchants/handlers/ProjectileProtection.php | 5 ++--- src/VanillaEnchants/handlers/Protection.php | 5 ++--- src/VanillaEnchants/handlers/Thorns.php | 6 ++++-- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/VanillaEnchants/handlers/BlastProtection.php b/src/VanillaEnchants/handlers/BlastProtection.php index ba119ef..79710e8 100644 --- a/src/VanillaEnchants/handlers/BlastProtection.php +++ b/src/VanillaEnchants/handlers/BlastProtection.php @@ -17,9 +17,8 @@ public function onDamage(EntityDamageEvent $event){ if($player instanceof Player && ($event->getCause() == EntityDamageEvent::CAUSE_BLOCK_EXPLOSION or $event->getCause() == EntityDamageEvent::CAUSE_ENTITY_EXPLOSION)){ $reduce = $this->getArmorPoints($player, 3); if($reduce > 0){ - $reduce *= 2; - $reduce /= 1.5; - $reduce = round($reduce); + $reduce /= 2; + $reduce += 1; $dmg = $event->getDamage() - $reduce; $dmg = $dmg < 0 ? 0 : $dmg; $event->setDamage($dmg); diff --git a/src/VanillaEnchants/handlers/DepthStrider.php b/src/VanillaEnchants/handlers/DepthStrider.php index 3e41b5c..104adb0 100644 --- a/src/VanillaEnchants/handlers/DepthStrider.php +++ b/src/VanillaEnchants/handlers/DepthStrider.php @@ -15,7 +15,7 @@ public function __construct(){ public function onMove(PlayerMoveEvent $event){ $player = $event->getPlayer(); $add = $this->getArmorPoints($player, 7); - $speed = $player->getAttributeMap()->getAttribute(5)->getDefaultValue() + ($add * 0.035); # Not sure about actual speed + $speed = $player->getAttributeMap()->getAttribute(5)->getDefaultValue() + ($add * 0.03); # Not sure about actual speed if(in_array($player->getLevel()->getBlock($player)->getId(), [8, 9]) && $add > 0){ if($player->getAttributeMap()->getAttribute(5)->getValue() < $speed){ $player->getAttributeMap()->getAttribute(5)->setValue($speed, false, true); diff --git a/src/VanillaEnchants/handlers/FeatherFalling.php b/src/VanillaEnchants/handlers/FeatherFalling.php index 113c2db..340a4f0 100644 --- a/src/VanillaEnchants/handlers/FeatherFalling.php +++ b/src/VanillaEnchants/handlers/FeatherFalling.php @@ -18,7 +18,7 @@ public function onDamage(EntityDamageEvent $event){ $reduce = $this->getArmorPoints($player, 2); if($reduce > 0){ $reduce *= 2; - $dmg = $event->getFinalDamage() - $reduce; + $dmg = $event->getDamage() - $reduce; $dmg = $dmg < 0 ? 0 : $dmg; $event->setDamage($dmg); } diff --git a/src/VanillaEnchants/handlers/FireProtection.php b/src/VanillaEnchants/handlers/FireProtection.php index f350b7d..7dfcbe4 100644 --- a/src/VanillaEnchants/handlers/FireProtection.php +++ b/src/VanillaEnchants/handlers/FireProtection.php @@ -17,9 +17,6 @@ public function onDamage(EntityDamageEvent $event){ if($player instanceof Player && ($event->getCause() == EntityDamageEvent::CAUSE_FIRE or $event->getCause() == EntityDamageEvent::CAUSE_FIRE_TICK)){ $reduce = $this->getArmorPoints($player, 1); if($reduce > 0){ - $reduce *= 2; - $reduce /= 1.5; - $reduce = round($reduce); $reduce = $reduce < 1 ? 1 : $reduce; $dmg = $event->getDamage() - $reduce; $dmg = $dmg < 0 ? 0 : $dmg; diff --git a/src/VanillaEnchants/handlers/Power.php b/src/VanillaEnchants/handlers/Power.php index bd99642..f0e0051 100644 --- a/src/VanillaEnchants/handlers/Power.php +++ b/src/VanillaEnchants/handlers/Power.php @@ -23,7 +23,7 @@ public function onDamage(EntityDamageEvent $event){ $item = $damager->getInventory()->getItemInHand(); if($item->hasEnchantment(19) && $item->getId() == 261){ $add = $item->getEnchantment(19)->getLevel() * 0.5 + 3; - $event->setDamage($event->getFinalDamage() + $add); + $event->setDamage($event->getDamage() + $add); } } } diff --git a/src/VanillaEnchants/handlers/ProjectileProtection.php b/src/VanillaEnchants/handlers/ProjectileProtection.php index 8590f30..d5c7f86 100644 --- a/src/VanillaEnchants/handlers/ProjectileProtection.php +++ b/src/VanillaEnchants/handlers/ProjectileProtection.php @@ -17,9 +17,8 @@ public function onDamage(EntityDamageEvent $event){ if($player instanceof Player && $event->getCause() == EntityDamageEvent::CAUSE_PROJECTILE){ $reduce = $this->getArmorPoints($player, 4); if($reduce > 0){ - $reduce *= 2; - $reduce /= 1.5; - $reduce = round($reduce); + $reduce /= 2; + $reduce += 1; $dmg = $event->getDamage() - $reduce; $dmg = $dmg < 0 ? 1 : $dmg; $event->setDamage($dmg); diff --git a/src/VanillaEnchants/handlers/Protection.php b/src/VanillaEnchants/handlers/Protection.php index 5a2d780..a1572c8 100644 --- a/src/VanillaEnchants/handlers/Protection.php +++ b/src/VanillaEnchants/handlers/Protection.php @@ -17,9 +17,8 @@ public function onDamage(EntityDamageEvent $event){ if($player instanceof Player){ $reduce = $this->getArmorPoints($player, 0); if($reduce > 0){ - $reduce *= 2; - $reduce /= 1.5; - $reduce = round($reduce); + $reduce /= 2; + $reduce += 1; $dmg = $event->getDamage() - $reduce; $dmg = $dmg < 0 ? 1 : $dmg; $event->setDamage($dmg); diff --git a/src/VanillaEnchants/handlers/Thorns.php b/src/VanillaEnchants/handlers/Thorns.php index 4adb741..19080dc 100644 --- a/src/VanillaEnchants/handlers/Thorns.php +++ b/src/VanillaEnchants/handlers/Thorns.php @@ -18,10 +18,12 @@ public function onDamage(EntityDamageEvent $event){ if($player instanceof Player && $event instanceof EntityDamageByEntityEvent){ $deflect = $this->getArmorPoints($player, 5); $damager = $event->getDamager(); - if($deflect > 0){ + if($deflect > 0 && rand(1, 100) <= 80){ # 80% chance? + if($damager instanceof Player && $damager->isCreative()){ + return false; + } $deflect *= 2; $deflect /= 1.5; - $deflect = round($deflect); $damager->attack(new EntityDamageByEntityEvent($player, $damager, 0, $deflect)); } }