mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Implemented Sharpness, Fire Aspect and Knockback enchantments
This commit is contained in:
@ -117,6 +117,12 @@ class Enchantment{
|
||||
self::registerEnchantment(new Enchantment(self::THORNS, "%enchantment.thorns", self::RARITY_MYTHIC, self::SLOT_TORSO, self::SLOT_HEAD | self::SLOT_LEGS | self::SLOT_FEET, 3));
|
||||
self::registerEnchantment(new Enchantment(self::RESPIRATION, "%enchantment.oxygen", self::RARITY_RARE, self::SLOT_HEAD, self::SLOT_NONE, 3));
|
||||
|
||||
self::registerEnchantment(new SharpnessEnchantment(self::SHARPNESS, "%enchantment.damage.all", self::RARITY_COMMON, self::SLOT_SWORD, self::SLOT_AXE, 5));
|
||||
//TODO: smite, bane of arthropods (these don't make sense now because their applicable mobs don't exist yet)
|
||||
|
||||
self::registerEnchantment(new KnockbackEnchantment(self::KNOCKBACK, "%enchantment.knockback", self::RARITY_UNCOMMON, self::SLOT_SWORD, self::SLOT_NONE, 2));
|
||||
self::registerEnchantment(new FireAspectEnchantment(self::FIRE_ASPECT, "%enchantment.fire", self::RARITY_RARE, self::SLOT_SWORD, self::SLOT_NONE, 2));
|
||||
|
||||
self::registerEnchantment(new Enchantment(self::EFFICIENCY, "%enchantment.digging", self::RARITY_COMMON, self::SLOT_DIG, self::SLOT_SHEARS, 5));
|
||||
self::registerEnchantment(new Enchantment(self::SILK_TOUCH, "%enchantment.untouching", self::RARITY_MYTHIC, self::SLOT_DIG, self::SLOT_SHEARS, 1));
|
||||
self::registerEnchantment(new Enchantment(self::UNBREAKING, "%enchantment.durability", self::RARITY_UNCOMMON, self::SLOT_DIG | self::SLOT_ARMOR | self::SLOT_FISHING_ROD | self::SLOT_BOW, self::SLOT_TOOL | self::SLOT_CARROT_STICK | self::SLOT_ELYTRA, 3));
|
||||
|
41
src/pocketmine/item/enchantment/FireAspectEnchantment.php
Normal file
41
src/pocketmine/item/enchantment/FireAspectEnchantment.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item\enchantment;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class FireAspectEnchantment extends MeleeWeaponEnchantment{
|
||||
|
||||
public function isApplicableTo(Entity $victim) : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDamageBonus(int $enchantmentLevel) : float{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function onPostAttack(Entity $attacker, Entity $victim, int $enchantmentLevel) : void{
|
||||
$victim->setOnFire($enchantmentLevel * 4);
|
||||
}
|
||||
}
|
44
src/pocketmine/item/enchantment/KnockbackEnchantment.php
Normal file
44
src/pocketmine/item/enchantment/KnockbackEnchantment.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item\enchantment;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
class KnockbackEnchantment extends MeleeWeaponEnchantment{
|
||||
|
||||
public function isApplicableTo(Entity $victim) : bool{
|
||||
return $victim instanceof Living;
|
||||
}
|
||||
|
||||
public function getDamageBonus(int $enchantmentLevel) : float{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function onPostAttack(Entity $attacker, Entity $victim, int $enchantmentLevel) : void{
|
||||
if($victim instanceof Living){
|
||||
$victim->knockBack($attacker, 0, $victim->x - $attacker->x, $victim->z - $attacker->z, $enchantmentLevel * 0.5);
|
||||
}
|
||||
}
|
||||
}
|
63
src/pocketmine/item/enchantment/MeleeWeaponEnchantment.php
Normal file
63
src/pocketmine/item/enchantment/MeleeWeaponEnchantment.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item\enchantment;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
/**
|
||||
* Classes extending this class can be applied to weapons and activate when used by a mob to attack another mob in melee
|
||||
* combat.
|
||||
*/
|
||||
abstract class MeleeWeaponEnchantment extends Enchantment{
|
||||
|
||||
/**
|
||||
* Returns whether this melee enchantment has an effect on the target entity. For example, Smite only applies to
|
||||
* undead mobs.
|
||||
*
|
||||
* @param Entity $victim
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isApplicableTo(Entity $victim) : bool;
|
||||
|
||||
/**
|
||||
* Returns the amount of additional damage caused by this enchantment to applicable targets.
|
||||
*
|
||||
* @param int $enchantmentLevel
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
abstract public function getDamageBonus(int $enchantmentLevel) : float;
|
||||
|
||||
/**
|
||||
* Called after damaging the entity to apply any post damage effects to the target.
|
||||
*
|
||||
* @param Entity $attacker
|
||||
* @param Entity $victim
|
||||
* @param int $enchantmentLevel
|
||||
*/
|
||||
public function onPostAttack(Entity $attacker, Entity $victim, int $enchantmentLevel) : void{
|
||||
|
||||
}
|
||||
}
|
37
src/pocketmine/item/enchantment/SharpnessEnchantment.php
Normal file
37
src/pocketmine/item/enchantment/SharpnessEnchantment.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item\enchantment;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class SharpnessEnchantment extends MeleeWeaponEnchantment{
|
||||
|
||||
public function isApplicableTo(Entity $victim) : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDamageBonus(int $enchantmentLevel) : float{
|
||||
return 0.5 * ($enchantmentLevel + 1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user