MCPcopy Create free account
hub / github.com/cuberite/cuberite / Tick

Method Tick

src/Chunk.cpp:562–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560
561
562void cChunk::Tick(float a_Dt)
563{
564 BroadcastPendingBlockChanges();
565
566 // Set all blocks that have been queued for setting later:
567 ProcessQueuedSetBlocks();
568
569 CheckBlocks();
570
571 // Tick simulators:
572 m_World->GetSimulatorManager()->SimulateChunk(a_Dt, m_PosX, m_PosZ, this);
573
574 TickBlocks();
575
576 // Tick all block entities in this chunk:
577 for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
578 {
579 m_IsDirty = (*itr)->Tick(a_Dt, *this) | m_IsDirty;
580 }
581
582 // Tick all entities in this chunk (except mobs):
583 for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
584 {
585 // Mobs are tickes inside MobTick (as we don't have to tick them if they are far away from players)
586 if (!((*itr)->IsMob()))
587 {
588 (*itr)->Tick(a_Dt, *this);
589 }
590 } // for itr - m_Entitites[]
591
592 // Remove all entities that were scheduled for removal:
593 for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();)
594 {
595 if ((*itr)->IsDestroyed())
596 {
597 LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass());
598 cEntity * ToDelete = *itr;
599 itr = m_Entities.erase(itr);
600 delete ToDelete;
601 continue;
602 }
603 itr++;
604 } // for itr - m_Entitites[]
605
606 // If any entity moved out of the chunk, move it to the neighbor:
607 for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();)
608 {
609 if (
610 ((*itr)->GetChunkX() != m_PosX) ||
611 ((*itr)->GetChunkZ() != m_PosZ)
612 )
613 {
614 MoveEntityToNewChunk(*itr);
615 itr = m_Entities.erase(itr);
616 }
617 else
618 {
619 ++itr;

Callers

nothing calls this directly

Calls 10

GetSimulatorManagerMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
IsMobMethod · 0.80
GetClassMethod · 0.80
SimulateChunkMethod · 0.45
IsDestroyedMethod · 0.45
GetUniqueIDMethod · 0.45
GetChunkXMethod · 0.45
GetChunkZMethod · 0.45

Tested by

no test coverage detected