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/World.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 4de325d6e..f70343889 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2182,18 +2182,12 @@ UInt32 cWorld::SpawnPrimedTNT(Vector3d a_Pos, int a_FuseTicks, double a_InitialV -void cWorld::SetBlocks(const sSetBlockVector & a_Blocks) +void cWorld::PlaceBlock(const Vector3i a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta) { - m_ChunkMap->SetBlocks(a_Blocks); -} - - - - + SetBlock(a_Position, a_BlockType, a_BlockMeta); -void cWorld::ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_FilterBlockType) -{ - m_ChunkMap->ReplaceBlocks(a_Blocks, a_FilterBlockType); + cChunkInterface ChunkInterface(GetChunkMap()); + cBlockInfo::GetHandler(a_BlockType)->OnPlaced(ChunkInterface, *this, a_Position, a_BlockType, a_BlockMeta); } @@ -2211,17 +2205,18 @@ bool cWorld::GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure) bool cWorld::DigBlock(Vector3i a_BlockPos) { - BLOCKTYPE blockType; - NIBBLETYPE blockMeta; - GetBlockTypeMeta(a_BlockPos, blockType, blockMeta); - cChunkInterface chunkInterface(GetChunkMap()); - auto blockHandler = cBlockInfo::GetHandler(blockType); - blockHandler->OnBreaking(chunkInterface, *this, a_BlockPos); + BLOCKTYPE BlockType; + NIBBLETYPE BlockMeta; + GetBlockTypeMeta(a_BlockPos, BlockType, BlockMeta); + if (!m_ChunkMap->DigBlock(a_BlockPos)) { return false; } - blockHandler->OnBroken(chunkInterface, *this, a_BlockPos, blockType, blockMeta); + + cChunkInterface ChunkInterface(GetChunkMap()); + cBlockInfo::GetHandler(BlockType)->OnBroken(ChunkInterface, *this, a_BlockPos, BlockType, BlockMeta); + return true; } -- cgit v1.2.3