mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 15:19:56 +00:00
Minor cleanup of Human->initEntity()
This commit is contained in:
parent
1d0f0a2999
commit
b4c2305c7f
@ -1758,6 +1758,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
return ($dot1 - $dot) >= -$maxDiff;
|
return ($dot1 - $dot) >= -$maxDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function initHumanData(){
|
||||||
|
//No need to do anything here, this data will be set from the login.
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function initEntity(){
|
||||||
|
parent::initEntity();
|
||||||
|
$this->addDefaultWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function processLogin(){
|
protected function processLogin(){
|
||||||
@ -3812,6 +3820,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
return $this->teleport($pos, $yaw, $pitch);
|
return $this->teleport($pos, $yaw, $pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function addDefaultWindows(){
|
||||||
|
$this->addWindow($this->getInventory(), ContainerIds::INVENTORY);
|
||||||
|
|
||||||
|
//TODO: more windows
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Inventory $inventory
|
* @param Inventory $inventory
|
||||||
*
|
*
|
||||||
@ -3841,7 +3855,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
if($forceId === null){
|
if($forceId === null){
|
||||||
$this->windowCnt = $cnt = max(ContainerIds::FIRST, ++$this->windowCnt % ContainerIds::LAST);
|
$this->windowCnt = $cnt = max(ContainerIds::FIRST, ++$this->windowCnt % ContainerIds::LAST);
|
||||||
}else{
|
}else{
|
||||||
$cnt = (int) $forceId;
|
$cnt = $forceId;
|
||||||
}
|
}
|
||||||
$this->windowIndex[$cnt] = $inventory;
|
$this->windowIndex[$cnt] = $inventory;
|
||||||
$this->windows->attach($inventory, $cnt);
|
$this->windows->attach($inventory, $cnt);
|
||||||
|
@ -281,25 +281,28 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For Human entities which are not players, sets their properties such as nametag, skin and UUID from NBT.
|
||||||
|
*/
|
||||||
|
protected function initHumanData(){
|
||||||
|
if(isset($this->namedtag->NameTag)){
|
||||||
|
$this->setNameTag($this->namedtag["NameTag"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof CompoundTag){
|
||||||
|
$this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Name"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->uuid = UUID::fromData((string) $this->getId(), $this->getSkinData(), $this->getNameTag());
|
||||||
|
}
|
||||||
|
|
||||||
protected function initEntity(){
|
protected function initEntity(){
|
||||||
|
|
||||||
$this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false, self::DATA_TYPE_BYTE);
|
$this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false, self::DATA_TYPE_BYTE);
|
||||||
$this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0], false);
|
$this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0], false);
|
||||||
|
|
||||||
$this->inventory = new PlayerInventory($this);
|
$this->inventory = new PlayerInventory($this);
|
||||||
if($this instanceof Player){
|
$this->initHumanData();
|
||||||
$this->addWindow($this->inventory, 0);
|
|
||||||
}else{
|
|
||||||
if(isset($this->namedtag->NameTag)){
|
|
||||||
$this->setNameTag($this->namedtag["NameTag"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof CompoundTag){
|
|
||||||
$this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Name"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->uuid = UUID::fromData((string) $this->getId(), $this->getSkinData(), $this->getNameTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof ListTag){
|
if(isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof ListTag){
|
||||||
foreach($this->namedtag->Inventory as $item){
|
foreach($this->namedtag->Inventory as $item){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user