Cuberite
A lightweight, fast and extensible game server for Minecraft
Broadcaster.cpp
Go to the documentation of this file.
1 // Broadcaster.cpp
2 
3 // Implements the broadcasting functions for cWorld
4 
5 #include "Globals.h"
6 #include "World.h"
7 #include "Chunk.h"
8 #include "ClientHandle.h"
9 #include "Entities/Entity.h"
10 #include "Entities/Player.h"
12 
13 
14 
15 
16 
17 namespace
18 {
19 
24  template <typename Func>
25  void ForClientsInWorld(cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func)
26  {
27  a_World.ForEachPlayer([&](cPlayer & a_Player)
28  {
29  cClientHandle * Client = a_Player.GetClientHandle();
30  if ((Client != a_Exclude) && (Client != nullptr) && Client->IsLoggedIn() && !Client->IsDestroyed())
31  {
32  a_Func(*Client);
33  }
34  return false;
35  }
36  );
37  }
38 
39 
45  template <typename Func>
46  void ForClientsWithChunk(const cChunkCoords a_ChunkCoords, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func)
47  {
48  a_World.DoWithChunk(a_ChunkCoords.m_ChunkX, a_ChunkCoords.m_ChunkZ,
49  [&](cChunk & a_Chunk)
50  {
51  for (auto * Client : a_Chunk.GetAllClients())
52  {
53  if (Client != a_Exclude)
54  {
55  a_Func(*Client);
56  }
57  }
58  return true;
59  }
60  );
61  }
62 
63 
64 
70  template <typename Func>
71  void ForClientsWithChunkAtPos(const Vector3i a_WorldPos, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func)
72  {
73  ForClientsWithChunk(cChunkDef::BlockToChunk(a_WorldPos), a_World, a_Exclude, std::move(a_Func));
74  }
75 
76 
77 
83  template <typename Func>
84  void ForClientsWithEntity(const cEntity & a_Entity, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func)
85  {
86  cWorld::cLock Lock(a_World); // Lock world before accessing a_Entity
87  auto Chunk = a_Entity.GetParentChunk();
88  if (Chunk != nullptr)
89  {
90  for (auto * Client : Chunk->GetAllClients())
91  {
92  if (Client != a_Exclude)
93  {
94  a_Func(*Client);
95  }
96  }
97  }
98  else // Some broadcasts happen before the entity's first tick sets its ParentChunk
99  {
100  ForClientsWithChunk({ a_Entity.GetChunkX(), a_Entity.GetChunkZ() }, a_World, a_Exclude, std::move(a_Func));
101  }
102  }
103 } // namespace (anonymous)
104 
105 
106 
107 
108 
109 void cWorld::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle)
110 {
111  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
112  {
113  a_Client.SendAttachEntity(a_Entity, a_Vehicle);
114  }
115  );
116 }
117 
118 
119 
120 
121 
122 void cWorld::BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
123 {
124  ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
125  {
126  a_Client.SendBlockAction(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType);
127  }
128  );
129 }
130 
131 
132 
133 
134 
135 void cWorld::BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, Int8 a_Stage, const cClientHandle * a_Exclude)
136 {
137  ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
138  {
139  a_Client.SendBlockBreakAnim(a_EntityID, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Stage);
140  }
141  );
142 }
143 
144 
145 
146 
147 
148 void cWorld::BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
149 {
150  DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk)
151  {
152  cBlockEntity * Entity = a_Chunk.GetBlockEntity(a_BlockPos);
153  if (Entity == nullptr)
154  {
155  return false;
156  }
157 
158  for (auto * Client : a_Chunk.GetAllClients())
159  {
160  if (Client != a_Exclude)
161  {
162  Entity->SendTo(*Client);
163  }
164  }
165  return true;
166  }
167  );
168 }
169 
170 
171 
172 
173 
174 void cWorld::BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude, eMessageType a_ChatPrefix)
175 {
176  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
177  {
178  a_Client.SendChat(a_Message, a_ChatPrefix);
179  }
180  );
181 }
182 
183 
184 
185 
186 
187 void cWorld::BroadcastChat(const cCompositeChat & a_Message, const cClientHandle * a_Exclude)
188 {
189  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
190  {
191  a_Client.SendChat(a_Message);
192  }
193  );
194 }
195 
196 
197 
198 
199 
200 void cWorld::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude)
201 {
202  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
203  {
204  a_Client.SendCollectEntity(a_Entity, a_Player, a_Count);
205  }
206  );
207 }
208 
209 
210 
211 
212 
213 void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
214 {
215  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
216  {
217  a_Client.SendDestroyEntity(a_Entity);
218  }
219  );
220 }
221 
222 
223 
224 
225 
226 void cWorld::BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle)
227 {
228  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
229  {
230  a_Client.SendDetachEntity(a_Entity, a_PreviousVehicle);
231  }
232  );
233 }
234 
235 
236 
237 
238 
240 {
241  ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
242  {
243  a_Client.SendDisplayObjective(a_Objective, a_Display);
244  }
245  );
246 }
247 
248 
249 
250 
251 
252 void cWorld::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle * a_Exclude)
253 {
254  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
255  {
256  a_Client.SendEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration);
257  }
258  );
259 }
260 
261 
262 
263 
264 
265 void cWorld::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
266 {
267  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
268  {
269  a_Client.SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
270  }
271  );
272 }
273 
274 
275 
276 
277 
278 void cWorld::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
279 {
280  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
281  {
282  a_Client.SendEntityHeadLook(a_Entity);
283  }
284  );
285 }
286 
287 
288 
289 
290 
291 void cWorld::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
292 {
293  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
294  {
295  a_Client.SendEntityLook(a_Entity);
296  }
297  );
298 }
299 
300 
301 
302 
303 
304 void cWorld::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
305 {
306  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
307  {
308  a_Client.SendEntityMetadata(a_Entity);
309  }
310  );
311 }
312 
313 
314 
315 
316 
317 void cWorld::BroadcastEntityRelMove(const cEntity & a_Entity, Vector3<Int8> a_RelMove, const cClientHandle * a_Exclude)
318 {
319  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
320  {
321  a_Client.SendEntityRelMove(a_Entity, a_RelMove.x, a_RelMove.y, a_RelMove.z);
322  }
323  );
324 }
325 
326 
327 
328 
329 
330 void cWorld::BroadcastEntityRelMoveLook(const cEntity & a_Entity, Vector3<Int8> a_RelMove, const cClientHandle * a_Exclude)
331 {
332  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
333  {
334  a_Client.SendEntityRelMoveLook(a_Entity, a_RelMove.x, a_RelMove.y, a_RelMove.z);
335  }
336  );
337 }
338 
339 
340 
341 
342 
343 void cWorld::BroadcastEntityStatus(const cEntity & a_Entity, Int8 a_Status, const cClientHandle * a_Exclude)
344 {
345  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
346  {
347  a_Client.SendEntityStatus(a_Entity, a_Status);
348  }
349  );
350 }
351 
352 
353 
354 
355 
356 void cWorld::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
357 {
358  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
359  {
360  a_Client.SendEntityVelocity(a_Entity);
361  }
362  );
363 }
364 
365 
366 
367 
368 
369 void cWorld::BroadcastEntityAnimation(const cEntity & a_Entity, Int8 a_Animation, const cClientHandle * a_Exclude)
370 {
371  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
372  {
373  a_Client.SendEntityAnimation(a_Entity, a_Animation);
374  }
375  );
376 }
377 
378 
379 
380 
381 
382 void cWorld::BroadcastLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo)
383 {
384  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
385  {
386  a_Client.SendLeashEntity(a_Entity, a_EntityLeashedTo);
387  }
388  );
389 }
390 
391 
392 
393 
394 
395 void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, const cClientHandle * a_Exclude)
396 {
397  ForClientsWithChunkAtPos(a_Src, *this, a_Exclude, [&](cClientHandle & a_Client)
398  {
399  a_Client.SendParticleEffect(a_ParticleName, a_Src.x, a_Src.y, a_Src.z, a_Offset.x, a_Offset.y, a_Offset.z, a_ParticleData, a_ParticleAmount);
400  }
401  );
402 }
403 
404 
405 
406 
407 
408 void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data, const cClientHandle * a_Exclude)
409 {
410  ForClientsWithChunkAtPos(a_Src, *this, a_Exclude, [&](cClientHandle & a_Client)
411  {
412  a_Client.SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount, a_Data);
413  }
414  );
415 }
416 
417 
418 
419 
420 
421 void cWorld::BroadcastPlayerListAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
422 {
423  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
424  {
425  a_Client.SendPlayerListAddPlayer(a_Player);
426  }
427  );
428 }
429 
430 
431 
432 
433 
434 void cWorld::BroadcastPlayerListRemovePlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
435 {
436  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
437  {
438  a_Client.SendPlayerListRemovePlayer(a_Player);
439  }
440  );
441 }
442 
443 
444 
445 
446 
447 void cWorld::BroadcastPlayerListUpdateGameMode(const cPlayer & a_Player, const cClientHandle * a_Exclude)
448 {
449  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
450  {
451  a_Client.SendPlayerListUpdateGameMode(a_Player);
452  }
453  );
454 }
455 
456 
457 
458 
459 
460 void cWorld::BroadcastPlayerListUpdatePing(const cPlayer & a_Player, const cClientHandle * a_Exclude)
461 {
462  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
463  {
464  a_Client.SendPlayerListUpdatePing(a_Player);
465  }
466  );
467 }
468 
469 
470 
471 
472 
473 void cWorld::BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName, const cClientHandle * a_Exclude)
474 {
475  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
476  {
477  a_Client.SendPlayerListUpdateDisplayName(a_Player, a_CustomName);
478  }
479  );
480 }
481 
482 
483 
484 
485 
486 void cWorld::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude)
487 {
488  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
489  {
490  a_Client.SendRemoveEntityEffect(a_Entity, a_EffectID);
491  }
492  );
493 }
494 
495 
496 
497 
498 
499 void cWorld::BroadcastScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode)
500 {
501  ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
502  {
503  a_Client.SendScoreboardObjective(a_Name, a_DisplayName, a_Mode);
504  }
505  );
506 }
507 
508 
509 
510 
511 
512 void cWorld::BroadcastScoreUpdate(const AString & a_Objective, const AString & a_PlayerName, cObjective::Score a_Score, Byte a_Mode)
513 {
514  ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
515  {
516  a_Client.SendScoreUpdate(a_Objective, a_PlayerName, a_Score, a_Mode);
517  }
518  );
519 }
520 
521 
522 
523 
524 
525 void cWorld::BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
526 {
527  ForClientsWithChunkAtPos(a_Position, *this, a_Exclude, [&](cClientHandle & a_Client)
528  {
529  a_Client.SendSoundEffect(a_SoundName, a_Position, a_Volume, a_Pitch);
530  }
531  );
532 }
533 
534 
535 
536 
537 
538 void cWorld::BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle * a_Exclude)
539 {
540  ForClientsWithChunkAtPos(a_SrcPos, *this, a_Exclude, [&](cClientHandle & a_Client)
541  {
542  a_Client.SendSoundParticleEffect(a_EffectID, a_SrcPos.x, a_SrcPos.y, a_SrcPos.z, a_Data);
543  }
544  );
545 }
546 
547 
548 
549 
550 
551 void cWorld::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude)
552 {
553  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
554  {
555  a_Entity.SpawnOn(a_Client);
556  }
557  );
558 }
559 
560 
561 
562 
563 
564 void cWorld::BroadcastTeleportEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
565 {
566  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
567  {
568  a_Client.SendTeleportEntity(a_Entity);
569  }
570  );
571 }
572 
573 
574 
575 
576 
577 void cWorld::BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
578 {
579  ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
580  {
581  a_Client.SendThunderbolt(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
582  }
583  );
584 }
585 
586 
587 
588 
589 
591 {
592  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
593  {
595  }
596  );
597 }
598 
599 
600 
601 
602 
604 {
605  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
606  {
607  a_Client.SendUnleashEntity(a_Entity);
608  }
609  );
610 }
611 
612 
613 
614 
615 
616 void cWorld::BroadcastUseBed(const cEntity & a_Entity, Vector3i a_BedPos)
617 {
618  ForClientsWithChunkAtPos(a_BedPos, *this, nullptr, [&](cClientHandle & a_Client)
619  {
620  a_Client.SendUseBed(a_Entity, a_BedPos.x, a_BedPos.y, a_BedPos.z);
621  }
622  );
623 }
624 
625 
626 
627 
628 
629 void cWorld::BroadcastWeather(eWeather a_Weather, const cClientHandle * a_Exclude)
630 {
631  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
632  {
633  a_Client.SendWeather(a_Weather);
634  }
635  );
636 }
int GetChunkZ(void) const
Definition: Entity.h:219
virtual bool IsDaylightCycleEnabled(void) const
Is the daylight cycle enabled?
Definition: World.h:100
virtual void BroadcastEntityEffect(const cEntity &a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastEntityRelMove(const cEntity &a_Entity, Vector3< Int8 > a_RelMove, const cClientHandle *a_Exclude=nullptr) override
void SendParticleEffect(const AString &a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount)
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, Int8 a_Animation, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode) override
T x
Definition: Vector3.h:17
eWeather
Definition: Defines.h:151
void SendAttachEntity(const cEntity &a_Entity, const cEntity &a_Vehicle)
virtual void BroadcastSpawnEntity(cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
void SendEntityVelocity(const cEntity &a_Entity)
virtual void BroadcastPlayerListUpdateDisplayName(const cPlayer &a_Player, const AString &a_CustomName, const cClientHandle *a_Exclude=nullptr) override
void SendDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display)
cChunk * GetParentChunk()
Returns the chunk responsible for ticking this entity.
Definition: Entity.h:540
void SendScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode)
signed char Int8
Definition: Globals.h:110
virtual void BroadcastEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item, const cClientHandle *a_Exclude=nullptr) override
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
void SendEntityLook(const cEntity &a_Entity)
bool DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
Calls the callback for the chunk at the block position specified, with ChunkMapCS locked...
Definition: World.cpp:1567
virtual void BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, Int8 a_Stage, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
Definition: Player.h:27
void SendDetachEntity(const cEntity &a_Entity, const cEntity &a_PreviousVehicle)
void SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage)
void SendLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo)
virtual void BroadcastPlayerListUpdatePing(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
virtual void SpawnOn(cClientHandle &a_Client)=0
Descendants override this function to send a command to the specified client to spawn the entity on t...
void SendPlayerListRemovePlayer(const cPlayer &a_Player)
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback a_Callback)
Calls the callback for the chunk specified, with ChunkMapCS locked.
Definition: World.cpp:1558
virtual void BroadcastRemoveEntityEffect(const cEntity &a_Entity, int a_EffectID, const cClientHandle *a_Exclude=nullptr) override
void SendSoundEffect(const AString &a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
virtual void BroadcastDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display) override
virtual void SendTo(cClientHandle &a_Client)=0
Sends the packet defining the block entity to the client specified.
void SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
virtual void BroadcastDetachEntity(const cEntity &a_Entity, const cEntity &a_PreviousVehicle) override
Definition: Chunk.h:49
void SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
T y
Definition: Vector3.h:17
cBlockEntity * GetBlockEntity(Vector3i a_AbsPos)
Returns the block entity at the specified (absolute) coords.
Definition: Chunk.cpp:1530
void SendWeather(eWeather a_Weather)
virtual void BroadcastEntityRelMoveLook(const cEntity &a_Entity, Vector3< Int8 > a_RelMove, const cClientHandle *a_Exclude=nullptr) override
void SendTeleportEntity(const cEntity &a_Entity)
T z
Definition: Vector3.h:17
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
static void BlockToChunk(int a_X, int a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords to chunk coords:
Definition: ChunkDef.h:234
void SendPlayerListAddPlayer(const cPlayer &a_Player)
virtual void BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle *a_Exclude=nullptr) override
If there is a block entity at the specified coods, sends it to all clients except a_Exclude...
Container for a single chat message composed of multiple functional parts.
Definition: CompositeChat.h:31
void SendEntityStatus(const cEntity &a_Entity, char a_Status)
void SendScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode)
virtual void BroadcastDestroyEntity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
void SendEntityRelMoveLook(const cEntity &a_Entity, char a_RelX, char a_RelY, char a_RelZ)
void SendPlayerListUpdateGameMode(const cPlayer &a_Player)
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
Definition: World.h:65
virtual void BroadcastAttachEntity(const cEntity &a_Entity, const cEntity &a_Vehicle) override
void SendEntityHeadLook(const cEntity &a_Entity)
virtual void BroadcastTimeUpdate(const cClientHandle *a_Exclude=nullptr) override
void SendCollectEntity(const cEntity &a_Entity, const cPlayer &a_Player, int a_Count)
void SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle)
virtual int GetTimeOfDay(void) const override
Definition: World.h:110
void SendUseBed(const cEntity &a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
virtual void BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle *a_Exclude=nullptr) override
virtual Int64 GetWorldAge(void) const override
Definition: World.h:109
void SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
virtual void BroadcastPlayerListAddPlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
void SendEntityAnimation(const cEntity &a_Entity, char a_Animation)
virtual void BroadcastPlayerListUpdateGameMode(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
bool IsDestroyed(void) const
Definition: ClientHandle.h:138
void SendEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item)
void SendRemoveEntityEffect(const cEntity &a_Entity, int a_EffectID)
virtual void BroadcastLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo) override
void SendChat(const AString &a_Message, eMessageType a_ChatPrefix, const AString &a_AdditionalData="")
int m_ChunkZ
Definition: ChunkDef.h:60
void SendEntityRelMove(const cEntity &a_Entity, char a_RelX, char a_RelY, char a_RelZ)
virtual void BroadcastParticleEffect(const AString &a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastTeleportEntity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastPlayerListRemovePlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastCollectEntity(const cEntity &a_Pickup, const cPlayer &a_Player, int a_Count, const cClientHandle *a_Exclude=nullptr) override
int m_ChunkX
Definition: ChunkDef.h:59
std::string AString
Definition: StringUtils.h:13
virtual void BroadcastScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode) override
bool IsLoggedIn(void) const
Definition: ClientHandle.h:127
int GetChunkX(void) const
Definition: Entity.h:218
void SendEntityEffect(const cEntity &a_Entity, int a_EffectID, int a_Amplifier, int a_Duration)
virtual void BroadcastEntityHeadLook(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastUnleashEntity(const cEntity &a_Entity) override
virtual void BroadcastEntityVelocity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
void SendUnleashEntity(const cEntity &a_Entity)
Definition: Entity.h:73
virtual void BroadcastWeather(eWeather a_Weather, const cClientHandle *a_Exclude=nullptr) override
unsigned int UInt32
Definition: Globals.h:113
eMessageType
Definition: Defines.h:976
void SendPlayerListUpdatePing(const cPlayer &a_Player)
unsigned char Byte
Definition: Globals.h:117
cChunkClientHandles GetAllClients(void) const
Definition: Chunk.h:562
virtual void BroadcastUseBed(const cEntity &a_Entity, Vector3i a_BlockPos) override
virtual void BroadcastEntityLook(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle *a_Exclude=nullptr) override
Definition: Item.h:36
EffectID
Definition: EffectID.h:5
void SendEntityMetadata(const cEntity &a_Entity)
void SendPlayerListUpdateDisplayName(const cPlayer &a_Player, const AString &a_CustomName)
void SendDestroyEntity(const cEntity &a_Entity)
A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the dest...
Definition: World.h:76
virtual void BroadcastEntityStatus(const cEntity &a_Entity, Int8 a_Status, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastChat(const AString &a_Message, const cClientHandle *a_Exclude=nullptr, eMessageType a_ChatPrefix=mtCustom) override
cClientHandle * GetClientHandle(void) const
Returns the raw client handle associated with the player.
Definition: Player.h:254
virtual bool ForEachPlayer(cPlayerListCallback a_Callback) override
Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true.
Definition: World.cpp:2549