Introduced VanillaEnchantments registry

This commit is contained in:
Dylan K. Taylor
2020-10-23 20:48:19 +01:00
parent e9038336e3
commit a01c086481
16 changed files with 191 additions and 204 deletions

View File

@@ -28,7 +28,7 @@ use pocketmine\entity\projectile\Arrow as ArrowEntity;
use pocketmine\entity\projectile\Projectile;
use pocketmine\event\entity\EntityShootBowEvent;
use pocketmine\event\entity\ProjectileLaunchEvent;
use pocketmine\item\enchantment\Enchantment;
use pocketmine\item\enchantment\VanillaEnchantments;
use pocketmine\player\Player;
use pocketmine\world\sound\BowShootSound;
use function intdiv;
@@ -64,17 +64,17 @@ class Bow extends Tool implements Releasable{
), $player, $baseForce >= 1);
$entity->setMotion($player->getDirectionVector());
$infinity = $this->hasEnchantment(Enchantment::INFINITY());
$infinity = $this->hasEnchantment(VanillaEnchantments::INFINITY());
if($infinity){
$entity->setPickupMode(ArrowEntity::PICKUP_CREATIVE);
}
if(($punchLevel = $this->getEnchantmentLevel(Enchantment::PUNCH())) > 0){
if(($punchLevel = $this->getEnchantmentLevel(VanillaEnchantments::PUNCH())) > 0){
$entity->setPunchKnockback($punchLevel);
}
if(($powerLevel = $this->getEnchantmentLevel(Enchantment::POWER())) > 0){
if(($powerLevel = $this->getEnchantmentLevel(VanillaEnchantments::POWER())) > 0){
$entity->setBaseDamage($entity->getBaseDamage() + (($powerLevel + 1) / 2));
}
if($this->hasEnchantment(Enchantment::FLAME())){
if($this->hasEnchantment(VanillaEnchantments::FLAME())){
$entity->setOnFire(intdiv($entity->getFireTicks(), 20) + 100);
}
$ev = new EntityShootBowEvent($player, $this, $entity, $baseForce * 3);