Added some wrapper methods to make data flags less of a pain in the ass to work with

This commit is contained in:
Dylan K. Taylor
2017-08-17 16:52:17 +01:00
parent 83af4dcd59
commit e825ebd8fa
10 changed files with 75 additions and 35 deletions

View File

@ -283,7 +283,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
protected function initEntity(){
$this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false, self::DATA_TYPE_BYTE);
$this->setPlayerFlag(self::DATA_PLAYER_FLAG_SLEEP, false);
$this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0], false);
$this->inventory = new PlayerInventory($this);
@ -542,4 +542,24 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
parent::close();
}
}
/**
* Wrapper around {@link Entity#getDataFlag} for player-specific data flag reading.
*
* @param int $flagId
* @return bool
*/
public function getPlayerFlag(int $flagId){
return $this->getDataFlag(self::DATA_PLAYER_FLAGS, $flagId);
}
/**
* Wrapper around {@link Entity#setDataFlag} for player-specific data flag setting.
*
* @param int $flagId
* @param bool $value
*/
public function setPlayerFlag(int $flagId, bool $value = true){
$this->setDataFlag(self::DATA_PLAYER_FLAGS, $flagId, $value, self::DATA_TYPE_BYTE);
}
}