Revert "Implemented proportional armor modifier, applied armor in other damage types and consume armor when player is damaged"

This commit is contained in:
Shoghi Cervantes 2015-03-18 17:26:06 +01:00
parent 7c0bd45d1d
commit d34499e67b
31 changed files with 203 additions and 397 deletions

View File

@ -68,7 +68,6 @@ use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory; use pocketmine\inventory\PlayerInventory;
use pocketmine\inventory\SimpleTransactionGroup; use pocketmine\inventory\SimpleTransactionGroup;
use pocketmine\inventory\StonecutterShapelessRecipe; use pocketmine\inventory\StonecutterShapelessRecipe;
use pocketmine\item\Armor;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\level\format\LevelProvider; use pocketmine\level\format\LevelProvider;
@ -1983,7 +1982,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1, EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1,
]; ];
$points = 0;
if($this->distance($target) > 8){ if($this->distance($target) > 8){
$cancelled = true; $cancelled = true;
}elseif($target instanceof Player){ }elseif($target instanceof Player){
@ -1993,7 +1991,34 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$cancelled = true; $cancelled = true;
} }
$points = $target->getInventory()->getArmorPoints(); $armorValues = [
Item::LEATHER_CAP => 1,
Item::LEATHER_TUNIC => 3,
Item::LEATHER_PANTS => 2,
Item::LEATHER_BOOTS => 1,
Item::CHAIN_HELMET => 1,
Item::CHAIN_CHESTPLATE => 5,
Item::CHAIN_LEGGINGS => 4,
Item::CHAIN_BOOTS => 1,
Item::GOLD_HELMET => 1,
Item::GOLD_CHESTPLATE => 5,
Item::GOLD_LEGGINGS => 3,
Item::GOLD_BOOTS => 1,
Item::IRON_HELMET => 2,
Item::IRON_CHESTPLATE => 6,
Item::IRON_LEGGINGS => 5,
Item::IRON_BOOTS => 2,
Item::DIAMOND_HELMET => 3,
Item::DIAMOND_CHESTPLATE => 8,
Item::DIAMOND_LEGGINGS => 6,
Item::DIAMOND_BOOTS => 3,
];
$points = 0;
foreach($target->getInventory()->getArmorContents() as $index => $i){
if(isset($armorValues[$i->getId()])){
$points += $armorValues[$i->getId()];
}
}
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04); $damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
} }
@ -2021,6 +2046,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
} }
} }
break; break;
case ProtocolInfo::ANIMATE_PACKET: case ProtocolInfo::ANIMATE_PACKET:
if($this->spawned === false or $this->dead === true){ if($this->spawned === false or $this->dead === true){
@ -2662,24 +2688,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
parent::attack($damage, $source); parent::attack($damage, $source);
if($source instanceof EntityDamageEvent){ if($source instanceof EntityDamageEvent and $source->isCancelled()){
if($source->isCancelled()){ return;
return;
}
if($source->getDamage(EntityDamageEvent::MODIFIER_ARMOR) > 0){
for($i = 0; $i < 4; $i++){
$piece = $this->getInventory()->getArmorItem($i);
if($piece instanceof Armor){
$damage = $piece->getDamage();
if($damage >= $piece->getMaxDurability()){
$this->getInventory()->setArmorItem($i, Item::get(Item::AIR));
}else{
$piece->setDamage($damage + 1);
$this->getInventory()->setArmorItem($i, $piece);
}
}
}
}
} }
if($this->getLastDamageCause() === $source){ if($this->getLastDamageCause() === $source){
@ -2688,8 +2698,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$pk->event = 2; $pk->event = 2;
$this->dataPacket($pk); $this->dataPacket($pk);
} }
} }
public function getData(){ //TODO public function getData(){ //TODO

View File

@ -25,8 +25,6 @@ use pocketmine\entity\Entity;
use pocketmine\event\block\BlockGrowEvent; use pocketmine\event\block\BlockGrowEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent; use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -67,14 +65,7 @@ class Cactus extends Transparent{
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$damage = [EntityDamageEvent::MODIFIER_BASE => 1]; $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, $damage);
$entity->attack($ev->getFinalDamage(), $ev); $entity->attack($ev->getFinalDamage(), $ev);
} }

View File

@ -25,8 +25,6 @@ use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityCombustByBlockEvent; use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent; use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\Server; use pocketmine\Server;
@ -60,14 +58,7 @@ class Fire extends Flowable{
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$damage = [EntityDamageEvent::MODIFIER_BASE => 1]; $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, $damage);
$entity->attack($ev->getFinalDamage(), $ev); $entity->attack($ev->getFinalDamage(), $ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 8); $ev = new EntityCombustByBlockEvent($this, $entity, 8);

