declare(strict_types=0x1);namespace
pocketmine\entity;use
pocketmine\entity\effect\EffectInstance as €;use
pocketmine\entity\effect\VanillaEffects as �;use
pocketmine\entity\projectile\ProjectileSource as �;use
pocketmine\event\entity\EntityDamageEvent as �;use
pocketmine\event\player\PlayerExhaustEvent as �;use
pocketmine\inventory\EnderChestInventory as �;use
pocketmine\inventory\InventoryHolder as �;use
pocketmine\inventory\PlayerInventory as �;use
pocketmine\inventory\PlayerOffHandInventory as �;use
pocketmine\item\Consumable as �;use
pocketmine\item\enchantment\Enchantment as �;use
pocketmine\item\FoodSource as �;use
pocketmine\item\Item as �;use
pocketmine\item\Totem as �;use
pocketmine\nbt\NBT as �;use
pocketmine\nbt\tag\CompoundTag as �;use
pocketmine\nbt\tag\IntTag as �;use
pocketmine\nbt\tag\ListTag as �;use
pocketmine\nbt\tag\StringTag as �;use
pocketmine\network\mcpe\protocol\ActorEventPacket as �;use
pocketmine\network\mcpe\protocol\AddPlayerPacket as �;use
pocketmine\network\mcpe\protocol\MovePlayerPacket as �;use
pocketmine\network\mcpe\protocol\PlayerListPacket as �;use
pocketmine\network\mcpe\protocol\PlayerSkinPacket as �;use
pocketmine\network\mcpe\protocol\ProtocolInfo as �;use
pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties as �;use
pocketmine\network\mcpe\protocol\types\entity\StringMetadataProperty as �;use
pocketmine\network\mcpe\protocol\types\PlayerListEntry as �;use
pocketmine\player\Player as �;use
pocketmine\utils\Limits as �;use
pocketmine\utils\UUID as �;use
pocketmine\world\sound\TotemUseSound as �;use
pocketmine\world\World as �;use
function
array_filter as �;use
function
array_merge as �;use
function
array_values as �;use
function
in_array as �;use
function
min as �;use
function
random_int as �;use
function
strlen as �;class
Human
extends
Living
implements
�,唟protected$inventory;protected$offHandInventory;protected$enderChestInventory;protected$uuid;public$width=0.6;public$height=1.8;public$eyeHeight=1.62;protected$skin;protected$hungerManager;protected$xpManager;protected$xpSeed;protected$baseOffset=1.62;public
function
__construct(�$€,�$�){if($this->skin===\null){$�=$�->getCompoundTag("Skin");if($�===\null){throw
new\InvalidStateException((new\ReflectionClass($this))->getShortName()." must have a valid skin set");}$this->skin=new
Skin($�->getString("Name"),$�->hasTag("Data",�::class)?$�->getString("Data"):$�->getByteArray("Data"),$�->getByteArray("CapeData",""),$�->getString("GeometryName",""),$�->getByteArray("GeometryData",""));}parent::__construct($€,$�);}public
static
function
isValidSkin(string$�):bool{return
�(�($�),Skin::ACCEPTED_SKIN_SIZES,\true);}public
function
getUniqueId():瀧return$this->uuid;}public
function
getSkin():Skin{return$this->skin;}public
function
setSkin(Skin$�):void{$this->skin=$�;}public
function
sendSkin(?array$�=\null):void{$�=$�
??$this->hasSpawned;foreach($�
as$�){if($�->getNetworkSession()->getPlayerProtocol()<�::PROTOCOL_130){if($�
!==$this){$this->despawnFrom($�);}$�->getNetworkSession()->sendDataPacket(�::remove([�::createRemovalEntry($this->uuid)]));$�->getNetworkSession()->sendDataPacket(�::add([�::createAdditionEntry($this->uuid,$this->id,$this->getName(),$this->skin)]));if($�
!==$this){$this->spawnTo($�);}}else{$�=new
�();$�->uuid=$this->getUniqueId();$�->skin=$this->skin;$�->getNetworkSession()->sendDataPacket($�);}}}public
function
jump():void{parent::jump();if($this->isSprinting()){$this->hungerManager->exhaust(0.8,�::CAUSE_SPRINT_JUMPING);}else{$this->hungerManager->exhaust(0.2,�::CAUSE_JUMPING);}}public
function
getHungerManager():HungerManager{return$this->hungerManager;}public
function
consumeObject(�$�):bool{if($�
instanceof
�){if($�->requiresHunger()&&!$this->hungerManager->isHungry()){return\false;}$this->hungerManager->addFood($�->getFoodRestore());$this->hungerManager->addSaturation($�->getSaturationRestore());}return
parent::consumeObject($�);}public
function
getXpManager():ExperienceManager{return$this->xpManager;}public
function
getXpDropAmount():int{return
�(0x64,0x7*$this->xpManager->getXpLevel());}public
function
getInventory(){return$this->inventory;}public
function
getOffHandInventory():坽return$this->offHandInventory;}public
function
getEnderChestInventory():厈return$this->enderChestInventory;}protected
function
initHumanData(�$�):void{if($�->hasTag("NameTag",�::class)){$this->setNameTag($�->getString("NameTag"));}$this->uuid=�::fromData((string)$this->getId(),$this->skin->getSkinData(),$this->getNameTag());}protected
function
initEntity(�$�):void{parent::initEntity($�);$this->hungerManager=new
HungerManager($this);$this->xpManager=new
ExperienceManager($this);$this->inventory=new
�($this);$this->offHandInventory=new
�($this);$this->enderChestInventory=new
�();$this->initHumanData($�);$�=$�->getListTag("Inventory");if($�
!==\null){$�=$this->armorInventory->getChangeListeners();$this->armorInventory->removeChangeListeners(...$�);foreach($�
as$�=>$�){$�=$�->getByte("Slot");if($�
>=
0x0&&$�<0x9){$this->inventory->setHotbarSlotIndex($�,$�->getByte("TrueSlot",$�));}elseif($�
>=
0x64&&$�<0x68){$this->armorInventory->setItem($�-0x64,�::nbtDeserialize($�));}elseif($�
>=
0x9&&$�<$this->inventory->getSize()+0x9){$this->inventory->setItem($�-0x9,�::nbtDeserialize($�));}}$this->armorInventory->addChangeListeners(...$�);}$�=$�->getListTag("EnderChestInventory");if($�
!==\null){foreach($�
as$�=>$�){$this->enderChestInventory->setItem($�->getByte("Slot"),�::nbtDeserialize($�));}}$�=$�->getCompoundTag("OffHand");if($�
!==\null){$this->offHandInventory->setItemInHand(�::nbtDeserialize($�));}$this->inventory->setHeldItemIndex($�->getInt("SelectedInventorySlot",0x0),\false);$this->hungerManager->setFood((float)$�->getInt("foodLevel",(int)$this->hungerManager->getFood()));$this->hungerManager->setExhaustion($�->getFloat("foodExhaustionLevel",$this->hungerManager->getExhaustion()));$this->hungerManager->setSaturation($�->getFloat("foodSaturationLevel",$this->hungerManager->getSaturation()));$this->hungerManager->setFoodTickTimer($�->getInt("foodTickTimer",$this->hungerManager->getFoodTickTimer()));$this->xpManager->setXpAndProgressNoEvent($�->getInt("XpLevel",0x0),$�->getFloat("XpP",0.0));$this->xpManager->setLifetimeTotalXp($�->getInt("XpTotal",0x0));if($�->hasTag("XpSeed",�::class)){$this->xpSeed=$�->getInt("XpSeed");}else{$this->xpSeed=�(�::INT32_MIN,�::INT32_MAX);}}protected
function
entityBaseTick(int$�=0x1):bool{$�=parent::entityBaseTick($�);$this->hungerManager->tick($�);$this->xpManager->tick($�);return$�;}public
function
getName():string{return$this->getNameTag();}public
function
applyDamageModifiers(�$�):void{parent::applyDamageModifiers($�);$�=$�->getCause();if($�
!==
�::CAUSE_SUICIDE&&$�
!==
�::CAUSE_VOID&&($this->offHandInventory->getItemInHand()instanceof
峾|$this->inventory->getItemInHand()instanceof
�)){$�=$this->getHealth()-$�->getFinalDamage()-0x1;if($�<0x0){$�->setModifier($�,�::MODIFIER_TOTEM);}}}protected
function
applyPostDamageEffects(�$�):void{parent::applyPostDamageEffects($�);$�=$�->getModifier(�::MODIFIER_TOTEM);if($�<0x0){$this->effectManager->clear();$this->effectManager->add(new
€(�::REGENERATION(),0x28*0x14,0x1));$this->effectManager->add(new
€(�::FIRE_RESISTANCE(),0x28*0x14,0x1));$this->effectManager->add(new
€(�::ABSORPTION(),0x5*0x14,0x1));$this->broadcastEntityEvent(�::CONSUME_TOTEM);$this->getWorld()->addSound($this->location->add(0x0,$this->eyeHeight,0x0),new
�());$�=$this->offHandInventory->getItemInHand();if($�
instanceof
�){$�->pop();$this->offHandInventory->setItemInHand($�);}else{$�=$this->inventory->getItemInHand();if($�
instanceof
�){$�->pop();$this->inventory->setItemInHand($�);}}}}public
function
getDrops():array{return
�(�($this->inventory
!==\null?�($this->inventory->getContents()):[],$this->offHandInventory
!==\null?�($this->offHandInventory->getContents()):[],$this->armorInventory
!==\null?�($this->armorInventory->getContents()):[]),function(�$�):bool{return!$�->hasEnchantment(�::VANISHING());});}public
function
saveNBT():弡$�=parent::saveNBT();$�->setInt("foodLevel",(int)$this->hungerManager->getFood());$�->setFloat("foodExhaustionLevel",$this->hungerManager->getExhaustion());$�->setFloat("foodSaturationLevel",$this->hungerManager->getSaturation());$�->setInt("foodTickTimer",$this->hungerManager->getFoodTickTimer());$�->setInt("XpLevel",$this->xpManager->getXpLevel());$�->setFloat("XpP",$this->xpManager->getXpProgress());$�->setInt("XpTotal",$this->xpManager->getLifetimeTotalXp());$�->setInt("XpSeed",$this->xpSeed);$�=new
�([],�::TAG_Compound);$�->setTag("Inventory",$�);if($this->inventory
!==\null){for($�=0x0;$�<$this->inventory->getHotbarSize();++$�){$�=$this->inventory->getHotbarSlotIndex($�);$�=$this->inventory->getItem($�);$�->push($�->nbtSerialize($�)->setByte("TrueSlot",$�));}$�=$this->inventory->getSize()+$this->inventory->getHotbarSize();for($�=$this->inventory->getHotbarSize();$�<$�;++$�){$�=$this->inventory->getItem($�-0x9);if(!$�->isNull()){$�->push($�->nbtSerialize($�));}}for($�=0x64;$�<0x68;++$�){$�=$this->armorInventory->getItem($�-0x64);if(!$�->isNull()){$�->push($�->nbtSerialize($�));}}$�->setInt("SelectedInventorySlot",$this->inventory->getHeldItemIndex());}if($this->offHandInventory
!==\null){$�->setTag("OffHand",$this->offHandInventory->getItemInHand()->nbtSerialize(0x0));}if($this->enderChestInventory
!==\null){$�=[];$�=$this->enderChestInventory->getSize();for($�=0x0;$�<$�;++$�){$�=$this->enderChestInventory->getItem($�);if(!$�->isNull()){$榌]=$�->nbtSerialize($�);}}$�->setTag("EnderChestInventory",new
�($�,�::TAG_Compound));}if($this->skin
!==\null){$�->setTag("Skin",�::create()->setString("Name",$this->skin->getSkinId())->setByteArray("Data",$this->skin->getSkinData())->setByteArray("CapeData",$this->skin->getCapeData())->setString("GeometryName",$this->skin->getGeometryName())->setByteArray("GeometryData",$this->skin->getGeometryData()));}return$�;}public
function
spawnTo(�$�):void{if($�
!==$this){parent::spawnTo($�);}}protected
function
sendSpawnPacket(�$�):void{if(!($this
instanceof
�)){$�->getNetworkSession()->sendDataPacket(�::add([�::createAdditionEntry($this->uuid,$this->id,$this->getName(),$this->skin)]));}$�=new
�();$�->uuid=$this->getUniqueId();$�->username=$this->getName();$�->entityRuntimeId=$this->getId();$�->position=$this->location->asVector3();$�->motion=$this->getMotion();$�->yaw=$this->location->yaw;$�->pitch=$this->location->pitch;$�->item=$this->getInventory()->getItemInHand();$�->metadata=$this->getSyncedNetworkData(\false);$�->getNetworkSession()->sendDataPacket($�);if($�->getNetworkSession()->getPlayerProtocol()>=
�::PROTOCOL_220){$this->sendData($�,[�::NAMETAG=>new
�($this->getNameTag())]);}$�->getNetworkSession()->onMobArmorChange($this);if(!($this
instanceof
�)){$�->getNetworkSession()->sendDataPacket(�::remove([�::createRemovalEntry($this->uuid)]));}}public
function
broadcastMovement(bool$�=\false):void{$�=new
�();$�->entityRuntimeId=$this->getId();$�->position=$this->getOffsetPosition($this->location);$�->yaw=$this->location->yaw;$�->pitch=$this->location->pitch;$�->headYaw=$this->location->yaw;$�->mode=$�?�::MODE_TELEPORT:�::MODE_NORMAL;$this->server->broadcastPackets($this->hasSpawned,[$哴);}protected
function
onDispose():void{$this->inventory->removeAllViewers();$this->offHandInventory->removeAllViewers();$this->enderChestInventory->removeAllViewers();parent::onDispose();}protected
function
destroyCycles():void{$this->inventory=\null;$this->offHandInventory=\null;$this->enderChestInventory=\null;$this->hungerManager=\null;$this->xpManager=\null;parent::destroyCycles();}}
© 2023 Quttera Ltd. All rights reserved.