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

Method Tick

src/World.cpp:714–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712
713
714void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
715{
716 // Call the plugins
717 cPluginManager::Get()->CallHookWorldTick(*this, a_Dt, a_LastTickDurationMSec);
718
719 // We need sub-tick precision here, that's why we store the time in seconds and calculate ticks off of it
720 m_WorldAgeSecs += (double)a_Dt / 1000.0;
721 m_TimeOfDaySecs += (double)a_Dt / 1000.0;
722
723 // Wrap time of day each 20 minutes (1200 seconds)
724 if (m_TimeOfDaySecs > 1200.0)
725 {
726 m_TimeOfDaySecs -= 1200.0;
727 }
728
729 m_WorldAge = (Int64)(m_WorldAgeSecs * 20.0);
730 m_TimeOfDay = (Int64)(m_TimeOfDaySecs * 20.0);
731
732 // Updates the sky darkness based on current time of day
733 UpdateSkyDarkness();
734
735 // Broadcast time update every 40 ticks (2 seconds)
736 if (m_LastTimeUpdate < m_WorldAge - 40)
737 {
738 BroadcastTimeUpdate();
739 m_LastTimeUpdate = m_WorldAge;
740 }
741
742 m_ChunkMap->Tick(a_Dt);
743
744 TickClients(a_Dt);
745 TickQueuedBlocks();
746 TickQueuedTasks();
747 TickScheduledTasks();
748
749 GetSimulatorManager()->Simulate(a_Dt);
750
751 TickWeather(a_Dt);
752
753 m_ChunkMap->FastSetQueuedBlocks();
754
755 if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes
756 {
757 SaveAllChunks();
758 }
759
760 if (m_WorldAge - m_LastUnload > 10 * 20) // Unload every 10 seconds
761 {
762 UnloadUnusedChunks();
763 }
764
765 TickMobs(a_Dt);
766}
767
768
769

Callers 3

ExecuteMethod · 0.45
TickMobsMethod · 0.45
TickClientsMethod · 0.45

Calls 3

CallHookWorldTickMethod · 0.80
FastSetQueuedBlocksMethod · 0.80
SimulateMethod · 0.45

Tested by

no test coverage detected