When right-clicking on a passive mob with 'his' spawn egg spawn a baby
This commit is contained in:
parent
a944ac3b06
commit
445abe001a
@ -5,6 +5,7 @@
|
|||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "BoundingBox.h"
|
#include "BoundingBox.h"
|
||||||
|
#include "../Items/ItemSpawnEgg.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -223,13 +224,14 @@ void cPassiveMonster::OnRightClicked(cPlayer & a_Player)
|
|||||||
{
|
{
|
||||||
super::OnRightClicked(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 a player holding breeding items right-clicked me, go into love mode
|
||||||
if ((m_LoveCooldown == 0) && !IsInLove() && !IsBaby())
|
if ((m_LoveCooldown == 0) && !IsInLove() && !IsBaby())
|
||||||
{
|
{
|
||||||
short HeldItem = a_Player.GetEquippedItem().m_ItemType;
|
|
||||||
cItems Items;
|
cItems Items;
|
||||||
GetBreedingItems(Items);
|
GetBreedingItems(Items);
|
||||||
if (Items.ContainsType(HeldItem))
|
if (Items.ContainsType(EquippedItem.m_ItemType))
|
||||||
{
|
{
|
||||||
if (!a_Player.IsGameModeCreative())
|
if (!a_Player.IsGameModeCreative())
|
||||||
{
|
{
|
||||||
@ -239,6 +241,22 @@ void cPassiveMonster::OnRightClicked(cPlayer & a_Player)
|
|||||||
m_World->BroadcastEntityStatus(*this, esMobInLove);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user