diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-09-20 15:50:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-20 15:50:52 +0200 |
commit | 68cced73afe546328cf94ed07c57deee47bfadec (patch) | |
tree | 88be88e3fd4a208b9849e526f1877caa44058ab5 /src/Chunk.cpp | |
parent | Added armor and shulker box cleaning (#4875) (diff) | |
download | cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.gz cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.bz2 cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.lz cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.xz cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.zst cuberite-68cced73afe546328cf94ed07c57deee47bfadec.zip |
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r-- | src/Chunk.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 3abdc6ff8..a2dd73b51 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -706,11 +706,9 @@ void cChunk::Tick(std::chrono::milliseconds a_Dt) void cChunk::TickBlock(const Vector3i a_RelPos) { - cBlockHandler * Handler = BlockHandler(GetBlock(a_RelPos)); - ASSERT(Handler != nullptr); // Happenned on server restart, FS #243 cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); - Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelPos); + cBlockHandler::For(GetBlock(a_RelPos)).OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelPos); } @@ -802,8 +800,7 @@ void cChunk::CheckBlocks() m_ToTickBlocks.pop(); Count--; - cBlockHandler * Handler = BlockHandler(GetBlock(Pos)); - Handler->Check(ChunkInterface, PluginInterface, Pos, *this); + cBlockHandler::For(GetBlock(Pos)).Check(ChunkInterface, PluginInterface, Pos, *this); } } @@ -827,9 +824,7 @@ void cChunk::TickBlocks(void) continue; // It's all air up here } - cBlockHandler * Handler = BlockHandler(GetBlock(Pos)); - ASSERT(Handler != nullptr); // Happenned on server restart, FS #243 - Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, Pos); + cBlockHandler::For(GetBlock(Pos)).OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, Pos); } // for i // Set a new random coord for the next tick: @@ -938,14 +933,13 @@ cItems cChunk::PickupsFromBlock(Vector3i a_RelPos, const cEntity * a_Digger, con BLOCKTYPE blockType; NIBBLETYPE blockMeta; GetBlockTypeMeta(a_RelPos, blockType, blockMeta); - auto blockHandler = cBlockInfo::GetHandler(blockType); auto blockEntity = GetBlockEntityRel(a_RelPos); cItems pickups (0); auto toolHandler = a_Tool ? a_Tool->GetHandler() : cItemHandler::GetItemHandler(E_ITEM_EMPTY); auto canHarvestBlock = toolHandler->CanHarvestBlock(blockType); if (canHarvestBlock) { - pickups = blockHandler->ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool); + pickups = cBlockHandler::For(blockType).ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool); } auto absPos = RelativeToAbsolute(a_RelPos); cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(*m_World, absPos, blockType, blockMeta, blockEntity, a_Digger, a_Tool, pickups); @@ -958,8 +952,7 @@ cItems cChunk::PickupsFromBlock(Vector3i a_RelPos, const cEntity * a_Digger, con int cChunk::GrowPlantAt(Vector3i a_RelPos, int a_NumStages) { - auto blockHandler = BlockHandler(GetBlock(a_RelPos)); - return blockHandler->Grow(*this, a_RelPos, a_NumStages); + return cBlockHandler::For(GetBlock(a_RelPos)).Grow(*this, a_RelPos, a_NumStages); } |