mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Added hunger and experience saving
This commit is contained in:
@ -32,7 +32,6 @@ use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\network\protocol\EntityEventPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\BlockIterator;
|
||||
|
||||
@ -48,14 +47,10 @@ abstract class Living extends Entity implements Damageable{
|
||||
protected function initEntity(){
|
||||
parent::initEntity();
|
||||
|
||||
$this->addAttributes();
|
||||
|
||||
if(isset($this->namedtag->HealF)){
|
||||
$this->namedtag->Health = new ShortTag("Health", (int) $this->namedtag["HealF"]);
|
||||
unset($this->namedtag->HealF);
|
||||
}
|
||||
|
||||
if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof ShortTag)){
|
||||
}elseif(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof ShortTag)){
|
||||
$this->namedtag->Health = new ShortTag("Health", $this->getMaxHealth());
|
||||
}
|
||||
|
||||
@ -63,10 +58,12 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
protected function addAttributes(){
|
||||
$this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::ABSORPTION));
|
||||
$this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::HEALTH));
|
||||
$this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::MOVEMENT_SPEED));
|
||||
$this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::FOLLOW_RANGE));
|
||||
$this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::KNOCKBACK_RESISTANCE));
|
||||
$this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::MOVEMENT_SPEED));
|
||||
$this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::ATTACK_DAMAGE));
|
||||
$this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::ABSORPTION));
|
||||
}
|
||||
|
||||
public function setHealth($amount){
|
||||
|
Reference in New Issue
Block a user