Sitting cats block enderchests from opening (#3906)
This commit is contained in:
parent
1ec85a2b2c
commit
05045860c2
@ -7,7 +7,6 @@
|
|||||||
#include "../UI/ChestWindow.h"
|
#include "../UI/ChestWindow.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
#include "../Mobs/Ocelot.h"
|
#include "../Mobs/Ocelot.h"
|
||||||
#include "../BoundingBox.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -219,32 +218,13 @@ void cChestEntity::DestroyWindow()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cFindSittingCat :
|
|
||||||
public cEntityCallback
|
|
||||||
{
|
|
||||||
virtual bool Item(cEntity * a_Entity) override
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
(a_Entity->GetEntityType() == cEntity::etMonster) &&
|
|
||||||
(static_cast<cMonster *>(a_Entity)->GetMobType() == eMonsterType::mtOcelot) &&
|
|
||||||
(static_cast<cOcelot *>(a_Entity)->IsSitting())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChestEntity::IsBlocked()
|
bool cChestEntity::IsBlocked()
|
||||||
{
|
{
|
||||||
cFindSittingCat FindSittingCat;
|
|
||||||
return (
|
return (
|
||||||
(GetPosY() >= cChunkDef::Height - 1) ||
|
(GetPosY() < cChunkDef::Height - 1) &&
|
||||||
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
|
|
||||||
(
|
(
|
||||||
(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ()) == E_BLOCK_AIR) &&
|
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
|
||||||
!GetWorld()->ForEachEntityInBox(cBoundingBox(Vector3d(GetPosX(), GetPosY() + 1, GetPosZ()), 1, 1), FindSittingCat)
|
!cOcelot::IsCatSittingOnBlock(GetWorld(), Vector3d(GetPos()))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../UI/EnderChestWindow.h"
|
#include "../UI/EnderChestWindow.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
|
#include "../Mobs/Ocelot.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -48,8 +49,13 @@ void cEnderChestEntity::SendTo(cClientHandle & a_Client)
|
|||||||
|
|
||||||
bool cEnderChestEntity::UsedBy(cPlayer * a_Player)
|
bool cEnderChestEntity::UsedBy(cPlayer * a_Player)
|
||||||
{
|
{
|
||||||
// TODO: cats are an obstruction
|
if (
|
||||||
if ((GetPosY() < cChunkDef::Height - 1) && !cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())))
|
(GetPosY() < cChunkDef::Height - 1) &&
|
||||||
|
(
|
||||||
|
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
|
||||||
|
!cOcelot::IsCatSittingOnBlock(GetWorld(), Vector3d(GetPos()))
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Obstruction, don't open
|
// Obstruction, don't open
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../Items/ItemHandler.h"
|
#include "../Items/ItemHandler.h"
|
||||||
#include "Broadcaster.h"
|
#include "Broadcaster.h"
|
||||||
|
#include "../BoundingBox.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -203,3 +204,30 @@ void cOcelot::SpawnOn(cClientHandle & a_ClientHandle)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cFindSittingCat :
|
||||||
|
public cEntityCallback
|
||||||
|
{
|
||||||
|
virtual bool Item(cEntity * a_Entity) override
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
(a_Entity->GetEntityType() == cEntity::etMonster) &&
|
||||||
|
(static_cast<cMonster *>(a_Entity)->GetMobType() == eMonsterType::mtOcelot) &&
|
||||||
|
(static_cast<cOcelot *>(a_Entity)->IsSitting())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cOcelot::IsCatSittingOnBlock(cWorld * a_World, Vector3d a_BlockPosition)
|
||||||
|
{
|
||||||
|
cFindSittingCat FindSittingCat;
|
||||||
|
return a_World->ForEachEntityInBox(cBoundingBox(Vector3d(a_BlockPosition.x, a_BlockPosition.y + 1, a_BlockPosition.z), 1), FindSittingCat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +54,9 @@ public:
|
|||||||
}
|
}
|
||||||
void SetCatType (eCatType a_CatType) { m_CatType = a_CatType; }
|
void SetCatType (eCatType a_CatType) { m_CatType = a_CatType; }
|
||||||
|
|
||||||
|
/** Returns true if there's a cat sitting above the given position */
|
||||||
|
static bool IsCatSittingOnBlock(cWorld * a_World, Vector3d a_BlockPosition);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool m_IsSitting;
|
bool m_IsSitting;
|
||||||
|
Loading…
Reference in New Issue
Block a user