Refactored block-to-pickup conversion. (#4417)
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "Blocks/BlockHandler.h"
|
||||
#include "ChunkData.h"
|
||||
#include "BlockEntities/BlockEntity.h"
|
||||
#include "Item.h"
|
||||
|
||||
|
||||
|
||||
@@ -2215,6 +2216,21 @@ bool cBlockArea::ForEachBlockEntity(cBlockEntityCallback a_Callback)
|
||||
|
||||
|
||||
|
||||
cItems cBlockArea::PickupsFromBlock(Vector3i a_AbsPos, const cEntity * a_Digger, const cItem * a_Tool)
|
||||
{
|
||||
auto relPos = a_AbsPos - m_Origin;
|
||||
BLOCKTYPE blockType;
|
||||
NIBBLETYPE blockMeta;
|
||||
GetRelBlockTypeMeta(relPos.x, relPos.y, relPos.z, blockType, blockMeta);
|
||||
auto blockEntity = GetBlockEntityRel(relPos);
|
||||
auto handler = BlockHandler(blockType);
|
||||
return handler->ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockArea::SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array)
|
||||
{
|
||||
if (a_Array == nullptr)
|
||||
@@ -2710,6 +2726,20 @@ void cBlockArea::RemoveNonMatchingBlockEntities(void)
|
||||
|
||||
|
||||
|
||||
cBlockEntity * cBlockArea::GetBlockEntityRel(Vector3i a_RelPos)
|
||||
{
|
||||
if (!HasBlockEntities())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
auto itr = m_BlockEntities->find(MakeIndex(a_RelPos));
|
||||
return (itr == m_BlockEntities->end()) ? nullptr : itr->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cBlockArea::sBlockEntityDeleter:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user