I had an idea on how we could let the server know what the bounding boxes are for a block. We simply create a list of boundingboxes in the block handler. Here is kinda what I mean:
BlockHandler.h:
BlockHandler.cpp:
Then when the server needs to know if an entity is in a block it loops through the list and checks if the bounding boxes intersect with the bounding box of an entity. This method would be usefull for for example a cauldron since it's more like a hollow block.
EDIT:
Another idea is to let the blockhandler itself check if an entity is inside.
BlockHandler.h:
typedef std::vector<cBoundingBox> BoundingBoxes; /// Returns a list of bounding boxes. For example a cauldron returns 5 because it has 5 faces that are solid but a full block returns 1 virtual BoundingBoxes & GetBoundingBoxes(Vector3i a_Pos);
BlockHandler.cpp:
cBlockHandler::BoundingBoxes & cBlockHandler::GetBoundingBoxes(Vector3i a_Pos) { cBlockHandler::BoundingBoxes BBS; if (cBlockInfo::IsSolid(m_BlockType)) { cBoundingBox BB(a_Pos, 1, 1); BBS.push_back(BB); } return BBS; }
Then when the server needs to know if an entity is in a block it loops through the list and checks if the bounding boxes intersect with the bounding box of an entity. This method would be usefull for for example a cauldron since it's more like a hollow block.
EDIT:
Another idea is to let the blockhandler itself check if an entity is inside.