1
0

Refactored block-to-pickup conversion. (#4417)

This commit is contained in:
Mattes D
2019-10-16 10:06:34 +02:00
committed by GitHub
parent 241d97bbf9
commit 221cc4ec5c
121 changed files with 2496 additions and 1744 deletions

View File

@@ -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: