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

Method Tick

src/Entities/Player.cpp:179–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178
179void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
180{
181 if (m_ClientHandle != NULL)
182 {
183 if (m_ClientHandle->IsDestroyed())
184 {
185 // This should not happen, because destroying a client will remove it from the world, but just in case
186 m_ClientHandle = NULL;
187 return;
188 }
189
190 if (!m_ClientHandle->IsPlaying())
191 {
192 // We're not yet in the game, ignore everything
193 return;
194 }
195 }
196
197 if (!a_Chunk.IsValid())
198 {
199 // This may happen if the cPlayer is created before the chunks have the chance of being loaded / generated (#83)
200 return;
201 }
202
203 super::Tick(a_Dt, a_Chunk);
204
205 // Handle charging the bow:
206 if (m_IsChargingBow)
207 {
208 m_BowCharge += 1;
209 }
210
211 //handle updating experience
212 if (m_bDirtyExperience)
213 {
214 SendExperience();
215 }
216
217 if (m_bDirtyPosition)
218 {
219 // Apply food exhaustion from movement:
220 ApplyFoodExhaustionFromMovement();
221
222 cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this);
223 BroadcastMovementUpdate(m_ClientHandle);
224 m_ClientHandle->StreamChunks();
225 }
226 else
227 {
228 BroadcastMovementUpdate(m_ClientHandle);
229 }
230
231 if (m_Health > 0) // make sure player is alive
232 {
233 m_World->CollectPickupsByPlayer(this);
234
235 if ((m_EatingFinishTick >= 0) && (m_EatingFinishTick <= m_World->GetWorldAge()))
236 {

Callers

nothing calls this directly

Calls 11

IsPlayingMethod · 0.80
CallHookPlayerMovingMethod · 0.80
GetPluginManagerMethod · 0.80
StreamChunksMethod · 0.80
GetWorldAgeMethod · 0.80
UpdateItemsMethod · 0.80
GetNowTimeMethod · 0.80
SendPlayerListMethod · 0.80
IsDestroyedMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected