Merge branch 'master' into mcpe-0.11

This commit is contained in:
Shoghi Cervantes 2015-03-17 19:12:03 +01:00
commit 1b25cd6ffa
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
38 changed files with 482 additions and 228 deletions

View File

@ -69,6 +69,7 @@ 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;
@ -217,6 +218,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
public function setBanned($value){ public function setBanned($value){
if($value === true){ if($value === true){
$this->server->getNameBans()->addBan($this->getName(), null, null, null); $this->server->getNameBans()->addBan($this->getName(), null, null, null);
$this->kick("You have been banned");
}else{ }else{
$this->server->getNameBans()->remove($this->getName()); $this->server->getNameBans()->remove($this->getName());
} }
@ -1250,7 +1252,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->entityBaseTick(1); $this->entityBaseTick(1);
if(!$this->forceMovement and $this->speed and $this->isSurvival()){ if($this->forceMovement === null and $this->speed and $this->isSurvival()){
$speed = sqrt($this->speed->x ** 2 + $this->speed->z ** 2); $speed = sqrt($this->speed->x ** 2 + $this->speed->z ** 2);
if($speed > 0.45){ if($speed > 0.45){
$this->highSpeedTicks += $speed > 3 ? 2 : 1; $this->highSpeedTicks += $speed > 3 ? 2 : 1;
@ -1280,10 +1282,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if(!$this->hasEffect(Effect::JUMP) and $diff > 0.6 and $expectedVelocity < $this->speed->y and !$this->server->getAllowFlight()){ if(!$this->hasEffect(Effect::JUMP) and $diff > 0.6 and $expectedVelocity < $this->speed->y and !$this->server->getAllowFlight()){
if($this->inAirTicks < 100){ if($this->inAirTicks < 100){
$this->setMotion(new Vector3(0, $expectedVelocity, 0)); $this->setMotion(new Vector3(0, $expectedVelocity, 0));
}else{ }elseif($this->kick("Flying is not enabled on this server")){
if($this->kick("Flying is not enabled on this server")){ return false;
return false;
}
} }
} }
} }
@ -1975,6 +1975,7 @@ 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){
@ -1984,34 +1985,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$cancelled = true; $cancelled = true;
} }
$armorValues = [ $points = $target->getInventory()->getArmorPoints();
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);
} }
@ -2039,7 +2013,6 @@ 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){
@ -2633,6 +2606,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if($ev->getDeathMessage() != ""){ if($ev->getDeathMessage() != ""){
$this->server->broadcast($ev->getDeathMessage(), Server::BROADCAST_CHANNEL_USERS); $this->server->broadcast($ev->getDeathMessage(), Server::BROADCAST_CHANNEL_USERS);
} }
if($this->server->isHardcore()){
$this->setBanned(true);
}
} }
public function setHealth($amount){ public function setHealth($amount){
@ -2671,8 +2648,24 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
parent::attack($damage, $source); parent::attack($damage, $source);
if($source instanceof EntityDamageEvent and $source->isCancelled()){ if($source instanceof EntityDamageEvent){
return; if($source->isCancelled()){
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){
@ -2681,6 +2674,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$pk->event = 2; $pk->event = 2;
$this->dataPacket($pk); $this->dataPacket($pk);
} }
} }
public function teleport(Vector3 $pos, $yaw = null, $pitch = null){ public function teleport(Vector3 $pos, $yaw = null, $pitch = null){

View File

@ -1142,10 +1142,11 @@ class Server{
$seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed; $seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed;
if($generator !== null and class_exists($generator) and is_subclass_of($generator, Generator::class)){ if(!isset($options["presey"])){
$generator = new $generator($options);
}else{
$options["preset"] = $this->getConfigString("generator-settings", ""); $options["preset"] = $this->getConfigString("generator-settings", "");
}
if(!($generator !== null and class_exists($generator, true) and is_subclass_of($generator, Generator::class))){
$generator = Generator::getGenerator($this->getLevelType()); $generator = Generator::getGenerator($this->getLevelType());
} }

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -25,6 +25,8 @@ 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;
@ -65,7 +67,14 @@ class Cactus extends Transparent{
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1); $damage = [EntityDamageEvent::MODIFIER_BASE => 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);
} }
@ -128,4 +137,4 @@ class Cactus extends Transparent{
[$this->id, 0, 1], [$this->id, 0, 1],
]; ];
} }
} }

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -25,6 +25,8 @@ 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;
@ -58,7 +60,14 @@ class Fire extends Flowable{
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1); $damage = [EntityDamageEvent::MODIFIER_BASE => 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);
@ -94,4 +103,4 @@ class Fire extends Flowable{
return false; return false;
} }
} }

View File

@ -21,6 +21,7 @@
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\item\Item;
class IronBars extends Thin{ class IronBars extends Thin{
@ -33,5 +34,36 @@ class IronBars extends Thin{
public function getName(){ public function getName(){
return "Iron Bars"; return "Iron Bars";
} }
public function getHardness(){
return 5;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.95;
case 4:
return 1.25;
case 3:
return 1.9;
case 2:
return 0.65;
case 1:
return 3.75;
default:
return 5;
}
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::IRON_BARS, 0, 1],
];
}else{
return [];
}
}
}
}

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -25,6 +25,8 @@ 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;
@ -51,8 +53,15 @@ 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];
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
if(!$entity->hasEffect(Effect::FIRE_RESISTANCE)){ if(!$entity->hasEffect(Effect::FIRE_RESISTANCE)){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4); $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, $damage);
$entity->attack($ev->getFinalDamage(), $ev); $entity->attack($ev->getFinalDamage(), $ev);
} }

View File

@ -50,8 +50,12 @@ class Stonecutter extends Solid{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
return [ if($item->isPickaxe() >= 1){
[$this->id, 0, 1], return [
]; [Item::STONECUTTER, 0, 1],
];
}else{
return [];
}
} }
} }

View File

@ -23,6 +23,7 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\Player;
class TallGrass extends Flowable{ class TallGrass extends Flowable{
@ -45,6 +46,17 @@ class TallGrass extends Flowable{
]; ];
return $names[$this->meta & 0x03]; return $names[$this->meta & 0x03];
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getId() === self::GRASS){
$this->getLevel()->setBlock($block, $this, true);
return true;
}
return false;
}
public function onUpdate($type){ public function onUpdate($type){
@ -67,4 +79,4 @@ class TallGrass extends Flowable{
return []; return [];
} }
} }

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -33,6 +33,8 @@ 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;
@ -867,6 +869,13 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -28,6 +28,8 @@ 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;
@ -176,7 +178,14 @@ 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;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1); $damage = [EntityDamageEvent::MODIFIER_BASE => 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);
} }
@ -186,7 +195,14 @@ abstract class Living extends Entity implements Damageable{
if($airTicks <= -20){ if($airTicks <= -20){
$airTicks = 0; $airTicks = 0;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2); $damage = [EntityDamageEvent::MODIFIER_BASE => 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);
} }
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks); $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks);

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -24,10 +24,11 @@ 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;
@ -127,15 +128,22 @@ 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 = ceil($motion * $this->damage); $damage = [EntityDamageEvent::MODIFIER_BASE => ceil($motion * $this->damage)];
$hit = $movingObjectPosition->entityHit;
if($this->shootingEntity === null){ if($hit instanceof InventoryHolder){
$ev = new EntityDamageByEntityEvent($this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage); $inventory = $hit->getInventory();
}else{ if($inventory instanceof PlayerInventory){
$ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage); $damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
} }
$movingObjectPosition->entityHit->attack($ev->getFinalDamage(), $ev); if($this->shootingEntity === null){
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
}else{
$ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $hit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
}
$hit->attack($ev->getFinalDamage(), $ev);
if($this->fireTicks > 0){ if($this->fireTicks > 0){
@ -179,4 +187,4 @@ abstract class Projectile extends Entity{
return $hasUpdate; return $hasUpdate;
} }
} }

View File

@ -49,4 +49,4 @@ class EntityDamageByBlockEvent extends EntityDamageEvent{
} }
} }

View File

@ -115,7 +115,9 @@ abstract class BaseInventory implements Inventory{
$this->clear($i); $this->clear($i);
} }
}else{ }else{
$this->setItem($i, $items[$i]); if (!$this->setItem($i, $items[$i])){
$this->clear($i);
}
} }
} }
} }

View File

@ -37,7 +37,8 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
public function __construct(Chest $left, Chest $right){ public function __construct(Chest $left, Chest $right){
$this->left = $left->getRealInventory(); $this->left = $left->getRealInventory();
$this->right = $right->getRealInventory(); $this->right = $right->getRealInventory();
BaseInventory::__construct($this, InventoryType::get(InventoryType::DOUBLE_CHEST)); $items = array_merge($this->left->getContents(), $this->right->getContents());
BaseInventory::__construct($this, InventoryType::get(InventoryType::DOUBLE_CHEST), $items);
} }
public function getInventory(){ public function getInventory(){
@ -77,13 +78,19 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
$items = array_slice($items, 0, $this->size, true); $items = array_slice($items, 0, $this->size, true);
} }
parent::setContents($items);
$leftItems = array_slice($items, 0, $this->left->getSize(), true); for($i = 0; $i < $this->size; ++$i){
$this->left->setContents($leftItems); if(!isset($items[$i])){
if(count($items) > $this->left->getSize()){ if ($i < $this->left->size){
$rightItems = array_slice($items, $this->left->getSize() - 1, $this->right->getSize(), true); if(isset($this->left->slots[$i])){
$this->right->setContents($rightItems); $this->clear($i);
}
}elseif(isset($this->right->slots[$i - $this->left->size])){
$this->clear($i);
}
}elseif(!$this->setItem($i, $items[$i])){
$this->clear($i);
}
} }
} }

View File

@ -25,6 +25,7 @@ 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;
@ -297,6 +298,15 @@ 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,4 +27,8 @@ abstract class Armor extends Item{
public function getMaxStackSize(){ public function getMaxStackSize(){
return 1; return 1;
} }
} /**
* @return int
*/
public abstract function getArmorPoints();
}

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -26,4 +26,10 @@ 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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -27,6 +27,8 @@ 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;
@ -161,7 +163,13 @@ class Explosion{
$impact = (1 - $distance) * ($exposure = 1); $impact = (1 - $distance) * ($exposure = 1);
$damage = (int) ((($impact * $impact + $impact) / 2) * 8 * $explosionSize + 1); $damage = [EntityDamageEvent::MODIFIER_BASE => (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);

View File

@ -128,9 +128,8 @@ class Vector3{
public function floor(){ public function floor(){
$x = (int) $this->x; $x = (int) $this->x;
$y = (int) $this->y;
$z = (int) $this->z; $z = (int) $this->z;
return new Vector3($this->x >= $x ? $x : $x - 1, $this->y >= $y ? $y : $y - 1, $this->z >= $z ? $z : $z - 1); return new Vector3($this->x >= $x ? $x : $x - 1, round($this->y), $this->z >= $z ? $z : $z - 1);
} }
public function round(){ public function round(){