summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2017-08-17 16:29:43 +0200
committerMattes D <github@xoft.cz>2017-08-17 16:29:43 +0200
commit05045860c2002e3c9a79d90290f4d65fdd171141 (patch)
tree0265750956435f284d5b9c499dbbe5c90231db73
parentAdd cLuaWindow OnClicked Callback (#3901) (diff)
downloadcuberite-05045860c2002e3c9a79d90290f4d65fdd171141.tar
cuberite-05045860c2002e3c9a79d90290f4d65fdd171141.tar.gz
cuberite-05045860c2002e3c9a79d90290f4d65fdd171141.tar.bz2
cuberite-05045860c2002e3c9a79d90290f4d65fdd171141.tar.lz
cuberite-05045860c2002e3c9a79d90290f4d65fdd171141.tar.xz
cuberite-05045860c2002e3c9a79d90290f4d65fdd171141.tar.zst
cuberite-05045860c2002e3c9a79d90290f4d65fdd171141.zip
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/ChestEntity.cpp26
-rw-r--r--src/BlockEntities/EnderChestEntity.cpp10
-rw-r--r--src/Mobs/Ocelot.cpp28
-rw-r--r--src/Mobs/Ocelot.h3
4 files changed, 42 insertions, 25 deletions
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index 54f6e0dfa..a8f5b7242 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -7,7 +7,6 @@
#include "../UI/ChestWindow.h"
#include "../ClientHandle.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()
{
- cFindSittingCat FindSittingCat;
return (
- (GetPosY() >= cChunkDef::Height - 1) ||
- !cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
+ (GetPosY() < cChunkDef::Height - 1) &&
(
- (GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ()) == E_BLOCK_AIR) &&
- !GetWorld()->ForEachEntityInBox(cBoundingBox(Vector3d(GetPosX(), GetPosY() + 1, GetPosZ()), 1, 1), FindSittingCat)
+ !cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
+ !cOcelot::IsCatSittingOnBlock(GetWorld(), Vector3d(GetPos()))
)
);
}
diff --git a/src/BlockEntities/EnderChestEntity.cpp b/src/BlockEntities/EnderChestEntity.cpp
index 9030a0172..e475d7022 100644
--- a/src/BlockEntities/EnderChestEntity.cpp
+++ b/src/BlockEntities/EnderChestEntity.cpp
@@ -7,6 +7,7 @@
#include "../Entities/Player.h"
#include "../UI/EnderChestWindow.h"
#include "../ClientHandle.h"
+#include "../Mobs/Ocelot.h"
@@ -48,8 +49,13 @@ void cEnderChestEntity::SendTo(cClientHandle & a_Client)
bool cEnderChestEntity::UsedBy(cPlayer * a_Player)
{
- // TODO: cats are an obstruction
- if ((GetPosY() < cChunkDef::Height - 1) && !cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())))
+ if (
+ (GetPosY() < cChunkDef::Height - 1) &&
+ (
+ !cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
+ !cOcelot::IsCatSittingOnBlock(GetWorld(), Vector3d(GetPos()))
+ )
+ )
{
// Obstruction, don't open
return false;
diff --git a/src/Mobs/Ocelot.cpp b/src/Mobs/Ocelot.cpp
index 47776670c..e5004a1d1 100644
--- a/src/Mobs/Ocelot.cpp
+++ b/src/Mobs/Ocelot.cpp
@@ -6,6 +6,7 @@
#include "../Entities/Player.h"
#include "../Items/ItemHandler.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);
+}
+
+
+
+
diff --git a/src/Mobs/Ocelot.h b/src/Mobs/Ocelot.h
index 5729851fe..59b4f25af 100644
--- a/src/Mobs/Ocelot.h
+++ b/src/Mobs/Ocelot.h
@@ -54,6 +54,9 @@ public:
}
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:
bool m_IsSitting;