From bfc77a772a8abfaee5e7a5f456ce9ed224e994c2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 25 Oct 2016 10:43:37 +0100 Subject: [PATCH] New entity data flags @Intyre, you are beyond awesome --- src/pocketmine/entity/Ageable.php | 4 --- src/pocketmine/entity/Animal.php | 9 +------ src/pocketmine/entity/Entity.php | 36 +++++++++++++++++++-------- src/pocketmine/entity/Living.php | 2 +- src/pocketmine/entity/Villager.php | 2 +- src/pocketmine/entity/WaterAnimal.php | 8 +----- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/pocketmine/entity/Ageable.php b/src/pocketmine/entity/Ageable.php index 7067af087..ced02e42b 100644 --- a/src/pocketmine/entity/Ageable.php +++ b/src/pocketmine/entity/Ageable.php @@ -23,9 +23,5 @@ namespace pocketmine\entity; interface Ageable{ - const DATA_AGEABLE_FLAGS = 14; - - const DATA_FLAG_BABY = 0; - public function isBaby(); } \ No newline at end of file diff --git a/src/pocketmine/entity/Animal.php b/src/pocketmine/entity/Animal.php index 18bff79dc..07cae3319 100644 --- a/src/pocketmine/entity/Animal.php +++ b/src/pocketmine/entity/Animal.php @@ -24,14 +24,7 @@ namespace pocketmine\entity; abstract class Animal extends Creature implements Ageable{ - public function initEntity(){ - parent::initEntity(); - if($this->getDataProperty(self::DATA_AGEABLE_FLAGS) === null){ - $this->setDataProperty(self::DATA_AGEABLE_FLAGS, self::DATA_TYPE_BYTE, 0); - } - } - public function isBaby(){ - return $this->getDataFlag(self::DATA_AGEABLE_FLAGS, self::DATA_FLAG_BABY); + return $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_BABY); } } \ No newline at end of file diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index b90eae603..82ca656ff 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -62,10 +62,8 @@ use pocketmine\Server; abstract class Entity extends Location implements Metadatable{ - const NETWORK_ID = -1; - const DATA_TYPE_BYTE = 0; const DATA_TYPE_SHORT = 1; const DATA_TYPE_INT = 2; @@ -110,10 +108,6 @@ abstract class Entity extends Location implements Metadatable{ * 57 (byte) * 58 (float) * 59 (float) */ - - /* - const DATA_SILENT = 4; - */ const DATA_FLAG_ONFIRE = 0; @@ -122,13 +116,33 @@ abstract class Entity extends Location implements Metadatable{ const DATA_FLAG_SPRINTING = 3; const DATA_FLAG_ACTION = 4; const DATA_FLAG_INVISIBLE = 5; - + const DATA_FLAG_TEMPTED = 6; //??? + const DATA_FLAG_INLOVE = 7; + const DATA_FLAG_SADDLED = 8; + const DATA_FLAG_POWERED = 9; + const DATA_FLAG_IGNITED = 10; //for creepers? + const DATA_FLAG_BABY = 11; + const DATA_FLAG_CONVERTING = 12; //??? + const DATA_FLAG_CRITICAL = 13; const DATA_FLAG_CAN_SHOW_NAMETAG = 14; const DATA_FLAG_ALWAYS_SHOW_NAMETAG = 15; - const DATA_FLAG_IMMOBILE = 16; - - const DATA_FLAG_NOT_UNDERWATER = 30; //Hide bubbles if not underwater - + const DATA_FLAG_IMMOBILE = 16, DATA_FLAG_NO_AI = 16; + const DATA_FLAG_SILENT = 17; + const DATA_FLAG_WALLCLIMBING = 18; + const DATA_FLAG_RESTING = 19; //for bats? + const DATA_FLAG_SITTING = 20; + const DATA_FLAG_ANGRY = 21; + const DATA_FLAG_INTERESTED = 22; //for mobs following players with food? + const DATA_FLAG_CHARGED = 23; + const DATA_FLAG_TAMED = 24; + const DATA_FLAG_LEASHED = 25; + const DATA_FLAG_SHEARED = 26; //for sheep + const DATA_FLAG_FALL_FLYING = 27; //??? + const DATA_FLAG_ELDER = 28; //elder guardian + const DATA_FLAG_MOVING = 29; + const DATA_FLAG_BREATHING = 30; //hides bubbles if true + const DATA_FLAG_CHESTED = 31; //for mules? + const DATA_FLAG_STACKABLE = 32; //??? public static $entityCount = 1; /** @var Entity[] */ diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 1a1e7ebc8..4b5c7195f 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -178,7 +178,7 @@ abstract class Living extends Entity implements Damageable{ public function entityBaseTick($tickDiff = 1){ Timings::$timerLivingEntityBaseTick->startTiming(); - $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_NOT_UNDERWATER, !$this->isInsideOfWater()); + $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_BREATHING, !$this->isInsideOfWater()); $hasUpdate = parent::entityBaseTick($tickDiff); diff --git a/src/pocketmine/entity/Villager.php b/src/pocketmine/entity/Villager.php index 287341d99..00375f25b 100644 --- a/src/pocketmine/entity/Villager.php +++ b/src/pocketmine/entity/Villager.php @@ -82,6 +82,6 @@ class Villager extends Creature implements NPC, Ageable{ } public function isBaby(){ - return $this->getDataFlag(self::DATA_AGEABLE_FLAGS, self::DATA_FLAG_BABY); + return $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_BABY); } } diff --git a/src/pocketmine/entity/WaterAnimal.php b/src/pocketmine/entity/WaterAnimal.php index cfb2b033a..7520f16ea 100644 --- a/src/pocketmine/entity/WaterAnimal.php +++ b/src/pocketmine/entity/WaterAnimal.php @@ -22,14 +22,8 @@ namespace pocketmine\entity; abstract class WaterAnimal extends Creature implements Ageable{ - public function initEntity(){ - parent::initEntity(); - if($this->getDataProperty(self::DATA_AGEABLE_FLAGS) === null){ - $this->setDataProperty(self::DATA_AGEABLE_FLAGS, self::DATA_TYPE_BYTE, 0); - } - } public function isBaby(){ - return $this->getDataFlag(self::DATA_AGEABLE_FLAGS, self::DATA_FLAG_BABY); + return $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_BABY); } }