mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Implemented armor durability
This commit is contained in:
@ -25,12 +25,13 @@ declare(strict_types=1);
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\enchantment\ProtectionEnchantment;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Color;
|
||||
|
||||
abstract class Armor extends Item{
|
||||
abstract class Armor extends Durable{
|
||||
|
||||
public const TAG_CUSTOM_COLOR = "customColor"; //TAG_Int
|
||||
|
||||
@ -78,4 +79,21 @@ abstract class Armor extends Item{
|
||||
|
||||
return $epf;
|
||||
}
|
||||
|
||||
protected function getUnbreakingDamageReduction(int $amount) : int{
|
||||
if(($unbreakingLevel = $this->getEnchantmentLevel(Enchantment::UNBREAKING)) > 0){
|
||||
$negated = 0;
|
||||
|
||||
$chance = 1 / ($unbreakingLevel + 1);
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
if(mt_rand(1, 100) > 60 and lcg_value() > $chance){ //unbreaking only applies to armor 40% of the time at best
|
||||
$negated++;
|
||||
}
|
||||
}
|
||||
|
||||
return $negated;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class ChainBoots extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 196;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class ChainChestplate extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 241;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class ChainHelmet extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 166;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class ChainLeggings extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 226;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class DiamondBoots extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 430;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class DiamondChestplate extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 529;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class DiamondHelmet extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 364;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class DiamondLeggings extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 496;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class GoldBoots extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 92;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class GoldChestplate extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 113;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class GoldHelmet extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 78;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class GoldLeggings extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 106;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class IronBoots extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 196;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class IronChestplate extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 241;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class IronHelmet extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 166;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class IronLeggings extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 226;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class LeatherBoots extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 66;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class LeatherCap extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 56;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class LeatherPants extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 76;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class LeatherTunic extends Armor{
|
||||
public function getDefensePoints() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 81;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user