summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-01 21:05:45 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-01 21:05:45 +0200
commitdfed6f94ca78f2e104ed316d83400b0ca74cb79a (patch)
treed00547328b70bbb4a4ea5d713f6ffe8e3a48ee12 /src/Mobs
parentAdded CustomName to cMonster. (diff)
downloadcuberite-dfed6f94ca78f2e104ed316d83400b0ca74cb79a.tar
cuberite-dfed6f94ca78f2e104ed316d83400b0ca74cb79a.tar.gz
cuberite-dfed6f94ca78f2e104ed316d83400b0ca74cb79a.tar.bz2
cuberite-dfed6f94ca78f2e104ed316d83400b0ca74cb79a.tar.lz
cuberite-dfed6f94ca78f2e104ed316d83400b0ca74cb79a.tar.xz
cuberite-dfed6f94ca78f2e104ed316d83400b0ca74cb79a.tar.zst
cuberite-dfed6f94ca78f2e104ed316d83400b0ca74cb79a.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Monster.cpp19
-rw-r--r--src/Mobs/Monster.h2
-rw-r--r--src/Mobs/Sheep.cpp2
3 files changed, 23 insertions, 0 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 6a477ca1c..a89fa32a3 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -553,6 +553,25 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
+void cMonster::OnRightClicked(cPlayer & a_Player)
+{
+ super::OnRightClicked(a_Player);
+
+ const cItem & EquippedItem = a_Player.GetEquippedItem();
+ if ((EquippedItem.m_ItemType == E_ITEM_NAME_TAG) && !EquippedItem.m_CustomName.empty())
+ {
+ SetCustomName(EquippedItem.m_CustomName);
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ }
+ }
+}
+
+
+
+
+
// Checks to see if EventSeePlayer should be fired
// monster sez: Do I see the player
void cMonster::CheckEventSeePlayer(void)
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index ce4e36a46..f14a4f100 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -92,6 +92,8 @@ public:
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+ virtual void OnRightClicked(cPlayer & a_Player) override;
+
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
virtual bool ReachedDestination(void);
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index 9fb47201d..ee3236bba 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -47,6 +47,8 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSheep::OnRightClicked(cPlayer & a_Player)
{
+ super::OnRightClicked(a_Player);
+
const cItem & EquippedItem = a_Player.GetEquippedItem();
if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && !IsSheared() && !IsBaby())
{