Cuberite
A lightweight, fast and extensible game server for Minecraft
World.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #define MAX_PLAYERS 65535
5 
6 #include <functional>
7 
9 #include "ChunkMap.h"
11 #include "ChunkGeneratorThread.h"
12 #include "ChunkSender.h"
13 #include "Defines.h"
14 #include "LightingThread.h"
15 #include "IniFile.h"
16 #include "Item.h"
17 #include "Mobs/Monster.h"
19 #include "Entities/Boat.h"
20 #include "ForEachChunkProvider.h"
21 #include "Scoreboard.h"
22 #include "MapManager.h"
23 #include "Blocks/WorldInterface.h"
25 #include "EffectID.h"
26 
27 
28 
29 class cFireSimulator;
30 class cFluidSimulator;
31 class cSandSimulator;
32 class cRedstoneSimulator;
33 class cItem;
34 class cPlayer;
36 typedef std::shared_ptr<cClientHandle> cClientHandlePtr;
37 typedef std::list<cClientHandlePtr> cClientHandlePtrs;
38 typedef std::list<cClientHandle *> cClientHandles;
39 class cEntity;
40 class cChunkGenerator; // The thread responsible for generating chunks
41 class cBeaconEntity;
43 class cChestEntity;
44 class cCuboid;
45 class cDispenserEntity;
46 class cFlowerPotEntity;
47 class cFurnaceEntity;
48 class cNoteEntity;
49 class cMobHeadEntity;
50 class cCompositeChat;
51 class cSetChunkData;
52 class cDeadlockDetect;
53 class cUUID;
54 
55 typedef std::list< cPlayer * > cPlayerList;
56 typedef std::list< std::pair< std::unique_ptr<cPlayer>, cWorld * > > cAwaitingPlayerList;
57 
58 typedef std::unique_ptr<cSetChunkData> cSetChunkDataPtr;
59 typedef std::vector<cSetChunkDataPtr> cSetChunkDataPtrs;
60 
61 
62 
63 
64 
65 class cWorld // tolua_export
66  final:
67  public cForEachChunkProvider,
68  public cWorldInterface,
69  public cBroadcastInterface
70 // tolua_begin
71 {
72 public:
73  // tolua_end
74 
76  class cLock :
77  public cCSLock
78  {
79  typedef cCSLock super;
80  public:
81  cLock(cWorld & a_World);
82  };
83 
84  static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
85  {
86  return "cWorld";
87  }
88 
89  // tolua_begin
90 
92  bool IsSavingEnabled(void) const { return m_IsSavingEnabled; }
93 
95  void SetSavingEnabled(bool a_IsSavingEnabled) { m_IsSavingEnabled = a_IsSavingEnabled; }
96 
97  int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; }
98 
100  virtual bool IsDaylightCycleEnabled(void) const { return m_IsDaylightCycleEnabled; }
101 
103  virtual void SetDaylightCycleEnabled(bool a_IsDaylightCycleEnabled)
104  {
105  m_IsDaylightCycleEnabled = a_IsDaylightCycleEnabled;
107  }
108 
109  virtual Int64 GetWorldAge (void) const override { return std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count(); }
110  virtual int GetTimeOfDay(void) const override { return std::chrono::duration_cast<cTickTime>(m_TimeOfDay).count(); }
111 
112  void SetTicksUntilWeatherChange(int a_WeatherInterval)
113  {
114  m_WeatherInterval = a_WeatherInterval;
115  }
116 
117  virtual void SetTimeOfDay(int a_TimeOfDay) override
118  {
119  m_TimeOfDay = cTickTime(a_TimeOfDay);
122  }
123 
126  int GetDefaultWeatherInterval(eWeather a_Weather);
127 
129  eGameMode GetGameMode(void) const { return m_GameMode; }
130 
132  bool IsGameModeCreative(void) const { return (m_GameMode == gmCreative); }
133 
135  bool IsGameModeSurvival(void) const { return (m_GameMode == gmSurvival); }
136 
138  bool IsGameModeAdventure(void) const { return (m_GameMode == gmAdventure); }
139 
141  bool IsGameModeSpectator(void) const { return (m_GameMode == gmSpectator); }
142 
143  bool IsPVPEnabled(void) const { return m_bEnabledPVP; }
144 
145  bool IsDeepSnowEnabled(void) const { return m_IsDeepSnowEnabled; }
146 
147  bool ShouldLavaSpawnFire(void) const { return m_ShouldLavaSpawnFire; }
148 
150 
151  virtual eDimension GetDimension(void) const override { return m_Dimension; }
152 
154  virtual int GetHeight(int a_BlockX, int a_BlockZ) override;
155 
156  // tolua_end
157 
159  bool TryGetHeight(int a_BlockX, int a_BlockZ, int & a_Height); // Exported in ManualBindings.cpp
160 
161  // Broadcast respective packets to all clients of the chunk where the event is taking place
162  // Implemented in Broadcaster.cpp
163  // (Please keep these alpha-sorted)
164  virtual void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle) override;
165  virtual void BroadcastBlockAction (Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr) override; // Exported in ManualBindings_World.cpp
166  virtual void BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, Int8 a_Stage, const cClientHandle * a_Exclude = nullptr) override;
167  virtual void BroadcastBlockEntity (Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr) override;
168 
169  // tolua_begin
170  virtual void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = nullptr, eMessageType a_ChatPrefix = mtCustom) override;
171  virtual void BroadcastChatInfo (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) override { BroadcastChat(a_Message, a_Exclude, mtInformation); }
172  virtual void BroadcastChatFailure(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) override { BroadcastChat(a_Message, a_Exclude, mtFailure); }
173  virtual void BroadcastChatSuccess(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) override { BroadcastChat(a_Message, a_Exclude, mtSuccess); }
174  virtual void BroadcastChatWarning(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) override { BroadcastChat(a_Message, a_Exclude, mtWarning); }
175  virtual void BroadcastChatFatal (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) override { BroadcastChat(a_Message, a_Exclude, mtFailure); }
176  virtual void BroadcastChatDeath (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) override { BroadcastChat(a_Message, a_Exclude, mtDeath); }
177  virtual void BroadcastChat (const cCompositeChat & a_Message, const cClientHandle * a_Exclude = nullptr) override;
178  // tolua_end
179 
180  virtual void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr) override;
181  virtual void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) override;
182  virtual void BroadcastDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
183  virtual void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle * a_Exclude = nullptr) override;
184  virtual void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = nullptr) override;
185  virtual void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) override;
186  virtual void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) override;
187  virtual void BroadcastEntityMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) override;
188  virtual void BroadcastEntityRelMove (const cEntity & a_Entity, Vector3<Int8> a_RelMove, const cClientHandle * a_Exclude = nullptr) override;
189  virtual void BroadcastEntityRelMoveLook (const cEntity & a_Entity, Vector3<Int8> a_RelMove, const cClientHandle * a_Exclude = nullptr) override;
190  virtual void BroadcastEntityStatus (const cEntity & a_Entity, Int8 a_Status, const cClientHandle * a_Exclude = nullptr) override;
191  virtual void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) override;
192  virtual void BroadcastEntityAnimation (const cEntity & a_Entity, Int8 a_Animation, const cClientHandle * a_Exclude = nullptr) override; // tolua_export
193  virtual void BroadcastLeashEntity (const cEntity & a_Entity, const cEntity & a_EntityLeashedTo) override;
194  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; // Exported in ManualBindings_World.cpp
195  virtual void BroadcastParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data, const cClientHandle * a_Exclude = nullptr) override; // Exported in ManualBindings_World.cpp
196  virtual void BroadcastPlayerListAddPlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) override;
197  virtual void BroadcastPlayerListRemovePlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) override;
198  virtual void BroadcastPlayerListUpdateGameMode (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) override;
199  virtual void BroadcastPlayerListUpdatePing (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) override;
200  virtual void BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName, const cClientHandle * a_Exclude = nullptr) override;
201  virtual void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = nullptr) override;
202  virtual void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
203  virtual void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override;
204  virtual void BroadcastDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override;
205  virtual void BroadcastSoundEffect (const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) override; // Exported in ManualBindings_World.cpp
206  virtual void BroadcastSoundParticleEffect (const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle * a_Exclude = nullptr) override; // Exported in ManualBindings_World.cpp
207  virtual void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) override;
208  virtual void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) override;
209  virtual void BroadcastThunderbolt (Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr) override;
210  virtual void BroadcastTimeUpdate (const cClientHandle * a_Exclude = nullptr) override;
211  virtual void BroadcastUnleashEntity (const cEntity & a_Entity) override;
212  virtual void BroadcastUseBed (const cEntity & a_Entity, Vector3i a_BlockPos) override;
213  virtual void BroadcastWeather (eWeather a_Weather, const cClientHandle * a_Exclude = nullptr) override;
214 
215  virtual cBroadcastInterface & GetBroadcastManager(void) override
216  {
217  return *this;
218  }
219 
221  void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
222 
223  void MarkChunkDirty (int a_ChunkX, int a_ChunkZ);
224  void MarkChunkSaving(int a_ChunkX, int a_ChunkZ);
225  void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
226 
229  void QueueSetChunkData(cSetChunkDataPtr a_SetChunkData);
230 
231  void ChunkLighted(
232  int a_ChunkX, int a_ChunkZ,
233  const cChunkDef::BlockNibbles & a_BlockLight,
234  const cChunkDef::BlockNibbles & a_SkyLight
235  );
236 
239  bool GetChunkData(cChunkCoords a_Coords, cChunkDataCallback & a_Callback) const;
240 
242  bool GetChunkBlockTypes(int a_ChunkX, int a_ChunkZ, BLOCKTYPE * a_BlockTypes);
243 
245  bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const;
246 
248  bool IsChunkValid(int a_ChunkX, int a_ChunkZ) const;
249 
250  bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const;
251 
253  void QueueUnloadUnusedChunks(void); // tolua_export
254 
255  void CollectPickupsByPlayer(cPlayer & a_Player);
256 
261  void AddPlayer(std::unique_ptr<cPlayer> a_Player, cWorld * a_OldWorld = nullptr);
262 
268  std::unique_ptr<cPlayer> RemovePlayer(cPlayer & a_Player, bool a_RemoveFromChunk);
269 
270 #ifdef _DEBUG
271  bool IsPlayerReferencedInWorldOrChunk(cPlayer & a_Player);
272 #endif
273 
275  virtual bool ForEachPlayer(cPlayerListCallback a_Callback) override; // >> EXPORTED IN MANUALBINDINGS <<
276 
279  bool DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
280 
282  bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
283 
285  bool DoWithNearestPlayer(Vector3d a_Pos, double a_RangeLimit, cPlayerListCallback a_Callback, bool a_CheckLineOfSight = true, bool a_IgnoreSpectator = true);
286 
288  bool DoWithPlayerByUUID(const cUUID & a_PlayerUUID, cPlayerListCallback a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
289 
290  void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player
291 
294  void AddEntity(OwnedEntity a_Entity);
295 
298  bool HasEntity(UInt32 a_UniqueID);
299 
302  OwnedEntity RemoveEntity(cEntity & a_Entity);
303 
305  bool ForEachEntity(cEntityCallback a_Callback); // Exported in ManualBindings.cpp
306 
308  bool ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback a_Callback); // Exported in ManualBindings.cpp
309 
313  virtual bool ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback a_Callback) override; // Exported in ManualBindings.cpp
314 
317  bool DoWithEntityByID(UInt32 a_UniqueID, cEntityCallback a_Callback); // Exported in ManualBindings.cpp
318 
320  void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback & a_Callback);
321 
323  bool AddChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
324 
326  void RemoveChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
327 
329  void RemoveClientFromChunks(cClientHandle * a_Client);
330 
333  void SendChunkTo(int a_ChunkX, int a_ChunkZ, cChunkSender::eChunkPriority a_Priority, cClientHandle * a_Client);
334 
337  void ForceSendChunkTo(int a_ChunkX, int a_ChunkZ, cChunkSender::eChunkPriority a_Priority, cClientHandle * a_Client);
338 
341 
343  void TouchChunk(int a_ChunkX, int a_ChunkZ);
344 
349  void PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_CallAfter = {});
350 
352  void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ);
353 
355  bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = nullptr); // Exported in ManualBindings.cpp
356 
358  bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export
359 
361  bool IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
362 
364  bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open); // tolua_export
365 
367  void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
368 
370  void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
371 
373  void QueueLightChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_Callback = {});
374 
375  bool IsChunkLighted(int a_ChunkX, int a_ChunkZ);
376 
378  virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override;
379 
381  bool ForEachLoadedChunk(cFunctionRef<bool(int, int)> a_Callback);
382 
383  // tolua_begin
384 
387  void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
388 
392  void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
393  {
394  return SetBlock({a_BlockX, a_BlockY, a_BlockZ}, a_BlockType, a_BlockMeta);
395  }
396 
400  void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
401  {
402  m_ChunkMap->FastSetBlock(a_BlockPos, a_BlockType, a_BlockMeta);
403  }
404 
409  void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
410  {
411  return FastSetBlock({a_BlockX, a_BlockY, a_BlockZ}, a_BlockType, a_BlockMeta);
412  }
413 
417  {
418  return m_ChunkMap->GetBlock(a_BlockPos);
419  }
420 
424  BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
425  {
426  return m_ChunkMap->GetBlock({a_BlockX, a_BlockY, a_BlockZ});
427  }
428 
432  {
433  return m_ChunkMap->GetBlockMeta(a_BlockPos);
434  }
435 
439  NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
440  {
441  return m_ChunkMap->GetBlockMeta({a_BlockX, a_BlockY, a_BlockZ});
442  }
443 
448  void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty = true, bool a_ShouldInformClients = true);
449 
455  void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty = true, bool a_ShouldInformClients = true)
456  {
457  return SetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}, a_MetaData, a_ShouldMarkDirty, a_ShouldInformClients);
458  }
459 
464 
469  NIBBLETYPE GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ)
470  {
471  return GetBlockSkyLight({a_BlockX, a_BlockY, a_BlockZ});
472  }
473 
477 
481  NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ)
482  {
483  return GetBlockBlockLight({a_BlockX, a_BlockY, a_BlockZ});
484  }
485 
486  // tolua_end
487 
492  bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
493 
499  bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
500  {
501  return GetBlockTypeMeta({a_BlockX, a_BlockY, a_BlockZ}, a_BlockType, a_BlockMeta);
502  }
503 
507  bool GetBlockInfo(Vector3i a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
508 
512  bool GetBlockInfo(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight)
513  {
514  return GetBlockInfo({a_BlockX, a_BlockY, a_BlockZ}, a_BlockType, a_Meta, a_SkyLight, a_BlockLight);
515  }
516 
517  // TODO: NIBBLETYPE GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ);
518 
524  virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override;
525 
526  // tolua_begin
527 
531  void SpawnItemPickups(const cItems & a_Pickups, Vector3i a_BlockPos, double a_FlyAwaySpeed = 1.0, bool a_IsPlayerCreated = false);
532 
535  void SpawnItemPickups(const cItems & a_Pickups, Vector3d a_Pos, double a_FlyAwaySpeed = 1.0, bool a_IsPlayerCreated = false);
536 
540  virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool a_IsPlayerCreated = false) override
541  {
542  return SpawnItemPickups(a_Pickups, Vector3d{a_BlockX, a_BlockY, a_BlockZ}, a_FlyAwaySpeed, a_IsPlayerCreated);
543  }
544 
546  void SpawnItemPickups(const cItems & a_Pickups, Vector3d a_Pos, Vector3d a_Speed, bool a_IsPlayerCreated = false);
547 
550  virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool a_IsPlayerCreated = false) override
551  {
552  return SpawnItemPickups(a_Pickups, {a_BlockX, a_BlockY, a_BlockZ}, {a_SpeedX, a_SpeedY, a_SpeedZ}, a_IsPlayerCreated);
553  }
554 
556  UInt32 SpawnItemPickup(Vector3d a_Pos, const cItem & a_Item, Vector3f a_Speed, int a_LifetimeTicks = 6000, bool a_CanCombine = true);
557 
560  virtual UInt32 SpawnItemPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f, int a_LifetimeTicks = 6000, bool a_CanCombine = true) override
561  {
562  return SpawnItemPickup({a_PosX, a_PosY, a_PosZ}, a_Item, {a_SpeedX, a_SpeedY, a_SpeedZ}, a_LifetimeTicks, a_CanCombine);
563  }
564 
567  UInt32 SpawnFallingBlock(Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
568 
572  UInt32 SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
573  {
574  return SpawnFallingBlock({a_X, a_Y, a_Z}, a_BlockType, a_BlockMeta);
575  }
576 
579  UInt32 SpawnMinecart(Vector3d a_Pos, int a_MinecartType, const cItem & a_Content = cItem(), int a_BlockHeight = 1);
580 
584  UInt32 SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType, const cItem & a_Content = cItem(), int a_BlockHeight = 1)
585  {
586  return SpawnMinecart({a_X, a_Y, a_Z}, a_MinecartType, a_Content, a_BlockHeight);
587  }
588 
589  // DEPRECATED, use the vector-parametered version instead.
590  UInt32 SpawnBoat(double a_X, double a_Y, double a_Z, cBoat::eMaterial a_Material)
591  {
592  LOGWARNING("cWorld::SpawnBoat(double, double, double) is deprecated, use cWorld::SpawnBoat(Vector3d) instead.");
593  return SpawnBoat({a_X, a_Y, a_Z}, a_Material);
594  }
595 
598  UInt32 SpawnBoat(Vector3d a_Pos, cBoat::eMaterial a_Material);
599 
602  UInt32 SpawnExperienceOrb(Vector3d a_Pos, int a_Reward);
603 
607  virtual UInt32 SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) override
608  {
609  return SpawnExperienceOrb({a_X, a_Y, a_Z}, a_Reward);
610  }
611 
612  // tolua_end
613 
616  virtual std::vector<UInt32> SpawnSplitExperienceOrbs(Vector3d a_Pos, int a_Reward) override; // Exported in ManualBindings_World.cpp
617 
621  std::vector<UInt32> SpawnSplitExperienceOrbs(double a_X, double a_Y, double a_Z, int a_Reward)
622  {
623  return SpawnSplitExperienceOrbs({a_X, a_Y, a_Z}, a_Reward);
624  }
625 
626  // tolua_begin
627 
628  // DEPRECATED, use the vector-parametered version instead.
629  UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1)
630  {
631  LOGWARNING("cWorld::SpawnPrimedTNT(double, double, double) is deprecated, use cWorld::SpawnPrimedTNT(Vector3d) instead.");
632  return SpawnPrimedTNT({a_X, a_Y, a_Z}, a_FuseTimeInSec, a_InitialVelocityCoeff);
633  }
634 
638  UInt32 SpawnPrimedTNT(Vector3d a_Pos, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1);
639 
640  // tolua_end
641 
645  void SetBlocks(const sSetBlockVector & a_Blocks);
646 
648  void ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_FilterBlockType);
649 
651  bool GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure);
652 
653  // tolua_begin
654 
659  bool DigBlock(Vector3i a_BlockPos);
660 
666  bool DigBlock(int a_X, int a_Y, int a_Z)
667  {
668  return DigBlock({a_X, a_Y, a_Z});
669  }
670 
676  bool DropBlockAsPickups(Vector3i a_BlockPos, const cEntity * a_Digger = nullptr, const cItem * a_Tool = nullptr);
677 
683  cItems PickupsFromBlock(Vector3i a_BlockPos, const cEntity * a_Digger = nullptr, const cItem * a_Tool = nullptr);
684 
685  virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer & a_Player) override;
686 
689  bool SetSpawn(double a_X, double a_Y, double a_Z);
690 
691  double GetSpawnX(void) const { return m_SpawnX; }
692  double GetSpawnY(void) const { return m_SpawnY; }
693  double GetSpawnZ(void) const { return m_SpawnZ; }
694 
696  virtual void WakeUpSimulators(Vector3i a_Block) override;
697 
699  void WakeUpSimulatorsInArea(const cCuboid & a_Area);
700 
701  // DEPRECATED, use vector-parametered version instead
702  void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
703  {
704  LOGWARNING("cWorld::WakeUpSimulators(int, int, int) is deprecated, use cWorld::WakeUpSimulators(Vector3i) instead.");
705  WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
706  }
707 
708  // DEPRECATED, use vector-parametered version instead
709  void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ);
710 
711  // tolua_end
712 
714 
718 
720  bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback a_Callback); // Exported in ManualBindings.cpp
721 
723  bool ForEachBrewingstandInChunk(int a_ChunkX, int a_ChunkZ, cBrewingstandCallback a_Callback); // Exported in ManualBindings.cpp
724 
726  bool ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback a_Callback); // Exported in ManualBindings.cpp
727 
729  bool ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCallback a_Callback);
730 
732  bool ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallback a_Callback);
733 
735  bool ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpenserCallback a_Callback);
736 
738  bool ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback a_Callback); // Exported in ManualBindings.cpp
739 
744  virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) override;
745 
747  virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback a_Callback) override; // Exported in ManualBindings.cpp
748 
750  bool DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback a_Callback); // Exported in ManualBindings.cpp
751 
753  virtual bool DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback a_Callback) override; // Exported in ManualBindings.cpp
754 
756  bool DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBrewingstandCallback a_Callback); // Lua-acessible
757 
759  bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback a_Callback); // Exported in ManualBindings.cpp
760 
762  bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback a_Callback); // Exported in ManualBindings.cpp
763 
765  bool DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback a_Callback); // Exported in ManualBindings.cpp
766 
768  bool DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback a_Callback); // Exported in ManualBindings.cpp
769 
771  bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback a_Callback); // Exported in ManualBindings.cpp
772 
774  bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback a_Callback); // Exported in ManualBindings.cpp
775 
777  bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback a_Callback); // Exported in ManualBindings.cpp
778 
780  bool DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadCallback a_Callback); // Exported in ManualBindings.cpp
781 
783  bool DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlowerPotCallback a_Callback); // Exported in ManualBindings.cpp
784 
786  bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Exported in ManualBindings.cpp
787 
789  void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ); } // tolua_export
790 
793  bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback a_Callback);
794 
797  bool DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback);
798 
802  bool GrowTreeImage(const sSetBlockVector & a_Blocks);
803 
804  // tolua_begin
805 
810  bool GrowTree(int a_BlockX, int a_BlockY, int a_BlockZ);
811 
814  bool GrowTreeFromSapling(Vector3i a_BlockPos, NIBBLETYPE a_SaplingMeta)
815  {
816  // TODO: Change the implementation to use Vector3i, once cTree uses Vector3i-based functions
817  return GrowTreeFromSapling(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_SaplingMeta);
818  }
819 
823  bool GrowTreeFromSapling(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_SaplingMeta);
824 
827  bool GrowTreeByBiome(int a_BlockX, int a_BlockY, int a_BlockZ);
828 
832  int GrowPlantAt(Vector3i a_BlockPos, int a_NumStages = 1);
833 
836  bool GrowRipePlant(Vector3i a_BlockPos);
837 
842  bool GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal = false)
843  {
844  UNUSED(a_IsByBonemeal);
845  return GrowRipePlant({a_BlockX, a_BlockY, a_BlockZ});
846  }
847 
849  int GrowCactus(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow);
850 
852  bool GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType);
853 
855  int GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow);
856 
858  EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ);
859 
862  bool SetBiomeAt(int a_BlockX, int a_BlockZ, EMCSBiome a_Biome);
863 
866  bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome);
867 
871  bool SetAreaBiome(const cCuboid & a_Area, EMCSBiome a_Biome);
872 
874  const AString & GetName(void) const { return m_WorldName; }
875 
877  const AString & GetDataPath(void) const { return m_DataPath; }
878 
880  const AString & GetIniFileName(void) const {return m_IniFileName; }
881 
884 
887 
889  void SetCommandBlocksEnabled(bool a_Flag) { m_bCommandBlocksEnabled = a_Flag; }
890 
893 
894  int GetMaxViewDistance(void) const { return m_MaxViewDistance; }
895  void SetMaxViewDistance(int a_MaxViewDistance);
896 
897  bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; }
898  void SetShouldUseChatPrefixes(bool a_Flag) { m_bUseChatPrefixes = a_Flag; }
899 
902 
903 
905  void SetLinkedNetherWorldName(const AString & a_Name) { m_LinkedNetherWorldName = a_Name; }
906 
908  void SetLinkedEndWorldName(const AString & a_Name) { m_LinkedEndWorldName = a_Name; }
909 
911  void SetLinkedOverworldName(const AString & a_Name) { m_LinkedOverworldName = a_Name; }
912 
914  virtual int GetMinNetherPortalWidth(void) const override { return m_MinNetherPortalWidth; }
915  virtual int GetMaxNetherPortalWidth(void) const override { return m_MaxNetherPortalWidth; }
916  virtual void SetMinNetherPortalWidth(int a_NewMinWidth) override { m_MinNetherPortalWidth = a_NewMinWidth; }
917  virtual void SetMaxNetherPortalWidth(int a_NewMaxWidth) override { m_MaxNetherPortalWidth = a_NewMaxWidth; }
918 
920  virtual int GetMinNetherPortalHeight(void) const override { return m_MinNetherPortalHeight; }
921  virtual int GetMaxNetherPortalHeight(void) const override { return m_MaxNetherPortalHeight; }
922  virtual void SetMinNetherPortalHeight(int a_NewMinHeight) override { m_MinNetherPortalHeight = a_NewMinHeight; }
923  virtual void SetMaxNetherPortalHeight(int a_NewMaxHeight) override { m_MaxNetherPortalHeight = a_NewMaxHeight; }
924 
925  // tolua_end
926 
928  void SaveAllChunks(void);
929 
931  void QueueSaveAllChunks(void); // tolua_export
932 
934  void QueueTask(std::function<void(cWorld &)> a_Task); // Exported in ManualBindings.cpp
935 
937  void ScheduleTask(int a_DelayTicks, std::function<void(cWorld &)> a_Task);
938 
940  size_t GetNumChunks() const; // tolua_export
941 
943  size_t GetNumUnusedDirtyChunks(void) const; // tolua_export
944 
946  void GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLightingQueue);
947 
948  // Various queues length queries (cannot be const, they lock their CS):
949  inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export
950  inline size_t GetLightingQueueLength (void) { return m_Lighting.GetQueueLength(); } // tolua_export
951  inline size_t GetStorageLoadQueueLength(void) { return m_Storage.GetLoadQueueLength(); } // tolua_export
952  inline size_t GetStorageSaveQueueLength(void) { return m_Storage.GetSaveQueueLength(); } // tolua_export
953 
955 
956  void InitializeSpawn(void);
957 
959  void Start();
960 
963  void Stop(cDeadlockDetect & a_DeadlockDetect);
964 
966  void TickQueuedBlocks(void);
967 
969  {
970  int X;
971  int Y;
972  int Z;
974  };
975 
977  void QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, int a_TicksToWait); // tolua_export
978 
979  // tolua_begin
981  void CastThunderbolt(Vector3i a_Block);
982  void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ); // DEPRECATED, use vector-parametered version instead
983 
985  void SetWeather(eWeather a_NewWeather);
986 
988  void ChangeWeather(void);
989 
991  eWeather GetWeather(void) const { return m_Weather; }
992 
994  bool IsWeatherSunny(void) const { return (m_Weather == wSunny); }
995 
997  bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ)
998  {
999  return (IsWeatherSunny() || IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
1000  }
1001 
1003  bool IsWeatherRain(void) const { return (m_Weather == wRain); }
1004 
1006  bool IsWeatherRainAt(int a_BlockX, int a_BlockZ)
1007  {
1008  return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
1009  }
1010 
1012  bool IsWeatherStorm(void) const { return (m_Weather == wStorm); }
1013 
1015  bool IsWeatherStormAt(int a_BlockX, int a_BlockZ)
1016  {
1017  return (IsWeatherStorm() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
1018  }
1019 
1021  bool IsWeatherWet(void) const { return !IsWeatherSunny(); }
1022 
1025  virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) override
1026  {
1027  auto Biome = GetBiomeAt(a_BlockX, a_BlockZ);
1028  return (IsWeatherWet() && !IsBiomeNoDownfall(Biome) && !IsBiomeCold(Biome));
1029  }
1030 
1035  virtual bool IsWeatherWetAtXYZ(Vector3i a_Pos);
1036 
1038  int GetSeed(void) { return m_Generator.GetSeed(); }
1039 
1040  // tolua_end
1041 
1043  cWorldStorage & GetStorage (void) { return m_Storage; }
1044  cChunkMap * GetChunkMap (void) { return m_ChunkMap.get(); }
1045 
1047  void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
1048 
1049  int GetMaxSugarcaneHeight(void) const { return m_MaxSugarcaneHeight; } // tolua_export
1050  int GetMaxCactusHeight (void) const { return m_MaxCactusHeight; } // tolua_export
1051 
1052  bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
1053 
1055  virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType, bool a_Baby = false) override; // tolua_export
1056 
1059  UInt32 SpawnMobFinalize(std::unique_ptr<cMonster> a_Monster);
1060 
1063  UInt32 CreateProjectile(Vector3d a_Pos, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = nullptr); // tolua_export
1064 
1068  UInt32 CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = nullptr); // tolua_export
1069 
1071  int GetTickRandomNumber(int a_Range);
1072 
1074  void TabCompleteUserName(const AString & a_Text, AStringVector & a_Results);
1075 
1078 
1084  void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export
1085 
1086 private:
1087 
1088  friend class cRoot;
1089 
1090  class cTickThread :
1091  public cIsThread
1092  {
1093  typedef cIsThread super;
1094  public:
1095  cTickThread(cWorld & a_World);
1096 
1097  protected:
1099 
1100  // cIsThread overrides:
1101  virtual void Execute(void) override;
1102  } ;
1103 
1108  {
1110 
1111  // cChunkSink overrides:
1112  virtual void OnChunkGenerated (cChunkDesc & a_ChunkDesc) override;
1113  virtual bool IsChunkValid (cChunkCoords a_Coords) override;
1114  virtual bool HasChunkAnyClients(cChunkCoords a_Coords) override;
1115  virtual bool IsChunkQueued (cChunkCoords a_Coords) override;
1116 
1117  // cPluginInterface overrides:
1118  virtual void CallHookChunkGenerating(cChunkDesc & a_ChunkDesc) override;
1119  virtual void CallHookChunkGenerated (cChunkDesc & a_ChunkDesc) override;
1120 
1121  public:
1122  cChunkGeneratorCallbacks(cWorld & a_World);
1123  } ;
1124 
1125 
1130 
1132 
1135 
1139 
1141 
1144 
1146 
1148  std::atomic<bool> m_IsSavingEnabled;
1149 
1152 
1154  double m_SpawnX;
1155  double m_SpawnY;
1156  double m_SpawnZ;
1157 
1158  // Variables defining the minimum and maximum size for a nether portal
1163 
1166 
1168 
1171  std::chrono::milliseconds m_WorldAge;
1172 
1173  std::chrono::milliseconds m_TimeOfDay;
1174  cTickTimeLong m_LastTimeUpdate; // The tick in which the last time update has been sent.
1175  cTickTimeLong m_LastChunkCheck; // The last WorldAge (in ticks) in which unloading and possibly saving was triggered
1176  cTickTimeLong m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred
1177  std::map<cMonster::eFamily, cTickTimeLong> m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
1178 
1180 
1186 
1187  std::vector<BlockTickQueueItem *> m_BlockTickQueue;
1188  std::vector<BlockTickQueueItem *> m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue
1189 
1190  std::unique_ptr<cSimulatorManager> m_SimulatorManager;
1191  std::unique_ptr<cSandSimulator> m_SandSimulator;
1194  std::unique_ptr<cFireSimulator> m_FireSimulator;
1196 
1199 
1201 
1202  unsigned int m_MaxPlayers;
1203 
1204  std::unique_ptr<cChunkMap> m_ChunkMap;
1205 
1207  std::set<eMonsterType> m_AllowedMobs;
1208 
1214 
1231 
1234 
1237 
1242 
1245 
1249 
1253 
1256 
1259 
1262 
1266 
1269 
1271  std::vector<std::pair<Int64, std::function<void(cWorld &)>>> m_Tasks;
1272 
1275 
1278 
1281 
1284 
1287 
1290 
1293 
1296 
1299 
1302 
1307  cWorld(
1308  const AString & a_WorldName, const AString & a_DataPath,
1309  cDeadlockDetect & a_DeadlockDetect, const AStringVector & a_WorldNames,
1310  eDimension a_Dimension = dimOverworld, const AString & a_LinkedOverworldName = {}
1311  );
1312  virtual ~cWorld() override;
1313 
1314  void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
1315 
1317  void TickWeather(float a_Dt);
1318 
1320  void TickMobs(std::chrono::milliseconds a_Dt);
1321 
1323  void TickQueuedTasks(void);
1324 
1326  void TickClients(float a_Dt);
1327 
1329  void UnloadUnusedChunks(void);
1330 
1331  void UpdateSkyDarkness(void);
1332 
1334  void GenerateRandomSpawn(int a_MaxSpawnRadius);
1335 
1338  bool CanSpawnAt(double a_X, double & a_Y, double a_Z);
1339 
1341  bool CheckPlayerSpawnPoint(int a_PosX, int a_PosY, int a_PosZ);
1342 
1344  eWeather ChooseNewWeather(void);
1345 
1347  cFluidSimulator * InitializeFluidSimulator(cIniFile & a_IniFile, const char * a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock);
1348 
1351 
1354  void AddQueuedPlayers(void);
1355 
1357  void InitializeAndLoadMobSpawningValues(cIniFile & a_IniFile);
1358 
1361  void SetChunkData(cSetChunkData & a_SetChunkData);
1362 
1366  bool GetLargeTreeAdjustment(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_SaplingMeta);
1367 }; // tolua_export
virtual bool IsDaylightCycleEnabled(void) const
Is the daylight cycle enabled?
Definition: World.h:100
size_t GetNumChunks() const
Returns the number of chunks loaded.
Definition: World.cpp:3103
AString GetLinkedOverworldName(void) const
Definition: World.h:910
virtual cBroadcastInterface & GetBroadcastManager(void) override
Definition: World.h:215
void SaveAllChunks(void)
Saves all chunks immediately.
Definition: World.cpp:2988
eGameMode m_GameMode
Definition: World.h:1181
virtual void BroadcastEntityEffect(const cEntity &a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle *a_Exclude=nullptr) override
void SetBlocks(const sSetBlockVector &a_Blocks)
Performs the specified single-block set operations simultaneously, as if SetBlock() was called for ea...
Definition: World.cpp:2153
virtual void BroadcastEntityRelMove(const cEntity &a_Entity, Vector3< Int8 > a_RelMove, const cClientHandle *a_Exclude=nullptr) override
virtual bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback) override
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox...
Definition: World.cpp:2729
NIBBLETYPE GetBlockSkyLight(Vector3i a_BlockPos)
Returns the sky light value at the specified block position.
Definition: World.cpp:1891
bool m_IsMelonStemBonemealable
Definition: World.h:1222
bool DigBlock(Vector3i a_BlockPos)
Replaces the specified block with air, and calls the apropriate block handlers (OnBreaking(), OnBroken()).
Definition: World.cpp:2180
bool ForEachLoadedChunk(cFunctionRef< bool(int, int)> a_Callback)
Calls the callback for each loaded chunk.
Definition: World.cpp:2979
eShrapnelLevel
Definition: BlockID.h:1220
bool TryGetHeight(int a_BlockX, int a_BlockZ, int &a_Height)
Retrieves the world height at the specified coords; returns false if chunk not loaded / generated...
Definition: World.cpp:2242
virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType, bool a_Baby=false) override
Spawns a mob of the specified type.
Definition: World.cpp:3190
std::chrono::duration< int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 >>> cTickTime
Definition: Globals.h:388
bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ)
Definition: World.cpp:3176
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, Int8 a_Animation, const cClientHandle *a_Exclude=nullptr) override
std::list< cClientHandlePtr > cClientHandlePtrs
Definition: Server.h:38
eGameMode
Definition: Defines.h:116
const AString & GetIniFileName(void) const
Returns the name of the world.ini file used by this world.
Definition: World.h:880
std::vector< std::pair< Int64, std::function< void(cWorld &)> > > m_Tasks
Tasks that have been queued onto the tick thread, possibly to be executed at target tick in the futur...
Definition: World.h:1271
cClientHandlePtrs m_ClientsToAdd
Clients that are scheduled for adding, waiting for TickClients to add them.
Definition: World.h:1283
eDimension
Dimension of a world.
Definition: BlockID.h:1127
void InitializeSpawn(void)
Definition: World.cpp:625
BLOCKTYPE GetBlock(Vector3i a_BlockPos)
Returns the block type at the specified position.
Definition: World.h:416
virtual void BroadcastScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode) override
AString m_LinkedOverworldName
The name of the overworld that portals in this world should link to.
Definition: World.h:1138
T x
Definition: Vector3.h:17
bool GetChunkBlockTypes(int a_ChunkX, int a_ChunkZ, BLOCKTYPE *a_BlockTypes)
Gets the chunk&#39;s blocks, only the block types.
Definition: World.cpp:2383
virtual void SpawnItemPickups(const cItems &a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool a_IsPlayerCreated=false) override
OBSOLETE, use the Vector3d-based overload instead.
Definition: World.h:550
void GenerateChunk(int a_ChunkX, int a_ChunkZ)
Generates the given chunk.
Definition: World.cpp:2943
void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:392
eWeather
Definition: Defines.h:151
bool GetBlockInfo(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_Meta, NIBBLETYPE &a_SkyLight, NIBBLETYPE &a_BlockLight)
Queries the whole block specification from the world.
Definition: World.h:512
virtual void BroadcastSpawnEntity(cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
int m_MinNetherPortalWidth
Definition: World.h:1159
virtual void SetMinNetherPortalWidth(int a_NewMinWidth) override
Definition: World.h:916
std::unique_ptr< cChunkMap > m_ChunkMap
Definition: World.h:1204
virtual void BroadcastPlayerListUpdateDisplayName(const cPlayer &a_Player, const AString &a_CustomName, const cClientHandle *a_Exclude=nullptr) override
int m_MaxRainTicks
Definition: World.h:1212
bool ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback a_Callback)
Calls the callback for each furnace in the specified chunk; returns true if all furnaces processed...
Definition: World.cpp:1390
virtual void SetTimeOfDay(int a_TimeOfDay) override
Definition: World.h:117
bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open)
Set the state of a trapdoor.
Definition: World.cpp:2908
virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback a_Callback) override
Calls the callback for the block entity at the specified coords; returns false if there&#39;s no block en...
Definition: World.cpp:1432
bool ShouldUseChatPrefixes(void) const
Definition: World.h:897
virtual void SetMaxNetherPortalHeight(int a_NewMaxHeight) override
Definition: World.h:923
void RemoveClientFromChunkSender(cClientHandle *a_Client)
Removes client from ChunkSender&#39;s queue of chunks to be sent.
Definition: World.cpp:2816
cChunkGeneratorThread m_Generator
The thread responsible for generating chunks.
Definition: World.h:1255
signed char Int8
Definition: Globals.h:110
std::list< cClientHandle * > cClientHandles
Definition: World.h:38
virtual int GetMaxNetherPortalHeight(void) const override
Definition: World.h:921
std::shared_ptr< cClientHandle > cClientHandlePtr
Definition: World.h:35
bool ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpenserCallback a_Callback)
Calls the callback for each dropspenser in the specified chunk; returns true if all dropspensers proc...
Definition: World.cpp:1381
bool m_IsCropsBonemealable
Definition: World.h:1220
virtual void BroadcastEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item, const cClientHandle *a_Exclude=nullptr) override
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta)
OBSOLETE, use the Vector3i-based overload instead.
Definition: World.h:499
int GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow)
Grows a sugarcane present at the block specified by the amount of blocks specified, up to the max height specified in the config; returns the amount of blocks the sugarcane grew inside this call.
Definition: World.cpp:1814
cFluidSimulator * m_WaterSimulator
Definition: World.h:1192
size_t GetNumUnusedDirtyChunks(void) const
Returns the number of unused dirty chunks.
Definition: World.cpp:3112
cCSLock super
Definition: World.h:79
virtual int GetMinNetherPortalHeight(void) const override
Returns or sets the minumim or maximum netherportal height.
Definition: World.h:920
bool CanSpawnAt(double a_X, double &a_Y, double a_Z)
Can the specified coordinates be used as a spawn point? Returns true if spawn position is valid and s...
Definition: World.cpp:749
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
bool m_IsMelonBonemealable
Definition: World.h:1223
virtual UInt32 SpawnItemPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem &a_Item, float a_SpeedX=0.f, float a_SpeedY=0.f, float a_SpeedZ=0.f, int a_LifetimeTicks=6000, bool a_CanCombine=true) override
OBSOLETE, use the Vector3d-based overload instead.
Definition: World.h:560
AString GetLinkedNetherWorldName(void) const
Definition: World.h:904
bool GrowTreeFromSapling(Vector3i a_BlockPos, NIBBLETYPE a_SaplingMeta)
Grows a tree at the specified coords, based on the sapling meta provided.
Definition: World.h:814
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
NIBBLETYPE m_SkyDarkness
Definition: World.h:1179
bool m_IsSpawnExplicitlySet
Definition: World.h:1153
void TouchChunk(int a_ChunkX, int a_ChunkZ)
Touches the chunk, causing it to be loaded or generated.
Definition: World.cpp:2825
void QueueSetChunkData(cSetChunkDataPtr a_SetChunkData)
Puts the chunk data into a queue to be set into the chunkmap in the tick thread.
Definition: World.cpp:2287
Despite the class name, this simulator takes care of all blocks that fall when suspended in the air...
Definition: SandSimulator.h:25
bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4, cPlayer *a_Player=nullptr)
Sets the sign text, asking plugins for permission first.
Definition: World.cpp:2852
void ForceSendChunkTo(int a_ChunkX, int a_ChunkZ, cChunkSender::eChunkPriority a_Priority, cClientHandle *a_Client)
Sends the chunk to the client specified, even if the client already has the chunk.
Definition: World.cpp:2806
bool ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCallback a_Callback)
Calls the callback for each dispenser in the specified chunk; returns true if all dispensers processe...
Definition: World.cpp:1363
double m_SpawnY
Definition: World.h:1155
std::map< cMonster::eFamily, cTickTimeLong > m_LastSpawnMonster
Definition: World.h:1177
int m_MinNetherPortalHeight
Definition: World.h:1161
std::chrono::milliseconds m_WorldAge
The age of the world.
Definition: World.h:1171
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
virtual int GetMinNetherPortalWidth(void) const override
Returns or sets the minumim or maximum netherportal width.
Definition: World.h:914
bool DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback a_Callback)
Calls the callback for the dropper at the specified coords; returns false if there&#39;s no dropper at th...
Definition: World.cpp:1486
eWeather ChooseNewWeather(void)
Chooses a reasonable transition from the current weather to a new weather.
Definition: World.cpp:864
int m_MaxThunderStormTicks
Definition: World.h:1213
bool m_IsCarrotsBonemealable
Definition: World.h:1219
bool DigBlock(int a_X, int a_Y, int a_Z)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:666
std::unique_ptr< cFireSimulator > m_FireSimulator
Definition: World.h:1194
Definition: Player.h:27
void AddEntity(OwnedEntity a_Entity)
Adds the entity into its appropriate chunk; takes ownership of the entity ptr.
Definition: World.cpp:3035
bool DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBrewingstandCallback a_Callback)
Calls the callback for the brewingstand at the specified coords; returns false if there&#39;s no brewings...
Definition: World.cpp:1459
void RemoveClientFromChunks(cClientHandle *a_Client)
Removes the client from all chunks it is present in.
Definition: World.cpp:2788
bool IsDeepSnowEnabled(void) const
Definition: World.h:145
int GetMaxViewDistance(void) const
Definition: World.h:894
bool GrowTreeByBiome(int a_BlockX, int a_BlockY, int a_BlockZ)
Grows a tree at the specified coords, based on the biome in the place.
Definition: World.cpp:1717
void ChunkLighted(int a_ChunkX, int a_ChunkZ, const cChunkDef::BlockNibbles &a_BlockLight, const cChunkDef::BlockNibbles &a_SkyLight)
Definition: World.cpp:2361
double m_SpawnX
Definition: World.h:1154
void QueueUnloadUnusedChunks(void)
Queues a task to unload unused chunks onto the tick thread.
Definition: World.cpp:2429
UInt32 SpawnFallingBlock(Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Spawns an falling block entity at the given position.
Definition: World.cpp:2008
void UpdateSkyDarkness(void)
Definition: World.cpp:1283
bool IsBiomeCold(EMCSBiome a_Biome)
Returns true if the biome is cold (has snow and snowfall at higher elevations but not at regular heig...
Definition: BiomeDef.cpp:194
virtual void BroadcastPlayerListUpdatePing(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
void ChangeWeather(void)
Forces a weather change in the next game tick.
Definition: World.cpp:551
void Start()
Starts threads that belong to this world.
Definition: World.cpp:654
virtual bool IsWeatherWetAtXYZ(Vector3i a_Pos)
Returns true if the specified location has wet weather (rain or storm), using the same logic as IsWea...
Definition: World.cpp:561
bool IsPVPEnabled(void) const
Definition: World.h:143
static const char * GetClassStatic(void)
Definition: World.h:84
bool GrowTreeImage(const sSetBlockVector &a_Blocks)
Imprints the specified blocks into the world, as long as each log block replaces only allowed blocks...
Definition: World.cpp:1731
int m_MaxSugarcaneHeight
Definition: World.h:1216
int m_MaxViewDistance
The maximum view distance that a player can have in this world.
Definition: World.h:1244
virtual bool DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback a_Callback) override
Calls the callback for the bed at the specified coords; returns false if there&#39;s no bed at those coor...
Definition: World.cpp:1450
cCriticalSection m_CSEntitiesToAdd
Guards m_EntitiesToAdd.
Definition: World.h:1286
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 SendPlayerList(cPlayer *a_DestPlayer)
Definition: World.cpp:2693
cIsThread super
Definition: World.h:1093
cTickTimeLong m_LastSave
Definition: World.h:1176
UInt32 SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType, const cItem &a_Content=cItem(), int a_BlockHeight=1)
OBSOLETE, use the Vector3d-based overload instead.
Definition: World.h:584
void SetLinkedNetherWorldName(const AString &a_Name)
Definition: World.h:905
bool IsWeatherWet(void) const
Returns true if the world currently has any precipitation - rain, storm or snow.
Definition: World.h:1021
std::atomic< bool > m_IsSavingEnabled
Whether or not writing chunks to disk is currently enabled.
Definition: World.h:1148
The interface through which the plugins are called for their OnChunkGenerating / OnChunkGenerated hoo...
virtual void BroadcastDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display) override
cSimulatorManager * GetSimulatorManager(void)
Definition: World.h:713
bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback a_Callback)
Calls the callback for the noteblock at the specified coords; returns false if there&#39;s no noteblock a...
Definition: World.cpp:1513
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
int GrowPlantAt(Vector3i a_BlockPos, int a_NumStages=1)
Grows the plant at the specified position by at most a_NumStages.
Definition: World.cpp:1776
std::list< cPlayer * > cPlayerList
Definition: Window.h:31
virtual void SetDaylightCycleEnabled(bool a_IsDaylightCycleEnabled)
Sets the daylight cycle to true / false.
Definition: World.h:103
bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const
Definition: World.cpp:2410
eWeather GetWeather(void) const
Returns the current weather.
Definition: World.h:991
bool DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadCallback a_Callback)
Calls the callback for the mob head block at the specified coords; returns false if there&#39;s no mob he...
Definition: World.cpp:1531
cCriticalSection m_CSSetChunkDataQueue
CS protecting m_SetChunkDataQueue.
Definition: World.h:1298
void MarkChunkSaved(int a_ChunkX, int a_ChunkZ)
Definition: World.cpp:2278
Represents two sets of coords, minimum and maximum for each direction.
Definition: BoundingBox.h:23
bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const
Returns true iff the chunk is in the loader / generator queue.
Definition: World.cpp:2392
void QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, int a_TicksToWait)
Queues the block to be ticked after the specified number of game ticks.
Definition: World.cpp:3161
bool DropBlockAsPickups(Vector3i a_BlockPos, const cEntity *a_Digger=nullptr, const cItem *a_Tool=nullptr)
Digs the specified block, and spawns the appropriate pickups for it.
Definition: World.cpp:2200
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
Definition: BiomeDef.h:21
eKind
The kind of the projectile.
virtual void BroadcastDetachEntity(const cEntity &a_Entity, const cEntity &a_PreviousVehicle) override
bool m_BroadcastDeathMessages
Definition: World.h:1164
size_t GetSaveQueueLength(void)
bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ)
Returns true if it is sunny at the specified location.
Definition: World.h:997
virtual void WakeUpSimulators(Vector3i a_Block) override
Wakes up the simulators for the specified block.
Definition: World.cpp:1308
void SpawnItemPickups(const cItems &a_Pickups, Vector3i a_BlockPos, double a_FlyAwaySpeed=1.0, bool a_IsPlayerCreated=false)
Spawns item pickups for each item in the list.
Definition: World.cpp:1936
void QueueSaveAllChunks(void)
Queues a task to save all chunks onto the tick thread.
Definition: World.cpp:3001
eShrapnelLevel GetTNTShrapnelLevel(void) const
Definition: World.h:891
bool DoWithEntityByID(UInt32 a_UniqueID, cEntityCallback a_Callback)
Calls the callback if the entity with the specified ID is found, with the entity object as the callba...
Definition: World.cpp:2738
bool IsGameModeSpectator(void) const
Returns true if the world is in Spectator mode.
Definition: World.h:141
T y
Definition: Vector3.h:17
void TickMobs(std::chrono::milliseconds a_Dt)
Handles the mob spawning / moving / destroying each tick.
Definition: World.cpp:1103
NIBBLETYPE GetBlockMeta(Vector3i a_BlockPos)
Returns the block meta at the specified position.
Definition: World.h:431
UInt32 SpawnItemPickup(Vector3d a_Pos, const cItem &a_Item, Vector3f a_Speed, int a_LifetimeTicks=6000, bool a_CanCombine=true)
Spawns a single pickup containing the specified item.
Definition: World.cpp:1993
std::unique_ptr< cPlayer > RemovePlayer(cPlayer &a_Player, bool a_RemoveFromChunk)
Removes the player from the world.
Definition: World.cpp:2457
virtual void BroadcastEntityRelMoveLook(const cEntity &a_Entity, Vector3< Int8 > a_RelMove, const cClientHandle *a_Exclude=nullptr) override
UInt32 SpawnBoat(double a_X, double a_Y, double a_Z, cBoat::eMaterial a_Material)
Definition: World.h:590
eMonsterType
Identifies individual monster type, as well as their network type-ID.
Definition: MonsterTypes.h:10
Takes requests for generating chunks and processes them in a separate thread one by one...
std::vector< cSetChunkDataPtr > cSetChunkDataPtrs
Definition: World.h:59
T z
Definition: Vector3.h:17
void QueueTask(std::function< void(cWorld &)> a_Task)
Queues a task onto the tick thread.
Definition: World.cpp:3010
cFluidSimulator * GetWaterSimulator(void)
Definition: World.h:715
int GetDefaultWeatherInterval(eWeather a_Weather)
Returns the default weather interval for the specific weather type.
Definition: World.cpp:497
virtual void BroadcastChatWarning(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
Definition: World.h:174
virtual void BroadcastChatFailure(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
Definition: World.h:172
void GetChunkStats(int &a_NumValid, int &a_NumDirty, int &a_NumInLightingQueue)
Returns the number of chunks loaded and dirty, and in the lighting queue.
Definition: World.cpp:3121
UInt32 SpawnExperienceOrb(Vector3d a_Pos, int a_Reward)
Spawns an experience orb at the given location with the given reward.
Definition: World.cpp:2024
void PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_CallAfter={})
Queues the chunk for preparing - making sure that it&#39;s generated and lit.
Definition: World.cpp:2834
void TickWeather(float a_Dt)
Handles the weather in each tick.
Definition: World.cpp:1069
int GetMaxSugarcaneHeight(void) const
Definition: World.h:1049
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
bool ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallback a_Callback)
Calls the callback for each dropper in the specified chunk; returns true if all droppers processed...
Definition: World.cpp:1372
void SetLinkedEndWorldName(const AString &a_Name)
Definition: World.h:908
bool m_IsGrassBonemealable
Definition: World.h:1221
bool IsBiomeNoDownfall(EMCSBiome a_Biome)
Returns true if the biome has no downfall - deserts and savannas.
Definition: BiomeDef.cpp:140
cTickThread m_TickThread
Definition: World.h:1265
virtual void BroadcastChatFatal(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
Definition: World.h:175
cWorldStorage m_Storage
Definition: World.h:1200
Definition: UUID.h:10
bool IsWeatherSunny(void) const
Returns true if the current weather is sunny.
Definition: World.h:994
void MarkChunkDirty(int a_ChunkX, int a_ChunkZ)
Definition: World.cpp:2260
int GetTickRandomNumber(int a_Range)
Returns a random number in range [0 .
Definition: World.cpp:3271
int m_MinThunderStormTicks
Definition: World.h:1213
Manages the in-game maps of a single world - Thread safe.
Definition: MapManager.h:28
cRedstoneSimulator * InitializeRedstoneSimulator(cIniFile &a_IniFile)
Creates a new redstone simulator.
Definition: World.cpp:3343
cEntityList m_EntitiesToAdd
List of entities that are scheduled for adding, waiting for the Tick thread to add them...
Definition: World.h:1289
virtual bool WriteBlockArea(cBlockArea &a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override
Writes the block area into the specified coords.
Definition: World.cpp:1927
std::vector< AString > AStringVector
Definition: StringUtils.h:14
std::vector< OwnedEntity > cEntityList
Definition: ChunkDef.h:33
void SetLinkedOverworldName(const AString &a_Name)
Definition: World.h:911
bool AddChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle *a_Client)
Adds client to a chunk, if not already present; returns true if added, false if present.
Definition: World.cpp:2770
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...
cLightingThread m_Lighting
Definition: World.h:1264
cCriticalSection m_CSPlayers
Definition: World.h:1197
int m_StorageCompressionFactor
Definition: World.h:1145
bool m_bEnabledPVP
Definition: World.h:1182
bool ForEachBrewingstandInChunk(int a_ChunkX, int a_ChunkZ, cBrewingstandCallback a_Callback)
Calls the callback for each brewingstand in the specified chunk; returns true if all brewingstands pr...
Definition: World.cpp:1345
size_t m_UnusedDirtyChunksCap
The maximum number of allowed unused dirty chunks for this world.
Definition: World.h:1129
bool m_IsBeetrootsBonemealable
Definition: World.h:1217
void SetShouldUseChatPrefixes(bool a_Flag)
Definition: World.h:898
Container for a single chat message composed of multiple functional parts.
Definition: CompositeChat.h:31
bool GetBlocks(sSetBlockVector &a_Blocks, bool a_ContinueOnFailure)
Retrieves block types of the specified blocks.
Definition: World.cpp:2171
bool GetLargeTreeAdjustment(int &a_BlockX, int &a_BlockY, int &a_BlockZ, NIBBLETYPE a_SaplingMeta)
Checks if the sapling at the specified block coord is a part of a large-tree sapling (2x2)...
Definition: World.cpp:1631
virtual void BroadcastDestroyEntity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
void InitializeAndLoadMobSpawningValues(cIniFile &a_IniFile)
Sets mob spawning values if nonexistant to their dimension specific defaults.
Definition: World.cpp:887
void AddQueuedPlayers(void)
Adds the players queued in the m_PlayersToAdd queue into the m_Players list.
Definition: World.cpp:3448
cCriticalSection m_CSTasks
Guards the m_Tasks.
Definition: World.h:1268
void TickQueuedBlocks(void)
Processes the blocks queued for ticking with a delay (m_BlockTickQueue[])
Definition: World.cpp:3131
int m_MaxSunnyTicks
Definition: World.h:1211
bool GrowTree(int a_BlockX, int a_BlockY, int a_BlockZ)
Grows a tree at the specified coords.
Definition: World.cpp:1576
bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback a_Callback)
Calls the callback for the dispenser at the specified coords; returns false if there&#39;s no dispenser a...
Definition: World.cpp:1477
cCriticalSection m_CSClients
Guards m_Clients.
Definition: World.h:1274
void SetSavingEnabled(bool a_IsSavingEnabled)
Set whether saving chunks is enabled.
Definition: World.h:95
double GetSpawnY(void) const
Definition: World.h:692
bool m_bCommandBlocksEnabled
Whether command blocks are enabled or not.
Definition: World.h:1233
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta)
Retrieves the block type and meta at the specified coords.
Definition: World.cpp:1909
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
Interface class used for comparing clients of two chunks.
Definition: ChunkDef.h:500
bool GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString &a_Line1, AString &a_Line2, AString &a_Line3, AString &a_Line4)
Retrieves the test on the sign at the specified coords; returns false if there&#39;s no sign at those coo...
Definition: World.cpp:1549
UInt32 SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
OBSOLETE, use the Vector3i-based overload instead.
Definition: World.h:572
Definition: World.h:65
virtual void BroadcastAttachEntity(const cEntity &a_Entity, const cEntity &a_Vehicle) override
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback &a_Callback) override
Calls the callback for each chunk in the coords specified (all cords are inclusive).
Definition: World.cpp:2970
cMapManager m_MapManager
Definition: World.h:1258
eGameMode GetGameMode(void) const
Returns the current game mode.
Definition: World.h:129
cLightingThread & GetLightingThread(void)
Definition: World.h:954
bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback a_Callback)
Calls the callback for each block entity in the specified chunk; returns true if all block entities p...
Definition: World.cpp:1336
virtual void BroadcastTimeUpdate(const cClientHandle *a_Exclude=nullptr) override
NIBBLETYPE GetSkyDarkness()
Get the current darkness level based on the time.
Definition: World.h:1077
bool GrowRipePlant(Vector3i a_BlockPos)
Grows the plant at the specified block to its ripe stage.
Definition: World.cpp:1785
eWeather m_Weather
Definition: World.h:1209
const AString & GetDataPath(void) const
Returns the data path to the world data.
Definition: World.h:877
std::chrono::duration< Int64, cTickTime::period > cTickTimeLong
Definition: Globals.h:389
eMaterial
Definition: Boat.h:24
cFluidSimulator * GetLavaSimulator(void)
Definition: World.h:716
cMapManager & GetMapManager(void)
Returns the associated map manager instance.
Definition: World.h:886
virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) override
Returns true if it is raining or storming at the specified location.
Definition: World.h:1025
bool m_IsTallGrassBonemealable
Definition: World.h:1230
cWorld(const AString &a_WorldName, const AString &a_DataPath, cDeadlockDetect &a_DeadlockDetect, const AStringVector &a_WorldNames, eDimension a_Dimension=dimOverworld, const AString &a_LinkedOverworldName={})
Construct the world and read settings from its ini file.
Definition: World.cpp:142
void TickClients(float a_Dt)
Ticks all clients that are in this world.
Definition: World.cpp:1232
bool IsGameModeAdventure(void) const
Returns true if the world is in Adventure mode.
Definition: World.h:138
void SetMaxViewDistance(int a_MaxViewDistance)
Definition: World.cpp:1864
void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
Definition: World.cpp:975
std::list< cClientHandle * > cClientHandles
Definition: Server.h:39
virtual int GetTimeOfDay(void) const override
Definition: World.h:110
cTickTimeLong m_LastTimeUpdate
Definition: World.h:1174
virtual void BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle *a_Exclude=nullptr) override
AString m_DataPath
The path to the root directory for the world files.
Definition: World.h:1134
AString m_WorldName
Definition: World.h:1131
void CollectPickupsByPlayer(cPlayer &a_Player)
Definition: World.cpp:2438
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ)
Definition: World.cpp:2269
bool ForEachEntity(cEntityCallback a_Callback)
Calls the callback for each entity in the entire world; returns true if all entities processed...
Definition: World.cpp:2711
AString m_IniFileName
Definition: World.h:1140
bool FindAndDoWithPlayer(const AString &a_PlayerNameHint, cPlayerListCallback a_Callback)
Finds a player from a partial or complete player name and calls the callback - case-insensitive.
Definition: World.cpp:2586
cChunkSender m_ChunkSender
Definition: World.h:1263
size_t GetQueueLength(void)
virtual void SpawnItemPickups(const cItems &a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed=1.0, bool a_IsPlayerCreated=false) override
OBSOLETE, use the Vector3d-based overload instead.
Definition: World.h:540
bool m_VillagersShouldHarvestCrops
Definition: World.h:1185
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ)
Definition: World.cpp:2961
virtual Int64 GetWorldAge(void) const override
Definition: World.h:109
bool IsGameModeCreative(void) const
Returns true if the world is in Creative mode.
Definition: World.h:132
cScoreboard & GetScoreBoard(void)
Returns the associated scoreboard instance.
Definition: World.h:883
UInt32 CreateProjectile(Vector3d a_Pos, cProjectileEntity::eKind a_Kind, cEntity *a_Creator, const cItem *a_Item, const Vector3d *a_Speed=nullptr)
Creates a projectile of the specified type.
Definition: World.cpp:3241
std::vector< UInt32 > SpawnSplitExperienceOrbs(double a_X, double a_Y, double a_Z, int a_Reward)
OBSOLETE, use the Vector3d-based overload instead.
Definition: World.h:621
bool DoWithNearestPlayer(Vector3d a_Pos, double a_RangeLimit, cPlayerListCallback a_Callback, bool a_CheckLineOfSight=true, bool a_IgnoreSpectator=true)
Calls the callback for nearest player for given position, Returns false if player not found...
Definition: World.cpp:2639
void Stop(cDeadlockDetect &a_DeadlockDetect)
Stops threads that belong to this world (part of deinit).
Definition: World.cpp:926
virtual void BroadcastPlayerListAddPlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
void LOGWARNING(const char *a_Format, fmt::ArgList a_ArgList)
Definition: Logger.cpp:174
AString GetLinkedEndWorldName(void) const
Definition: World.h:907
bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback a_Callback)
Calls the callback for the command block at the specified coords; returns false if there&#39;s no command...
Definition: World.cpp:1522
bool m_IsDeepSnowEnabled
Definition: World.h:1183
size_t GetLightingQueueLength(void)
Definition: World.h:950
std::set< eMonsterType > m_AllowedMobs
Definition: World.h:1207
virtual void BroadcastChatSuccess(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
Definition: World.h:173
bool ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback a_Callback)
Calls the callback for each entity in the specified chunk; returns true if all entities processed...
Definition: World.cpp:2720
virtual eDimension GetDimension(void) const override
Definition: World.h:151
NIBBLETYPE GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:469
virtual void BroadcastPlayerListUpdateGameMode(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback &a_Callback)
Compares clients of two chunks, calls the callback accordingly.
Definition: World.cpp:2761
bool m_IsPotatoesBonemealable
Definition: World.h:1224
bool m_IsCactusBonemealable
Definition: World.h:1218
virtual void SetMinNetherPortalHeight(int a_NewMinHeight) override
Definition: World.h:922
bool VillagersShouldHarvestCrops(void) const
Definition: World.h:149
UInt32 SpawnMinecart(Vector3d a_Pos, int a_MinecartType, const cItem &a_Content=cItem(), int a_BlockHeight=1)
Spawns an minecart at the given coordinates.
Definition: World.cpp:2088
bool m_IsSaplingBonemealable
Definition: World.h:1227
bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback a_Callback)
Calls the callback for the chest at the specified coords; returns false if there&#39;s no chest at those ...
Definition: World.cpp:1468
Definition: Cuboid.h:9
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty=true, bool a_ShouldInformClients=true)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:455
size_t GetStorageSaveQueueLength(void)
Definition: World.h:952
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:409
virtual void BroadcastLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo) override
virtual void BroadcastChatInfo(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
Definition: World.h:171
bool ShouldLavaSpawnFire(void) const
Definition: World.h:147
cWorldStorage & GetStorage(void)
Definition: World.h:1043
void ScheduleTask(int a_DelayTicks, std::function< void(cWorld &)> a_Task)
Queues a lambda task onto the tick thread, with the specified delay.
Definition: World.cpp:3020
int GetMaxCactusHeight(void) const
Definition: World.h:1050
bool DoWithPlayer(const AString &a_PlayerName, cPlayerListCallback a_Callback)
Calls the callback for the player of the given name; returns true if the player was found and the cal...
Definition: World.cpp:2567
double GetSpawnZ(void) const
Definition: World.h:693
eShrapnelLevel m_TNTShrapnelLevel
The level of DoExplosionAt() projecting random affected blocks as FallingBlock entities See the eShra...
Definition: World.h:1241
size_t GetLoadQueueLength(void)
std::list< cPlayer * > cPlayerList
Definition: World.h:53
void CastThunderbolt(Vector3i a_Block)
Casts a thunderbolt at the specified coords.
Definition: World.cpp:487
bool m_IsPumpkinStemBonemealable
Definition: World.h:1225
bool IsChunkValid(int a_ChunkX, int a_ChunkZ) const
Returns true iff the chunk is present and valid.
Definition: World.cpp:2401
#define UNUSED
Definition: Globals.h:152
The root of the object hierarchy.
Definition: Root.h:48
Definition: Defines.h:159
double m_SpawnZ
Definition: World.h:1156
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ)
Marks the chunk as failed-to-load:
Definition: World.cpp:2843
bool GetChunkData(cChunkCoords a_Coords, cChunkDataCallback &a_Callback) const
Calls the callback with the chunk&#39;s data, if available (with ChunkCS locked).
Definition: World.cpp:2374
bool ShouldBroadcastDeathMessages(void) const
Definition: World.h:900
void GenerateRandomSpawn(int a_MaxSpawnRadius)
Generates a random spawnpoint on solid land by walking chunks and finding their biomes.
Definition: World.cpp:667
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
eExplosionSource
The source of an explosion.
Definition: BlockID.h:1202
NIBBLETYPE GetBlockBlockLight(Vector3i a_BlockPos)
Returns the block-light value at the specified block position.
Definition: World.cpp:1900
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:424
void WakeUpSimulatorsInArea(const cCuboid &a_Area)
Wakes up the simulators for the specified area of blocks.
Definition: World.cpp:1327
int GetTicksUntilWeatherChange(void) const
Definition: World.h:97
virtual int GetHeight(int a_BlockX, int a_BlockZ) override
Returns the world height at the specified coords; waits for the chunk to get loaded / generated...
Definition: World.cpp:2233
void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
Sets the blockticking to start at the specified block.
Definition: World.cpp:589
UInt32 SpawnMobFinalize(std::unique_ptr< cMonster > a_Monster)
Wraps cEntity::Initialize, doing Monster-specific things before spawning the monster.
Definition: World.cpp:3211
std::vector< BlockTickQueueItem * > m_BlockTickQueue
Definition: World.h:1187
cClientHandlePtrs m_Clients
List of clients in this world, these will be ticked by this world.
Definition: World.h:1277
cChunkMap * GetChunkMap(void)
Definition: World.h:1044
bool SetSpawn(double a_X, double a_Y, double a_Z)
Set default spawn at the given coordinates.
Definition: World.cpp:598
bool IsWeatherRain(void) const
Returns true if the current weather is rainy.
Definition: World.h:1003
bool GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal=false)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:842
cScoreboard m_Scoreboard
Definition: World.h:1257
int m_MinRainTicks
Definition: World.h:1212
bool SetBiomeAt(int a_BlockX, int a_BlockZ, EMCSBiome a_Biome)
Sets the biome at the specified coords.
Definition: World.cpp:1833
virtual void BroadcastCollectEntity(const cEntity &a_Pickup, const cPlayer &a_Player, int a_Count, const cClientHandle *a_Exclude=nullptr) override
void TickQueuedTasks(void)
Executes all tasks queued onto the tick thread.
Definition: World.cpp:1190
std::string AString
Definition: StringUtils.h:13
int m_MinSunnyTicks
Definition: World.h:1211
virtual ~cWorld() override
Definition: World.cpp:451
const AString & GetName(void) const
Returns the name of the world.
Definition: World.h:874
bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome)
Sets the biome at the area.
Definition: World.cpp:1842
int GrowCactus(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow)
Grows a cactus present at the block specified by the amount of blocks specified, up to the max height...
Definition: World.cpp:1794
Implementation of the callbacks that the ChunkGenerator uses to store new chunks and interface to plu...
Definition: World.h:1105
virtual std::vector< UInt32 > SpawnSplitExperienceOrbs(Vector3d a_Pos, int a_Reward) override
Spawns experience orbs of the specified total value at the given location.
Definition: World.cpp:2045
virtual void BroadcastScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode) override
cCriticalSection m_CSPlayersToAdd
Guards m_PlayersToAdd.
Definition: World.h:1292
cChunkGeneratorThread & GetGenerator(void)
Definition: World.h:1042
void SetCommandBlocksEnabled(bool a_Flag)
Definition: World.h:889
bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString &a_Command)
Sets the command block command.
Definition: World.cpp:2877
bool IsGameModeSurvival(void) const
Returns true if the world is in Survival mode.
Definition: World.h:135
cClientHandles m_ClientsToRemove
Clients that are scheduled for removal (ticked in another world), waiting for TickClients() to remove...
Definition: World.h:1280
void ReplaceBlocks(const sSetBlockVector &a_Blocks, BLOCKTYPE a_FilterBlockType)
Replaces world blocks with a_Blocks, if they are of type a_FilterBlockType.
Definition: World.cpp:2162
bool IsWeatherRainAt(int a_BlockX, int a_BlockZ)
Returns true if it is raining at the specified location.
Definition: World.h:1006
bool DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback a_Callback)
Calls the callback for the beacon at the specified coords; returns false if there&#39;s no beacon at thos...
Definition: World.cpp:1441
virtual int GetMaxNetherPortalWidth(void) const override
Definition: World.h:915
virtual void BroadcastEntityHeadLook(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
cLock(cWorld &a_World)
Definition: World.cpp:91
bool IsWeatherStormAt(int a_BlockX, int a_BlockZ)
Returns true if the weather is stormy at the specified location.
Definition: World.h:1015
bool IsWeatherStorm(void) const
Returns true if the current weather is stormy.
Definition: World.h:1012
virtual void BroadcastChatDeath(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
Definition: World.h:176
int m_MaxNetherPortalWidth
Definition: World.h:1160
virtual void BroadcastUnleashEntity(const cEntity &a_Entity) override
AString m_LinkedNetherWorldName
Name of the nether world - where Nether portals should teleport.
Definition: World.h:1248
virtual void BroadcastEntityVelocity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void *a_SourceData) override
Does an explosion with the specified strength at the specified coordinates.
Definition: World.cpp:1399
Definition: Entity.h:73
cChunkGeneratorCallbacks m_GeneratorCallbacks
The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins.
Definition: World.h:1261
virtual void BroadcastWeather(eWeather a_Weather, const cClientHandle *a_Exclude=nullptr) override
RAII for cCriticalSection - locks the CS on creation, unlocks on destruction.
bool ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback a_Callback)
Calls the callback for each chest in the specified chunk; returns true if all chests processed...
Definition: World.cpp:1354
UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec=80, double a_InitialVelocityCoeff=1)
Definition: World.h:629
bool m_IsSugarcaneBonemealable
Definition: World.h:1228
void QueueLightChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_Callback={})
Queues a chunk for lighting; a_Callback is called after the chunk is lighted.
Definition: World.cpp:2952
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
Definition: World.h:400
bool m_bAnimals
Definition: World.h:1206
bool IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ)
Is the trapdoor open? Returns false if there is no trapdoor at the specified coords.
Definition: World.cpp:2891
bool m_bUseChatPrefixes
Whether prefixes such as [INFO] are prepended to SendMessageXXX() / BroadcastChatXXX() functions...
Definition: World.h:1236
int GetGeneratorQueueLength(void)
Definition: World.h:949
unsigned int UInt32
Definition: Globals.h:113
bool DoWithPlayerByUUID(const cUUID &a_PlayerUUID, cPlayerListCallback a_Callback)
Finds the player over his uuid and calls the callback.
Definition: World.cpp:2622
void RemoveChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle *a_Client)
Removes client from the chunk specified.
Definition: World.cpp:2779
int m_WeatherInterval
Definition: World.h:1210
std::unique_ptr< cEntity > OwnedEntity
Definition: ChunkDef.h:32
void SetTicksUntilWeatherChange(int a_WeatherInterval)
Definition: World.h:112
bool GetBlockInfo(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_Meta, NIBBLETYPE &a_SkyLight, NIBBLETYPE &a_BlockLight)
Queries the whole block specification from the world.
Definition: World.cpp:1918
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle &a_Client)
If there is a block entity at the specified coords, sends it to the client specified.
Definition: World.cpp:2251
AString m_StorageSchema
Name of the storage schema used to load and save chunks.
Definition: World.h:1143
void SetTNTShrapnelLevel(eShrapnelLevel a_Flag)
Definition: World.h:892
cItems PickupsFromBlock(Vector3i a_BlockPos, const cEntity *a_Digger=nullptr, const cItem *a_Tool=nullptr)
Returns all the pickups that would result if the a_Digger dug up the block at a_BlockPos using a_Tool...
Definition: World.cpp:2215
NIBBLETYPE BlockNibbles[NumBlocks/2]
The type used for block data in nibble format, AXIS_ORDER ordering.
Definition: ChunkDef.h:153
bool ShouldBroadcastAchievementMessages(void) const
Definition: World.h:901
NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:481
EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ)
Returns the biome at the specified coords.
Definition: World.cpp:1824
eMessageType
Definition: Defines.h:976
void SendChunkTo(int a_ChunkX, int a_ChunkZ, cChunkSender::eChunkPriority a_Priority, cClientHandle *a_Client)
Sends the chunk to the client specified, if the client doesn&#39;t have the chunk yet.
Definition: World.cpp:2797
void UseBlockEntity(cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
a_Player is using block entity at [x, y, z], handle that:
Definition: World.h:789
void TabCompleteUserName(const AString &a_Text, AStringVector &a_Results)
Appends all usernames starting with a_Text (case-insensitive) into Results.
Definition: World.cpp:3280
bool HasEntity(UInt32 a_UniqueID)
Returns true if an entity with the specified UniqueID exists in the world.
Definition: World.cpp:3046
cRedstoneSimulator * GetRedstoneSimulator(void)
Definition: World.h:717
unsigned char Byte
Definition: Globals.h:117
bool GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType)
Grows a melon or a pumpkin next to the block specified (assumed to be the stem); returns true if the ...
Definition: World.cpp:1804
bool CheckPlayerSpawnPoint(int a_PosX, int a_PosY, int a_PosZ)
Check if player starting point is acceptable.
Definition: World.cpp:822
The interface through which the generated chunks are handed to the cWorld or whoever created us...
void AddPlayer(std::unique_ptr< cPlayer > a_Player, cWorld *a_OldWorld=nullptr)
Adds the player to the world.
Definition: World.cpp:2447
AString m_LinkedEndWorldName
Name of the End world - where End portals should teleport.
Definition: World.h:1252
int GetSeed(void)
Returns the seed of the world.
Definition: World.h:1038
cSetChunkDataPtrs m_SetChunkDataQueue
Queue for the chunk data to be set into m_ChunkMap by the tick thread.
Definition: World.h:1301
bool m_IsPumpkinBonemealable
Definition: World.h:1226
cTickTimeLong m_LastChunkCheck
Definition: World.h:1175
int m_MaxCactusHeight
Definition: World.h:1215
The fire simulator takes care of the fire blocks.
Definition: FireSimulator.h:17
bool m_ShouldLavaSpawnFire
Definition: World.h:1184
cRedstoneSimulator * m_RedstoneSimulator
Definition: World.h:1195
std::unique_ptr< cSimulatorManager > m_SimulatorManager
Definition: World.h:1190
virtual void BroadcastUseBed(const cEntity &a_Entity, Vector3i a_BlockPos) override
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty=true, bool a_ShouldInformClients=true)
Sets the meta for the specified block, while keeping the blocktype.
Definition: World.cpp:1882
size_t GetStorageLoadQueueLength(void)
Definition: World.h:951
std::list< cClientHandlePtr > cClientHandlePtrs
Definition: World.h:37
virtual void BroadcastEntityLook(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
bool DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlowerPotCallback a_Callback)
Calls the callback for the flower pot at the specified coords; returns false if there&#39;s no flower pot...
Definition: World.cpp:1540
eDimension m_Dimension
The dimension of the world, used by the client to provide correct lighting scheme.
Definition: World.h:1151
bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback a_Callback)
Calls the callback for the furnace at the specified coords; returns false if there&#39;s no furnace at th...
Definition: World.cpp:1504
OwnedEntity RemoveEntity(cEntity &a_Entity)
Removes the entity from the world.
Definition: World.cpp:3073
void UnloadUnusedChunks(void)
Unloads all chunks immediately.
Definition: World.cpp:2419
void SetWeather(eWeather a_NewWeather)
Sets the specified weather; resets weather interval; asks and notifies plugins of the change...
Definition: World.cpp:522
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
Definition: World.cpp:1873
void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
Definition: World.h:702
cPlayerList m_Players
Definition: World.h:1198
virtual void BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle *a_Exclude=nullptr) override
void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked=true)
Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specifie...
Definition: World.cpp:3334
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
OBSOLETE, use the Vector3-based overload instead.
Definition: World.h:439
void SetChunkData(cSetChunkData &a_SetChunkData)
Sets the specified chunk data into the chunkmap.
Definition: World.cpp:2313
The actual world storage class.
Definition: WorldStorage.h:54
Definition: Item.h:36
EffectID
Definition: EffectID.h:5
cFluidSimulator * m_LavaSimulator
Definition: World.h:1193
bool m_BroadcastAchievementMessages
Definition: World.h:1165
cWorld & m_World
Definition: World.h:1098
std::unique_ptr< cSetChunkData > cSetChunkDataPtr
Definition: World.h:58
signed long long Int64
Definition: Globals.h:107
The interface that all chunk generators must implement to provide the generated chunks.
void RegenerateChunk(int a_ChunkX, int a_ChunkZ)
Regenerate the given chunk:
Definition: World.cpp:2932
virtual void SetMaxNetherPortalWidth(int a_NewMaxWidth) override
Definition: World.h:917
cFluidSimulator * InitializeFluidSimulator(cIniFile &a_IniFile, const char *a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock)
Creates a new fluid simulator, loads its settings from the inifile (a_FluidName section) ...
Definition: World.cpp:3378
int m_MaxNetherPortalHeight
Definition: World.h:1162
std::vector< sSetBlock > sSetBlockVector
Definition: ChunkDef.h:564
std::vector< BlockTickQueueItem * > m_BlockTickQueueCopy
Definition: World.h:1188
bool IsSavingEnabled(void) const
Get whether saving chunks is enabled.
Definition: World.h:92
std::list< std::pair< std::unique_ptr< cPlayer >, cWorld * > > cAwaitingPlayerList
Definition: World.h:56
virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer &a_Player) override
Sends the block on those coords to the player.
Definition: World.cpp:2224
A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the dest...
Definition: World.h:76
std::unique_ptr< cSandSimulator > m_SandSimulator
Definition: World.h:1191
virtual UInt32 SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) override
OBSOLETE, use the Vector3d-based overload instead.
Definition: World.h:607
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
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:234
bool m_IsBigFlowerBonemealable
Definition: World.h:1229
bool AreCommandBlocksEnabled(void) const
Definition: World.h:888
std::chrono::milliseconds m_TimeOfDay
Definition: World.h:1173
unsigned int m_MaxPlayers
Definition: World.h:1202
cAwaitingPlayerList m_PlayersToAdd
List of players that are scheduled for adding, waiting for the Tick thread to add them...
Definition: World.h:1295
bool m_IsDaylightCycleEnabled
Definition: World.h:1167
bool DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback a_Callback)
Calls the callback for the dropspenser at the specified coords; returns false if there&#39;s no dropspens...
Definition: World.cpp:1495
double GetSpawnX(void) const
Definition: World.h:691
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