diff options
Diffstat (limited to 'src/Mobs')
-rw-r--r-- | src/Mobs/Chicken.h | 5 | ||||
-rw-r--r-- | src/Mobs/Cow.h | 5 | ||||
-rw-r--r-- | src/Mobs/Mooshroom.h | 5 | ||||
-rw-r--r-- | src/Mobs/PassiveMonster.cpp | 8 | ||||
-rw-r--r-- | src/Mobs/PassiveMonster.h | 5 | ||||
-rw-r--r-- | src/Mobs/Pig.h | 5 | ||||
-rw-r--r-- | src/Mobs/Rabbit.h | 7 | ||||
-rw-r--r-- | src/Mobs/Sheep.h | 5 |
8 files changed, 33 insertions, 12 deletions
diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h index 05cf0ed39..ca70657b4 100644 --- a/src/Mobs/Chicken.h +++ b/src/Mobs/Chicken.h @@ -19,7 +19,10 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); } + virtual void GetFollowedItems(cItems & a_Items) override + { + a_Items.Add(E_ITEM_SEEDS); + } virtual void HandleFalling(void) override; diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h index ee1a4fafe..6ce51e806 100644 --- a/src/Mobs/Cow.h +++ b/src/Mobs/Cow.h @@ -20,7 +20,10 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void OnRightClicked(cPlayer & a_Player) override; - virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } + virtual void GetFollowedItems(cItems & a_Items) override + { + a_Items.Add(E_ITEM_WHEAT); + } } ; diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h index 754725c92..61cbfc083 100644 --- a/src/Mobs/Mooshroom.h +++ b/src/Mobs/Mooshroom.h @@ -20,7 +20,10 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void OnRightClicked(cPlayer & a_Player) override; - virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } + virtual void GetFollowedItems(cItems & a_Items) override + { + a_Items.Add(E_ITEM_WHEAT); + } } ; diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index c220a7128..a3d51da35 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -43,15 +43,17 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { CheckEventLostPlayer(); } - cItem FollowedItem = GetFollowedItem(); - if (FollowedItem.IsEmpty()) + cItems FollowedItems; + GetFollowedItems(FollowedItems); + if (FollowedItems.Size() <= 0) { return; } cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance)); if (a_Closest_Player != nullptr) { - if (a_Closest_Player->GetEquippedItem().IsEqual(FollowedItem)) + cItem EquippedItem = a_Closest_Player->GetEquippedItem(); + if (FollowedItems.ContainsType(EquippedItem)) { Vector3d PlayerPos = a_Closest_Player->GetPosition(); MoveToPosition(PlayerPos); diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h index 7f20c3092..a7e574a1d 100644 --- a/src/Mobs/PassiveMonster.h +++ b/src/Mobs/PassiveMonster.h @@ -20,9 +20,8 @@ public: /** When hit by someone, run away */ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; - /** Returns the item that the animal of this class follows when a player holds it in hand - Return an empty item not to follow (default). */ - virtual const cItem GetFollowedItem(void) const { return cItem(); } + /** Returns the items that the animal of this class follows when a player holds it in hand. */ + virtual void GetFollowedItems(cItems & a_Items) { } } ; diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index 0fe4b4fed..56c9f7ed6 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -24,7 +24,10 @@ public: virtual void OnRightClicked(cPlayer & a_Player) override; virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); } + virtual void GetFollowedItems(cItems & a_Items) override + { + a_Items.Add(E_ITEM_CARROT); + } bool IsSaddled(void) const { return m_bIsSaddled; } diff --git a/src/Mobs/Rabbit.h b/src/Mobs/Rabbit.h index 56181e3d0..79a9afe15 100644 --- a/src/Mobs/Rabbit.h +++ b/src/Mobs/Rabbit.h @@ -34,7 +34,12 @@ public: CLASS_PROTODEF(cRabbit) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); } + virtual void GetFollowedItems(cItems & a_Items) override + { + a_Items.Add(E_ITEM_CARROT); + a_Items.Add(E_ITEM_GOLDEN_CARROT); + a_Items.Add(E_BLOCK_DANDELION); + } eRabbitType GetRabbitType() const { return m_Type; } UInt8 GetRabbitTypeAsNumber() const { return static_cast<UInt8>(GetRabbitType()); } diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index b6c99ac2a..ff7632eb7 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -26,7 +26,10 @@ public: virtual void OnRightClicked(cPlayer & a_Player) override; virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } + virtual void GetFollowedItems(cItems & a_Items) override + { + a_Items.Add(E_ITEM_WHEAT); + } /** Generates a random color for the sheep like the vanilla server. The percent's where used are from the wiki: http://minecraft.gamepedia.com/Sheep#Breeding */ |