summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2017-07-01 14:36:43 +0200
committerLukas Pioch <lukas@zgow.de>2017-07-02 07:38:41 +0200
commit445abe001ab74e18035fce6c741f7ef829dca419 (patch)
tree60711d9798856ef3a648cf8034495a17f4476919 /src
parentEndermen take damage from rain (diff)
downloadcuberite-445abe001ab74e18035fce6c741f7ef829dca419.tar
cuberite-445abe001ab74e18035fce6c741f7ef829dca419.tar.gz
cuberite-445abe001ab74e18035fce6c741f7ef829dca419.tar.bz2
cuberite-445abe001ab74e18035fce6c741f7ef829dca419.tar.lz
cuberite-445abe001ab74e18035fce6c741f7ef829dca419.tar.xz
cuberite-445abe001ab74e18035fce6c741f7ef829dca419.tar.zst
cuberite-445abe001ab74e18035fce6c741f7ef829dca419.zip
Diffstat (limited to 'src')
-rw-r--r--src/Mobs/PassiveMonster.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index 5646f8e32..02e16d22f 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -5,6 +5,7 @@
#include "../World.h"
#include "../Entities/Player.h"
#include "BoundingBox.h"
+#include "../Items/ItemSpawnEgg.h"
@@ -223,13 +224,14 @@ void cPassiveMonster::OnRightClicked(cPlayer & a_Player)
{
super::OnRightClicked(a_Player);
+ const cItem & EquippedItem = a_Player.GetEquippedItem();
+
// If a player holding breeding items right-clicked me, go into love mode
if ((m_LoveCooldown == 0) && !IsInLove() && !IsBaby())
{
- short HeldItem = a_Player.GetEquippedItem().m_ItemType;
cItems Items;
GetBreedingItems(Items);
- if (Items.ContainsType(HeldItem))
+ if (Items.ContainsType(EquippedItem.m_ItemType))
{
if (!a_Player.IsGameModeCreative())
{
@@ -239,6 +241,22 @@ void cPassiveMonster::OnRightClicked(cPlayer & a_Player)
m_World->BroadcastEntityStatus(*this, esMobInLove);
}
}
+ // If a player holding my spawn egg right-clicked me, spawn a new baby
+ if (EquippedItem.m_ItemType == E_ITEM_SPAWN_EGG)
+ {
+ eMonsterType MonsterType = cItemSpawnEggHandler::ItemDamageToMonsterType(EquippedItem.m_ItemDamage);
+ if (
+ (MonsterType == m_MobType) &&
+ (GetWorld()->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), m_MobType, true) != cEntity::INVALID_ID) // Spawning succeeded
+ )
+ {
+ if (!a_Player.IsGameModeCreative())
+ {
+ // The mob was spawned, "use" the item:
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ }
+ }
+ }
}