From 6a1984112146a14c96f43e9cdf758f5104d6d2a3 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Wed, 12 Jul 2017 12:42:02 +0200 Subject: Added basic ocelot behavior (#3829) --- src/BlockEntities/ChestEntity.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index a4576b66d..54f6e0dfa 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -6,6 +6,8 @@ #include "../Entities/Player.h" #include "../UI/ChestWindow.h" #include "../ClientHandle.h" +#include "../Mobs/Ocelot.h" +#include "../BoundingBox.h" @@ -217,11 +219,36 @@ void cChestEntity::DestroyWindow() +class cFindSittingCat : + public cEntityCallback +{ + virtual bool Item(cEntity * a_Entity) override + { + return ( + (a_Entity->GetEntityType() == cEntity::etMonster) && + (static_cast(a_Entity)->GetMobType() == eMonsterType::mtOcelot) && + (static_cast(a_Entity)->IsSitting()) + ); + } +}; + + + + + bool cChestEntity::IsBlocked() { - // TODO: cats are an obstruction + cFindSittingCat FindSittingCat; return ( (GetPosY() >= cChunkDef::Height - 1) || - !cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) + !cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) || + ( + (GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ()) == E_BLOCK_AIR) && + !GetWorld()->ForEachEntityInBox(cBoundingBox(Vector3d(GetPosX(), GetPosY() + 1, GetPosZ()), 1, 1), FindSittingCat) + ) ); } + + + + -- cgit v1.2.3