View File

@ -25,8 +25,6 @@ use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityCombustByBlockEvent; use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent; use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
@ -53,14 +51,7 @@ class Lava extends Liquid{
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$entity->fallDistance *= 0.5; $entity->fallDistance *= 0.5;
$damage = [EntityDamageEvent::MODIFIER_BASE => 1]; $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, $damage);
$entity->attack($ev->getFinalDamage(), $ev); $entity->attack($ev->getFinalDamage(), $ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 15); $ev = new EntityCombustByBlockEvent($this, $entity, 15);

View File

@ -33,8 +33,6 @@ use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\entity\EntitySpawnEvent; use pocketmine\event\entity\EntitySpawnEvent;
use pocketmine\event\entity\EntityTeleportEvent; use pocketmine\event\entity\EntityTeleportEvent;
use pocketmine\event\Timings; use pocketmine\event\Timings;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\level\format\Chunk; use pocketmine\level\format\Chunk;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\level\Level; use pocketmine\level\Level;
@ -737,13 +735,6 @@ abstract class Entity extends Location implements Metadatable{
public function fall($fallDistance){ public function fall($fallDistance){
$damage = floor($fallDistance - 3); $damage = floor($fallDistance - 3);
if($damage > 0){ if($damage > 0){
$damage = [EntityDamageEvent::MODIFIER_BASE => $damage];
if($this instanceof InventoryHolder){
$inventory = $this->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage); $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage);
$this->attack($ev->getFinalDamage(), $ev); $this->attack($ev->getFinalDamage(), $ev);
} }

View File

@ -28,8 +28,6 @@ use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityDeathEvent; use pocketmine\event\entity\EntityDeathEvent;
use pocketmine\event\entity\EntityRegainHealthEvent; use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\Timings; use pocketmine\event\Timings;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item as ItemItem; use pocketmine\item\Item as ItemItem;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\Short;
@ -170,14 +168,7 @@ abstract class Living extends Entity implements Damageable{
if($this->dead !== true and $this->isInsideOfSolid()){ if($this->dead !== true and $this->isInsideOfSolid()){
$hasUpdate = true; $hasUpdate = true;
$damage = [EntityDamageEvent::MODIFIER_BASE => 1]; $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
if($this instanceof InventoryHolder){
$inventory = $this->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory;
}
}
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, $damage);
$this->attack($ev->getFinalDamage(), $ev); $this->attack($ev->getFinalDamage(), $ev);
} }
@ -187,14 +178,7 @@ abstract class Living extends Entity implements Damageable{
if($this->airTicks <= -20){ if($this->airTicks <= -20){
$this->airTicks = 0; $this->airTicks = 0;
$damage = [EntityDamageEvent::MODIFIER_BASE => 2]; $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
if($this instanceof InventoryHolder){
$inventory = $this->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, $damage);
$this->attack($ev->getFinalDamage(), $ev); $this->attack($ev->getFinalDamage(), $ev);
} }
}else{ }else{

View File

@ -24,11 +24,10 @@ namespace pocketmine\entity;
use pocketmine\event\entity\EntityCombustByEntityEvent; use pocketmine\event\entity\EntityCombustByEntityEvent;
use pocketmine\event\entity\EntityDamageByChildEntityEvent; use pocketmine\event\entity\EntityDamageByChildEntityEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityRegainHealthEvent; use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\entity\ProjectileHitEvent; use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\level\MovingObjectPosition; use pocketmine\level\MovingObjectPosition;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\Short;
@ -137,22 +136,15 @@ abstract class Projectile extends Entity{
$this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this)); $this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
$motion = sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2); $motion = sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2);
$damage = [EntityDamageEvent::MODIFIER_BASE => ceil($motion * $this->damage)]; $damage = ceil($motion * $this->damage);
$hit = $movingObjectPosition->entityHit;
if($hit instanceof InventoryHolder){
$inventory = $hit->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
if($this->shootingEntity === null){ if($this->shootingEntity === null){
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_PROJECTILE, $damage); $ev = new EntityDamageByEntityEvent($this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
}else{ }else{
$ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $hit, EntityDamageEvent::CAUSE_PROJECTILE, $damage); $ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
} }
$hit->attack($ev->getFinalDamage(), $ev); $movingObjectPosition->entityHit->attack($ev->getFinalDamage(), $ev);
if($this->fireTicks > 0){ if($this->fireTicks > 0){

View File

@ -25,7 +25,6 @@ use pocketmine\entity\Human;
use pocketmine\event\entity\EntityArmorChangeEvent; use pocketmine\event\entity\EntityArmorChangeEvent;
use pocketmine\event\entity\EntityInventoryChangeEvent; use pocketmine\event\entity\EntityInventoryChangeEvent;
use pocketmine\event\player\PlayerItemHeldEvent; use pocketmine\event\player\PlayerItemHeldEvent;
use pocketmine\item\Armor;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\network\protocol\ContainerSetContentPacket; use pocketmine\network\protocol\ContainerSetContentPacket;
use pocketmine\network\protocol\ContainerSetSlotPacket; use pocketmine\network\protocol\ContainerSetSlotPacket;
@ -300,15 +299,6 @@ class PlayerInventory extends BaseInventory{
return $armor; return $armor;
} }
public function getArmorPoints(){
$points = 0;
foreach($this->getArmorContents() as $i){
if($i instanceof Armor){
$points += $i->getArmorPoints();
}
}
return $points;
}
public function clearAll(){ public function clearAll(){
$limit = $this->getSize() + 4; $limit = $this->getSize() + 4;
for($index = 0; $index < $limit; ++$index){ for($index = 0; $index < $limit; ++$index){

View File

@ -27,8 +27,4 @@ abstract class Armor extends Item{
public function getMaxStackSize(){ public function getMaxStackSize(){
return 1; return 1;
} }
/**
* @return int
*/
public abstract function getArmorPoints();
} }

View File

@ -26,10 +26,4 @@ class ChainBoots extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::CHAIN_BOOTS, $meta, $count, "Chainmail Boots"); parent::__construct(self::CHAIN_BOOTS, $meta, $count, "Chainmail Boots");
} }
public function getArmorPoints(){
return 1;
}
public function getMaxDurability(){
return 196;
}
} }

