From 6bdd130aab51b630918ed664c4389cf33bcb2e06 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 29 Jul 2020 19:30:38 +0100 Subject: 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 --- src/Blocks/ChunkInterface.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/Blocks/ChunkInterface.cpp') diff --git a/src/Blocks/ChunkInterface.cpp b/src/Blocks/ChunkInterface.cpp index fd64ee9fc..15198dd37 100644 --- a/src/Blocks/ChunkInterface.cpp +++ b/src/Blocks/ChunkInterface.cpp @@ -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; } -- cgit v1.2.3