summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--src/Entities/Boat.cpp2
-rw-r--r--src/Entities/Entity.h2
-rw-r--r--src/Entities/ItemFrame.cpp2
-rw-r--r--src/Entities/Minecart.cpp5
-rw-r--r--src/Mobs/Monster.cpp19
-rw-r--r--src/Mobs/Monster.h2
-rw-r--r--src/Mobs/Sheep.cpp2
7 files changed, 31 insertions, 3 deletions
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index 8ff8866a1..328a70846 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -62,6 +62,8 @@ bool cBoat::DoTakeDamage(TakeDamageInfo & TDI)
void cBoat::OnRightClicked(cPlayer & a_Player)
{
+ super::OnRightClicked(a_Player);
+
if (m_Attachee != NULL)
{
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index b9c280b6b..774cdb062 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -447,7 +447,7 @@ public:
// tolua_end
/// Called when the specified player right-clicks this entity
- virtual void OnRightClicked(cPlayer &) {}
+ virtual void OnRightClicked(cPlayer & a_Player) {}
/// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy().
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL)
diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp
index 0bc10ec60..3ccb95998 100644
--- a/src/Entities/ItemFrame.cpp
+++ b/src/Entities/ItemFrame.cpp
@@ -22,6 +22,8 @@ cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_
void cItemFrame::OnRightClicked(cPlayer & a_Player)
{
+ super::OnRightClicked(a_Player);
+
if (!m_Item.IsEmpty())
{
// Item not empty, rotate, clipping values to zero to three inclusive
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index 1501eea84..5fabbb542 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -1072,6 +1072,8 @@ cRideableMinecart::cRideableMinecart(double a_X, double a_Y, double a_Z, const c
void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
{
+ super::OnRightClicked(a_Player);
+
if (m_Attachee != NULL)
{
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
@@ -1124,8 +1126,7 @@ void cMinecartWithChest::SetSlot(size_t a_Idx, const cItem & a_Item)
void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
{
- // Show the chest UI window to the player
- // TODO
+ // TODO: Show the chest UI window to the player
}
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())
{