1
0

OnBroken/OnPlaced are for entity actions

* Call OnPlaced/OnBroken in PlaceBlock/DigBlock
- Remove unused Placing/Breaking handlers
* Have the blockhandler's Check handle neighbour updating, instead of QueueTickBlockNeighbors
This commit is contained in:
Tiger Wang
2020-07-29 19:30:38 +01:00
parent adb86a75da
commit 6bdd130aab
16 changed files with 93 additions and 261 deletions

View File

@@ -12,6 +12,15 @@
bool cChunkInterface::DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
{
return m_ChunkMap->DoWithChunkAt(a_BlockPos, a_Callback);
}
BLOCKTYPE cChunkInterface::GetBlock(Vector3i a_Pos)
{
return m_ChunkMap->GetBlock(a_Pos);
@@ -95,16 +104,16 @@ bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a
bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, Vector3i a_BlockPos)
{
BLOCKTYPE blockType;
NIBBLETYPE blockMeta;
GetBlockTypeMeta(a_BlockPos, blockType, blockMeta);
auto handler = cBlockInfo::GetHandler(blockType);
handler->OnBreaking(*this, a_WorldInterface, a_BlockPos);
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
GetBlockTypeMeta(a_BlockPos, BlockType, BlockMeta);
if (!m_ChunkMap->DigBlock(a_BlockPos))
{
return false;
}
handler->OnBroken(*this, a_WorldInterface, a_BlockPos, blockType, blockMeta);
cBlockInfo::GetHandler(BlockType)->OnBroken(*this, a_WorldInterface, a_BlockPos, BlockType, BlockMeta);
return true;
}