View File

@ -26,10 +26,4 @@ class ChainChestplate extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::CHAIN_CHESTPLATE, $meta, $count, "Chain Chestplate"); parent::__construct(self::CHAIN_CHESTPLATE, $meta, $count, "Chain Chestplate");
} }
public function getArmorPoints(){
return 5;
}
public function getMaxDurability(){
return 241;
}
} }

View File

@ -26,10 +26,4 @@ class ChainHelmet extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::CHAIN_HELMET, $meta, $count, "Chainmail Helmet"); parent::__construct(self::CHAIN_HELMET, $meta, $count, "Chainmail Helmet");
} }
public function getArmorPoints(){
return 2;
}
public function getMaxDurability(){
return 166;
}
} }

View File

@ -26,10 +26,4 @@ class ChainLeggings extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::CHAIN_LEGGINGS, $meta, $count, "Chain Leggings"); parent::__construct(self::CHAIN_LEGGINGS, $meta, $count, "Chain Leggings");
} }
public function getArmorPoints(){
return 3;
}
public function getMaxDurability(){
return 226;
}
} }

View File

@ -26,10 +26,4 @@ class DiamondBoots extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_BOOTS, $meta, $count, "Diamond Boots"); parent::__construct(self::DIAMOND_BOOTS, $meta, $count, "Diamond Boots");
} }
public function getArmorPoints(){
return 3;
}
public function getMaxDurability(){
return 430;
}
} }

View File

@ -26,10 +26,4 @@ class DiamondChestplate extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_CHESTPLATE, $meta, $count, "Diamond Chestplate"); parent::__construct(self::DIAMOND_CHESTPLATE, $meta, $count, "Diamond Chestplate");
} }
public function getArmorPoints(){
return 8;
}
public function getMaxDurability(){
return 529;
}
} }

View File

@ -26,10 +26,4 @@ class DiamondHelmet extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_HELMET, $meta, $count, "Diamond Helmet"); parent::__construct(self::DIAMOND_HELMET, $meta, $count, "Diamond Helmet");
} }
public function getArmorPoints(){
return 3;
}
public function getMaxDurability(){
return 364;
}
} }

View File

@ -26,10 +26,4 @@ class DiamondLeggings extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_LEGGINGS, $meta, $count, "Diamond Leggings"); parent::__construct(self::DIAMOND_LEGGINGS, $meta, $count, "Diamond Leggings");
} }
public function getArmorPoints(){
return 6;
}
public function getMaxDurability(){
return 496;
}
} }

View File

@ -26,10 +26,4 @@ class GoldBoots extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_BOOTS, $meta, $count, "Gold Boots"); parent::__construct(self::GOLD_BOOTS, $meta, $count, "Gold Boots");
} }
public function getArmorPoints(){
return 1;
}
public function getMaxDurability(){
return 92;
}
} }

View File

@ -26,10 +26,4 @@ class GoldChestplate extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_CHESTPLATE, $meta, $count, "Gold Chestplate"); parent::__construct(self::GOLD_CHESTPLATE, $meta, $count, "Gold Chestplate");
} }
public function getArmorPoints(){
return 5;
}
public function getMaxDurability(){
return 113;
}
} }

View File

@ -26,10 +26,4 @@ class GoldHelmet extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_HELMET, $meta, $count, "Gold Helmet"); parent::__construct(self::GOLD_HELMET, $meta, $count, "Gold Helmet");
} }
public function getArmorPoints(){
return 2;
}
public function getMaxDurability(){
return 78;
}
} }

View File

@ -26,10 +26,4 @@ class GoldLeggings extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_LEGGINGS, $meta, $count, "Gold Leggings"); parent::__construct(self::GOLD_LEGGINGS, $meta, $count, "Gold Leggings");
} }
public function getArmorPoints(){
return 3;
}
public function getMaxDurability(){
return 106;
}
} }

View File

@ -26,10 +26,4 @@ class IronBoots extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::IRON_BOOTS, $meta, $count, "Iron Boots"); parent::__construct(self::IRON_BOOTS, $meta, $count, "Iron Boots");
} }
public function getArmorPoints(){
return 2;
}
public function getMaxDurability(){
return 196;
}
} }

View File

@ -26,10 +26,4 @@ class IronChestplate extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::IRON_CHESTPLATE, $meta, $count, "Iron Chestplate"); parent::__construct(self::IRON_CHESTPLATE, $meta, $count, "Iron Chestplate");
} }
public function getArmorPoints(){
return 6;
}
public function getMaxDurability(){
return 241;
}
} }

View File

@ -26,10 +26,4 @@ class IronHelmet extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::IRON_HELMET, $meta, $count, "Iron Helmet"); parent::__construct(self::IRON_HELMET, $meta, $count, "Iron Helmet");
} }
public function getArmorPoints(){
return 2;
}
public function getMaxDurability(){
return 166;
}
} }

View File

@ -26,10 +26,4 @@ class IronLeggings extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::IRON_LEGGINGS, $meta, $count, "Iron Leggings"); parent::__construct(self::IRON_LEGGINGS, $meta, $count, "Iron Leggings");
} }
public function getArmorPoints(){
return 5;
}
public function getMaxDurability(){
return 226;
}
} }

View File

@ -26,10 +26,4 @@ class LeatherBoots extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::LEATHER_BOOTS, $meta, $count, "Leather Boots"); parent::__construct(self::LEATHER_BOOTS, $meta, $count, "Leather Boots");
} }
public function getArmorPoints(){
return 1;
}
public function getMaxDurability(){
return 66;
}
} }

View File

@ -26,10 +26,4 @@ class LeatherCap extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::LEATHER_CAP, $meta, $count, "Leather Cap"); parent::__construct(self::LEATHER_CAP, $meta, $count, "Leather Cap");
} }
public function getArmorPoints(){
return 1;
}
public function getMaxDurability(){
return 56;
}
} }

View File

@ -26,10 +26,4 @@ class LeatherPants extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::LEATHER_PANTS, $meta, $count, "Leather Pants"); parent::__construct(self::LEATHER_PANTS, $meta, $count, "Leather Pants");
} }
public function getArmorPoints(){
return 2;
}
public function getMaxDurability(){
return 76;
}
} }

View File

@ -26,10 +26,4 @@ class LeatherTunic extends Armor{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){
parent::__construct(self::LEATHER_TUNIC, $meta, $count, "Leather Tunic"); parent::__construct(self::LEATHER_TUNIC, $meta, $count, "Leather Tunic");
} }
public function getArmorPoints(){
return 3;
}
public function getMaxDurability(){
return 81;
}
} }

View File

@ -27,8 +27,6 @@ use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityExplodeEvent; use pocketmine\event\entity\EntityExplodeEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Math; use pocketmine\math\Math;
@ -163,13 +161,7 @@ class Explosion{
$impact = (1 - $distance) * ($exposure = 1); $impact = (1 - $distance) * ($exposure = 1);
$damage = [EntityDamageEvent::MODIFIER_BASE => (int) ((($impact * $impact + $impact) / 2) * 8 * $explosionSize + 1)]; $damage = (int) ((($impact * $impact + $impact) / 2) * 8 * $explosionSize + 1);
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
if($this->what instanceof Entity){ if($this->what instanceof Entity){
$ev = new EntityDamageByEntityEvent($this->what, $entity, EntityDamageEvent::CAUSE_ENTITY_EXPLOSION, $damage); $ev = new EntityDamageByEntityEvent($this->what, $entity, EntityDamageEvent::CAUSE_ENTITY_EXPLOSION, $damage);