Cuberite
A lightweight, fast and extensible game server for Minecraft
Chunk.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Entities/Entity.h"
5 #include "ChunkData.h"
6 
10 
11 #include "ChunkMap.h"
12 
13 
14 
15 
16 
17 class cWorld;
18 class cClientHandle;
19 class cPlayer;
20 class cChunkMap;
21 class cBeaconEntity;
22 class cBedEntity;
24 class cBoundingBox;
25 class cChestEntity;
26 class cChunkDataCallback;
28 class cDispenserEntity;
29 class cFurnaceEntity;
30 class cNoteEntity;
31 class cMobHeadEntity;
32 class cFlowerPotEntity;
33 class cBlockArea;
34 class cBlockArea;
36 class cMobCensus;
37 class cMobSpawner;
39 
40 typedef std::list<cClientHandle *> cClientHandleList;
41 
42 // A convenience macro for calling GetChunkAndRelByAbsolute.
43 #define PREPARE_REL_AND_CHUNK(Position, OriginalChunk) cChunk * Chunk; Vector3i Rel; bool RelSuccess = (OriginalChunk).GetChunkAndRelByAbsolute(Position, &Chunk, Rel)
44 #define PREPARE_BLOCKDATA BLOCKTYPE BlockType; NIBBLETYPE BlockMeta;
45 
46 
47 // This class is not to be used directly
48 // Instead, call actions on cChunkMap (such as cChunkMap::SetBlock() etc.)
49 class cChunk :
50  public cChunkDef // The inheritance is "misused" here only to inherit the functions and constants defined in cChunkDef
51 {
52 public:
53 
55  enum ePresence
56  {
60  };
61 
62  cChunk(
63  int a_ChunkX, int a_ChunkZ, // Chunk coords
64  cChunkMap * a_ChunkMap, cWorld * a_World, // Parent objects
65  cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP, // Neighbor chunks
67  );
68  cChunk(cChunk & other) = delete;
69  ~cChunk();
70 
72  bool IsValid(void) const {return (m_Presence == cpPresent); }
73 
75  bool IsQueued(void) const {return (m_Presence == cpQueued); }
76 
79  void SetPresence(ePresence a_Presence);
80 
82  void SetShouldGenerateIfLoadFailed(bool a_ShouldGenerateIfLoadFailed);
83 
85  void MarkRegenerating(void);
86 
88  bool IsDirty(void) const {return m_IsDirty; }
89 
90  bool CanUnload(void);
91 
93  bool CanUnloadAfterSaving(void);
94 
95  bool IsLightValid(void) const {return m_IsLightValid; }
96 
97  /*
98  To save a chunk, the WSSchema must:
99  1. Mark the chunk as being saved (MarkSaving())
100  2. Get the chunk's data using GetAllData()
101  3. Mark the chunk as saved (MarkSaved())
102  If anywhere inside this sequence another thread mmodifies the chunk, the chunk will not get marked as saved in MarkSaved()
103  */
104  void MarkSaving(void); // Marks the chunk as being saved.
105  void MarkSaved(void); // Marks the chunk as saved, if it didn't change from the last call to MarkSaving()
106  void MarkLoaded(void); // Marks the chunk as freshly loaded. Fails if the chunk is already valid
107 
110  void MarkLoadFailed(void);
111 
113  void GetAllData(cChunkDataCallback & a_Callback);
114 
118  void SetAllData(cSetChunkData & a_SetChunkData);
119 
120  void SetLight(
121  const cChunkDef::BlockNibbles & a_BlockLight,
122  const cChunkDef::BlockNibbles & a_SkyLight
123  );
124 
126  void GetBlockTypes(BLOCKTYPE * a_BlockTypes);
127 
129  void WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes);
130 
132  bool HasBlockEntityAt(Vector3i a_BlockPos);
133 
137  void Stay(bool a_Stay = true);
138 
140  void CollectMobCensus(cMobCensus & toFill);
141 
143  void SpawnMobs(cMobSpawner & a_MobSpawner);
144 
145  void Tick(std::chrono::milliseconds a_Dt);
146 
148  void TickBlock(int a_RelX, int a_RelY, int a_RelZ);
149 
150  int GetPosX(void) const { return m_PosX; }
151  int GetPosZ(void) const { return m_PosZ; }
152 
153  cWorld * GetWorld(void) const { return m_World; }
154 
155  void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
156  // SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense
157 
159  void QueueTickBlock(Vector3i a_RelPos);
160 
163  void QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ)
164  {
165  return QueueTickBlock({a_RelX, a_RelY, a_RelZ});
166  }
167 
169  void QueueTickBlockNeighbors(Vector3i a_RelPos);
170 
171  void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc.
172  void FastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true)
173  {
174  FastSetBlock(a_RelPos.x, a_RelPos.y, a_RelPos.z, a_BlockType, a_BlockMeta, a_SendToClients);
175  }
176 
177  BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const { return m_ChunkData.GetBlock({ a_RelX, a_RelY, a_RelZ }); }
178  BLOCKTYPE GetBlock(Vector3i a_RelCoords) const { return m_ChunkData.GetBlock(a_RelCoords); }
179 
180  void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
181  void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
182  {
183  GetBlockTypeMeta({ a_RelX, a_RelY, a_RelZ }, a_BlockType, a_BlockMeta);
184  }
185 
186  void GetBlockInfo(Vector3i a_RelPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
187  void GetBlockInfo(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight)
188  {
189  GetBlockInfo({ a_RelX, a_RelY, a_RelZ }, a_BlockType, a_Meta, a_SkyLight, a_BlockLight);
190  }
191 
200  bool GetChunkAndRelByAbsolute(const Vector3d & a_Position, cChunk ** a_Chunk, Vector3i & a_Rel);
201 
210  bool GetChunkAndRelByAbsolute(const Vector3i & a_Position, cChunk ** a_Chunk, Vector3i & a_Rel);
211 
214  cChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ);
215 
218  cChunk * GetRelNeighborChunk(int a_RelX, int a_RelZ);
219 
224  cChunk * GetRelNeighborChunkAdjustCoords(Vector3i & a_RelPos) const;
225 
226  EMCSBiome GetBiomeAt(int a_RelX, int a_RelZ) const {return cChunkDef::GetBiome(m_BiomeMap, a_RelX, a_RelZ); }
227 
230  void SetBiomeAt(int a_RelX, int a_RelZ, EMCSBiome a_Biome);
231 
234  void SetAreaBiome(int a_MinRelX, int a_MaxRelX, int a_MinRelZ, int a_MaxRelZ, EMCSBiome a_Biome);
235 
236  void CollectPickupsByPlayer(cPlayer & a_Player);
237 
239  bool SetSignLines(int a_RelX, int a_RelY, int a_RelZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
240 
241  int GetHeight( int a_X, int a_Z);
242 
243  void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client);
244 
246  bool AddClient(cClientHandle * a_Client);
247 
249  void RemoveClient(cClientHandle * a_Client);
250 
252  bool HasClient(cClientHandle * a_Client);
253 
255  bool HasAnyClients(void) const;
256 
257  void AddEntity(OwnedEntity a_Entity);
258 
261  OwnedEntity RemoveEntity(cEntity & a_Entity);
262 
263  bool HasEntity(UInt32 a_EntityID);
264 
266  bool ForEachEntity(cEntityCallback a_Callback); // Lua-accessible
267 
270  bool ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback a_Callback); // Lua-accessible
271 
273  bool DoWithEntityByID(UInt32 a_EntityID, cEntityCallback a_Callback, bool & a_CallbackResult); // Lua-accessible
274 
278  template <class tyEntity, BLOCKTYPE... tBlocktype>
279  bool GenericForEachBlockEntity(cFunctionRef<bool(tyEntity &)> a_Callback);
280 
282  bool ForEachBlockEntity(cBlockEntityCallback a_Callback); // Lua-accessible
283 
285  bool ForEachBrewingstand(cBrewingstandCallback a_Callback); // Lua-accessible
286 
288  bool ForEachChest(cChestCallback a_Callback); // Lua-accessible
289 
291  bool ForEachDispenser(cDispenserCallback a_Callback);
292 
294  bool ForEachDropper(cDropperCallback a_Callback);
295 
297  bool ForEachDropSpenser(cDropSpenserCallback a_Callback);
298 
300  bool ForEachFurnace(cFurnaceCallback a_Callback); // Lua-accessible
301 
305  template <class tyEntity, BLOCKTYPE... tBlocktype>
306  bool GenericDoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFunctionRef<bool(tyEntity &)> a_Callback);
307 
309  bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback a_Callback); // Lua-acessible
310 
312  bool DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback a_Callback); // Lua-acessible
313 
315  bool DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBrewingstandCallback a_Callback); // Lua-acessible
316 
318  bool DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback a_Callback); // Lua-acessible
319 
321  bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback a_Callback); // Lua-acessible
322 
324  bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback a_Callback);
325 
327  bool DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback a_Callback);
328 
330  bool DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback a_Callback);
331 
333  bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback a_Callback); // Lua-accessible
334 
336  bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback a_Callback);
337 
339  bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback a_Callback);
340 
342  bool DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadCallback a_Callback);
343 
345  bool DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlowerPotCallback a_Callback);
346 
348  bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Lua-accessible
349 
352  bool UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z); // [x, y, z] in world block coords
353 
354  void CalculateHeightmap(const BLOCKTYPE * a_BlockTypes);
355 
356  void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
357 
359  {
360  return PositionToWorldPosition(a_RelPos.x, a_RelPos.y, a_RelPos.z);
361  }
362 
363  void PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ, int & a_BlockX, int & a_BlockY, int & a_BlockZ);
364  Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ);
365 
366  inline void MarkDirty(void)
367  {
368  m_IsDirty = true;
369  m_IsSaving = false;
370  }
371 
373  inline void SetNextBlockTick(int a_RelX, int a_RelY, int a_RelZ)
374  {
375  m_BlockTickX = a_RelX;
376  m_BlockTickY = a_RelY;
377  m_BlockTickZ = a_RelZ;
378  }
379 
380  inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
381  {
382  return m_ChunkData.GetMeta({ a_RelX, a_RelY, a_RelZ });
383  }
384 
385  NIBBLETYPE GetMeta(Vector3i a_RelPos) const { return m_ChunkData.GetMeta(a_RelPos); }
386 
387  void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta, bool a_ShouldMarkDirty = true, bool a_ShouldInformClients = true)
388  {
389  SetMeta({ a_RelX, a_RelY, a_RelZ }, a_Meta, a_ShouldMarkDirty, a_ShouldInformClients);
390  }
391 
395  inline void SetMeta(Vector3i a_RelPos, NIBBLETYPE a_Meta, bool a_ShouldMarkDirty = true, bool a_ShouldInformClients = true)
396  {
397  bool hasChanged = m_ChunkData.SetMeta(a_RelPos, a_Meta);
398  if (hasChanged)
399  {
400  if (a_ShouldMarkDirty)
401  {
402  MarkDirty();
403  }
404  if (a_ShouldInformClients)
405  {
406  m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelPos.x, a_RelPos.y, a_RelPos.z, GetBlock(a_RelPos), a_Meta));
407  }
408  }
409  }
410 
412  NIBBLETYPE GetTimeAlteredLight(NIBBLETYPE a_Skylight) const;
413 
415  inline NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const { return m_ChunkData.GetBlockLight(a_RelPos); }
416  inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const { return m_ChunkData.GetBlockLight({ a_RelX, a_RelY, a_RelZ }); }
417 
419  inline NIBBLETYPE GetSkyLight(Vector3i a_RelPos) const { return m_ChunkData.GetSkyLight(a_RelPos); }
420  inline NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const { return m_ChunkData.GetSkyLight({ a_RelX, a_RelY, a_RelZ }); }
421 
423  inline NIBBLETYPE GetSkyLightAltered(Vector3i a_RelPos) const { return GetTimeAlteredLight(m_ChunkData.GetSkyLight(a_RelPos)); }
424  inline NIBBLETYPE GetSkyLightAltered(int a_RelX, int a_RelY, int a_RelZ) const { return GetSkyLightAltered({ a_RelX, a_RelY, a_RelZ }); }
425 
428  bool UnboundedRelGetBlock(Vector3i a_RelCoords, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
429 
433  bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
434  {
435  return UnboundedRelGetBlock({a_RelX, a_RelY, a_RelZ}, a_BlockType, a_BlockMeta);
436  }
437 
440  bool UnboundedRelGetBlockType(Vector3i a_RelCoords, BLOCKTYPE & a_BlockType) const;
441 
445  bool UnboundedRelGetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType) const
446  {
447  return UnboundedRelGetBlockType({a_RelX, a_RelY, a_RelZ}, a_BlockType);
448  }
449 
452  bool UnboundedRelGetBlockMeta(Vector3i a_RelPos, NIBBLETYPE & a_BlockMeta) const;
453 
457  bool UnboundedRelGetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE & a_BlockMeta) const
458  {
459  return UnboundedRelGetBlockMeta({a_RelX, a_RelY, a_RelZ}, a_BlockMeta);
460  }
461 
464  bool UnboundedRelGetBlockBlockLight(Vector3i a_RelPos, NIBBLETYPE & a_BlockLight) const;
465 
469  bool UnboundedRelGetBlockBlockLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE & a_BlockLight) const
470  {
471  return UnboundedRelGetBlockBlockLight({a_RelX, a_RelY, a_RelZ}, a_BlockLight);
472  }
473 
476  bool UnboundedRelGetBlockSkyLight(Vector3i a_RelPos, NIBBLETYPE & a_SkyLight) const;
477 
481  bool UnboundedRelGetBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE & a_SkyLight) const
482  {
483  return UnboundedRelGetBlockSkyLight({a_RelX, a_RelY, a_RelZ}, a_SkyLight);
484  }
485 
488  bool UnboundedRelGetBlockLights(Vector3i a_RelPos, NIBBLETYPE & a_BlockLight, NIBBLETYPE & a_SkyLight) const;
489 
493  bool UnboundedRelGetBlockLights(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE & a_BlockLight, NIBBLETYPE & a_SkyLight) const
494  {
495  return UnboundedRelGetBlockLights({a_RelX, a_RelY, a_RelZ}, a_BlockLight, a_SkyLight);
496  }
497 
500  bool UnboundedRelSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
501 
505  bool UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
506  {
507  return UnboundedRelSetBlock({a_RelX, a_RelY, a_RelZ}, a_BlockType, a_BlockMeta);
508  }
509 
512  bool UnboundedRelFastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
513 
517  bool UnboundedRelFastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
518  {
519  return UnboundedRelFastSetBlock({a_RelX, a_RelY, a_RelZ}, a_BlockType, a_BlockMeta);
520  }
521 
524  void UnboundedQueueTickBlock(Vector3i a_RelPos);
525 
526 
527 
528  // Per-chunk simulator data:
533 
536 
540 
544  cBlockEntity * GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ) { return GetBlockEntity({a_BlockX, a_BlockY, a_BlockZ}); }
545 
550 
553  bool ShouldBeTicked(void) const;
554 
560  void SetAlwaysTicked(bool a_AlwaysTicked);
561 
563  {
565  }
566 
570  {
571  return cChunkDef::RelativeToAbsolute(a_RelBlockPosition, {m_PosX, m_PosZ});
572  }
573 
574 
575 private:
576 
577  friend class cChunkMap;
578 
580  {
586 
587  sSetBlockQueueItem(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType) :
588  m_Tick(a_Tick), m_RelX(a_RelX), m_RelY(a_RelY), m_RelZ(a_RelZ), m_BlockType(a_BlockType), m_BlockMeta(a_BlockMeta), m_PreviousType(a_PreviousBlockType)
589  {
590  }
591  } ;
592 
593  typedef std::vector<sSetBlockQueueItem> sSetBlockQueueVector;
594 
595 
598 
601  bool m_IsLightValid; // True if the blocklight and skylight are calculated
602  bool m_IsDirty; // True if the chunk has changed since it was last saved
603  bool m_IsSaving; // True if the chunk is being saved
604  bool m_HasLoadFailed; // True if chunk failed to load and hasn't been generated yet since then
605 
606  std::vector<Vector3i> m_ToTickBlocks;
608 
609  // A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers
610  std::vector<cClientHandle *> m_LoadedByClient;
611  std::vector<OwnedEntity> m_Entities;
613 
616 
620 
622 
625 
627 
628  cChunk * m_NeighborXM; // Neighbor at [X - 1, Z]
629  cChunk * m_NeighborXP; // Neighbor at [X + 1, Z]
630  cChunk * m_NeighborZM; // Neighbor at [X, Z - 1]
631  cChunk * m_NeighborZP; // Neighbor at [X, Z + 1]
632 
633  // Per-chunk simulator data:
638 
640 
645 
646 
647  // Pick up a random block of this chunk
648  void GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z);
649  void GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ);
650 
651  void RemoveBlockEntity(cBlockEntity * a_BlockEntity);
652  void AddBlockEntity (cBlockEntity * a_BlockEntity);
653 
655  void AddBlockEntityClean(cBlockEntity * a_BlockEntity);
656 
658  void CreateBlockEntities(void);
659 
661  void WakeUpSimulators(void);
662 
664  void BroadcastPendingBlockChanges(void);
665 
667  void CheckBlocks();
668 
670  void TickBlocks(void);
671 
673  void ApplyWeatherToTop(void);
674 
677  cItems PickupsFromBlock(Vector3i a_RelPos, const cEntity * a_Digger, const cItem * a_Tool);
678 
682  int GrowPlantAt(Vector3i a_RelPos, int a_NumStages = 1);
683 
685  void MoveEntityToNewChunk(OwnedEntity a_Entity);
686 };
687 
688 typedef cChunk * cChunkPtr;
689 
690 typedef std::list<cChunkPtr> cChunkPtrList;
691 
692 
693 
694 
cWorld * GetWorld(void) const
Definition: Chunk.h:153
sSetBlockVector m_PendingSendBlocks
Blocks that have changed and need to be sent to all clients.
Definition: Chunk.h:607
bool GenericDoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFunctionRef< bool(tyEntity &)> a_Callback)
Calls the callback for the tyEntity at the specified coords; returns false if there&#39;s no such block e...
Definition: Chunk.cpp:2036
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
Definition: Chunk.h:72
bool ForEachBlockEntity(cBlockEntityCallback a_Callback)
Calls the callback for each block entity; returns true if all block entities processed, false if the callback aborted by returning true.
Definition: Chunk.cpp:1958
std::map< size_t, cBlockEntity * > cBlockEntities
Definition: ChunkDef.h:34
void AddBlockEntity(cBlockEntity *a_BlockEntity)
Definition: Chunk.cpp:1508
NIBBLETYPE GetSkyLight(Vector3i a_RelPos) const
Get the level of sky light illuminating the block (0 - 15) independent of daytime.
Definition: Chunk.h:419
void AddEntity(OwnedEntity a_Entity)
Definition: Chunk.cpp:1796
bool IsLightValid(void) const
Definition: Chunk.h:95
bool ForEachDispenser(cDispenserCallback a_Callback)
Calls the callback for each dispenser; returns true if all dispensers processed, false if the callbac...
Definition: Chunk.cpp:1989
bool DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback a_Callback)
Calls the callback for the bed at the specified coords; returns false if there&#39;s no bed at those coor...
Definition: Chunk.cpp:2078
bool UnboundedRelGetBlockSkyLight(Vector3i a_RelPos, NIBBLETYPE &a_SkyLight) const
Same as GetBlockSkyLight(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or m_Chun...
Definition: Chunk.cpp:1081
NIBBLETYPE m_BlockMeta
Definition: Chunk.h:584
T x
Definition: Vector3.h:17
bool DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback a_Callback)
Calls the callback for the dispenser at the specified coords; returns false if there&#39;s no dropper at ...
Definition: Chunk.cpp:2123
cChunk * GetRelNeighborChunk(int a_RelX, int a_RelZ)
Returns the chunk into which the relatively-specified block belongs, by walking the neighbors...
Definition: Chunk.cpp:2291
cChunk * GetRelNeighborChunkAdjustCoords(Vector3i &a_RelPos) const
Returns the chunk into which the relatively-specified block belongs.
Definition: Chunk.cpp:2358
The chunk is not present, but is queued for loading / generation.
Definition: Chunk.h:58
void SetAlwaysTicked(bool a_AlwaysTicked)
Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter.
Definition: Chunk.cpp:1568
sSetBlockQueueItem(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType)
Definition: Chunk.h:587
NIBBLETYPE GetMeta(Vector3i a_RelPos) const
Definition: Chunk.h:385
void GetRandomBlockCoords(int &a_X, int &a_Y, int &a_Z)
Definition: Chunk.cpp:550
NIBBLETYPE GetTimeAlteredLight(NIBBLETYPE a_Skylight) const
Light alterations based on time.
Definition: Chunk.cpp:2450
bool UnboundedRelGetBlockBlockLight(Vector3i a_RelPos, NIBBLETYPE &a_BlockLight) const
Same as GetBlockBlockLight(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or m_Ch...
Definition: Chunk.cpp:1060
NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const
Get the level of artificial light illuminating the block (0 - 15)
Definition: Chunk.h:415
void MoveEntityToNewChunk(OwnedEntity a_Entity)
Called by Tick() when an entity moves out of this chunk into a neighbor; moves the entity and sends s...
Definition: Chunk.cpp:732
cRedstoneSimulatorChunkData * m_RedstoneSimulatorData
Definition: Chunk.h:639
void GetBlockTypes(BLOCKTYPE *a_BlockTypes)
Copies m_BlockData into a_BlockTypes, only the block types.
Definition: Chunk.cpp:370
void MarkLoadFailed(void)
Marks the chunk as failed to load.
Definition: Chunk.cpp:255
bool ForEachDropSpenser(cDropSpenserCallback a_Callback)
Calls the callback for each dropspenser; returns true if all dropspensers processed, false if the callback aborted by returning true.
Definition: Chunk.cpp:2011
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: Chunk.cpp:2202
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Definition: Chunk.cpp:2230
void CreateBlockEntities(void)
Creates a block entity for each block that needs a block entity and doesn&#39;t have one already...
Definition: Chunk.cpp:1198
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle &a_Client)
Definition: Chunk.cpp:2416
void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle *a_Client)
Definition: Chunk.cpp:1483
BLOCKTYPE m_PreviousType
Definition: Chunk.h:585
NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const
Definition: ChunkData.cpp:244
BLOCKTYPE GetBlock(Vector3i a_RelPos) const
Definition: ChunkData.cpp:136
void WriteBlockArea(cBlockArea &a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
Writes the specified cBlockArea at the coords specified.
Definition: Chunk.cpp:379
void SetAreaBiome(int a_MinRelX, int a_MaxRelX, int a_MinRelZ, int a_MaxRelZ, EMCSBiome a_Biome)
Sets the biome in the specified relative coords area.
Definition: Chunk.cpp:1610
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: Chunk.cpp:2169
bool IsQueued(void) const
Returns true iff the chunk is in the queue for loading / generating.
Definition: Chunk.h:75
bool HasBlockEntityAt(Vector3i a_BlockPos)
Returns true if there is a block entity at the coords specified.
Definition: Chunk.cpp:479
bool UnboundedRelGetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE &a_BlockType) const
OBSOLETE, use the Vector3i-based overload.
Definition: Chunk.h:445
void CalculateHeightmap(const BLOCKTYPE *a_BlockTypes)
Definition: Chunk.cpp:1290
bool UnboundedRelGetBlockBlockLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE &a_BlockLight) const
OBSOLETE, use the Vector3i-based overload.
Definition: Chunk.h:469
Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition)
Converts the coord relative to this chunk into an absolute coord.
Definition: Chunk.h:569
bool UnboundedRelGetBlockType(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType) const
Same as GetBlockType(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or m_ChunkMap...
Definition: Chunk.cpp:1018
Definition: Player.h:27
void MarkLoaded(void)
Definition: Chunk.cpp:245
bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
OBSOLETE, use the Vector3i-based overload.
Definition: Chunk.h:433
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: Chunk.cpp:2089
int m_StayCount
Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero...
Definition: Chunk.h:615
cChunk * m_NeighborZP
Definition: Chunk.h:631
void GetThreeRandomNumbers(int &a_X, int &a_Y, int &a_Z, int a_MaxX, int a_MaxY, int a_MaxZ)
Definition: Chunk.cpp:529
void AddBlockEntityClean(cBlockEntity *a_BlockEntity)
Add a block entity to the chunk without marking the chunk dirty.
Definition: Chunk.cpp:1518
void MarkSaved(void)
Definition: Chunk.cpp:232
cFluidSimulatorData * m_LavaSimulatorData
Definition: Chunk.h:636
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Definition: Chunk.cpp:1313
void CollectMobCensus(cMobCensus &toFill)
Recence all mobs proximities to players in order to know what to do with them.
Definition: Chunk.cpp:498
void QueueTickBlock(Vector3i a_RelPos)
Queues block for ticking (m_ToTickQueue)
Definition: Chunk.cpp:1365
cBlockEntity * GetBlockEntityRel(Vector3i a_RelPos)
Returns the block entity at the specified (relative) coords.
Definition: Chunk.cpp:1548
void WakeUpSimulators(void)
Wakes up each simulator for its specific blocks; through all the blocks in the chunk.
Definition: Chunk.cpp:1232
cSandSimulatorChunkData m_SandSimulatorData
Definition: Chunk.h:637
bool ForEachChest(cChestCallback a_Callback)
Calls the callback for each chest; returns true if all chests processed, false if the callback aborte...
Definition: Chunk.cpp:1978
int m_PosZ
Definition: Chunk.h:617
void CollectPickupsByPlayer(cPlayer &a_Player)
Definition: Chunk.cpp:1632
Vector3i PositionToWorldPosition(Vector3i a_RelPos)
Definition: Chunk.h:358
bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback a_Callback)
Calls the callback for the block entity at the specified coords; returns false if there&#39;s no block en...
Definition: Chunk.cpp:2058
cBlockEntities m_BlockEntities
Definition: Chunk.h:612
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: Chunk.cpp:2146
OwnedEntity RemoveEntity(cEntity &a_Entity)
Releases ownership of the given entity if it was found in this chunk.
Definition: Chunk.cpp:1816
std::vector< OwnedEntity > m_Entities
Definition: Chunk.h:611
bool CanUnloadAfterSaving(void)
Returns true if the chunk could have been unloaded if it weren&#39;t dirty.
Definition: Chunk.cpp:210
cFluidSimulatorData * m_WaterSimulatorData
Definition: Chunk.h:635
bool GetChunkAndRelByAbsolute(const Vector3d &a_Position, cChunk **a_Chunk, Vector3i &a_Rel)
Convert absolute coordinates into relative coordinates.
Definition: Chunk.cpp:2252
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
cSandSimulatorChunkData & GetSandSimulatorData(void)
Definition: Chunk.h:532
void SetMeta(Vector3i a_RelPos, NIBBLETYPE a_Meta, bool a_ShouldMarkDirty=true, bool a_ShouldInformClients=true)
Set a meta value, with the option of not informing the client and / or not marking dirty...
Definition: Chunk.h:395
cFluidSimulatorData * GetLavaSimulatorData(void)
Definition: Chunk.h:531
Constants used throughout the code, useful typedefs and utility functions.
Definition: ChunkDef.h:130
Represents two sets of coords, minimum and maximum for each direction.
Definition: BoundingBox.h:23
void Tick(std::chrono::milliseconds a_Dt)
Definition: Chunk.cpp:633
cChunk * cChunkPtr
Definition: Chunk.h:688
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: Chunk.cpp:2158
void QueueTickBlockNeighbors(Vector3i a_RelPos)
Queues all 6 neighbors of the specified block for ticking (m_ToTickQueue).
Definition: Chunk.cpp:1381
bool HasEntity(UInt32 a_EntityID)
Definition: Chunk.cpp:1855
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
Definition: BiomeDef.h:21
bool DoWithEntityByID(UInt32 a_EntityID, cEntityCallback a_Callback, bool &a_CallbackResult)
Calls the callback if the entity with the specified ID is found, with the entity object as the callba...
Definition: Chunk.cpp:1915
Definition: Chunk.h:49
bool m_ShouldGenerateIfLoadFailed
If the chunk fails to load, should it be queued in the generator or reset back to invalid...
Definition: Chunk.h:600
bool m_HasLoadFailed
Definition: Chunk.h:604
bool SetSignLines(int a_RelX, int a_RelY, int a_RelZ, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4)
Sets the sign text.
Definition: Chunk.cpp:1680
EMCSBiome GetBiomeAt(int a_RelX, int a_RelZ) const
Definition: Chunk.h:226
bool UnboundedRelGetBlockMeta(Vector3i a_RelPos, NIBBLETYPE &a_BlockMeta) const
Same as GetBlockMeta(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or m_ChunkMap...
Definition: Chunk.cpp:1039
bool m_IsLightValid
Definition: Chunk.h:601
T y
Definition: Vector3.h:17
cBlockEntity * GetBlockEntity(Vector3i a_AbsPos)
Returns the block entity at the specified (absolute) coords.
Definition: Chunk.cpp:1530
bool CanUnload(void)
Definition: Chunk.cpp:197
bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback)
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox...
Definition: Chunk.cpp:1888
T z
Definition: Vector3.h:17
int m_BlockTickX
Definition: Chunk.h:626
void ApplyWeatherToTop(void)
Adds snow to the top of snowy biomes and hydrates farmland / fills cauldrons in rainy biomes...
Definition: Chunk.cpp:877
NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:420
bool ForEachEntity(cEntityCallback a_Callback)
Calls the callback for each entity; returns true if all entities processed, false if the callback abo...
Definition: Chunk.cpp:1871
bool UnboundedRelGetBlockLights(Vector3i a_RelPos, NIBBLETYPE &a_BlockLight, NIBBLETYPE &a_SkyLight) const
Queries both BlockLight and SkyLight, relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or ...
Definition: Chunk.cpp:1102
NIBBLETYPE GetSkyLightAltered(Vector3i a_RelPos) const
Get the level of sky light illuminating the block (0 - 15), taking daytime into a account...
Definition: Chunk.h:423
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: Chunk.cpp:2191
void SetRedstoneSimulatorData(cRedstoneSimulatorChunkData *a_Data)
Definition: Chunk.h:535
void MarkDirty(void)
Definition: Chunk.h:366
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: Chunk.cpp:2067
ePresence m_Presence
Holds the presence status of the chunk - if it is present, or in the loader / generator queue...
Definition: Chunk.h:597
bool UnboundedRelGetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE &a_BlockMeta) const
OBSOLETE, use the Vector3i-based overload.
Definition: Chunk.h:457
cChunkDef::BiomeMap m_BiomeMap
Definition: Chunk.h:624
This class is used to determine which monster can be spawned in which place it is essentially static ...
Definition: MobSpawner.h:15
std::vector< cClientHandle * > m_LoadedByClient
Definition: Chunk.h:610
bool m_IsSaving
Definition: Chunk.h:603
Definition: World.h:65
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:380
void CheckBlocks()
Checks the block scheduled for checking in m_ToTickBlocks[].
Definition: Chunk.cpp:807
void SpawnMobs(cMobSpawner &a_MobSpawner)
Try to Spawn Monsters inside chunk.
Definition: Chunk.cpp:563
std::list< cChunkPtr > cChunkPtrList
Definition: Chunk.h:690
bool UnboundedRelSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Same as SetBlock(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or m_ChunkMap in ...
Definition: Chunk.cpp:1124
cFireSimulatorChunkData m_FireSimulatorData
Definition: Chunk.h:634
cChunkData m_ChunkData
Definition: Chunk.h:621
int GetPosX(void) const
Definition: Chunk.h:150
NIBBLETYPE GetSkyLight(Vector3i a_RelPos) const
Definition: ChunkData.cpp:266
cCoordWithIntList cSandSimulatorChunkData
Per-chunk data for the simulator, specified individual chunks to simulate; Data is not used...
Definition: SandSimulator.h:11
cCoordWithIntList cFireSimulatorChunkData
Stores individual fire blocks in the chunk; the int data is used as the time [msec] the fire takes to...
Definition: FireSimulator.h:69
int m_AlwaysTicked
If greater than zero, the chunk is ticked even if it has no clients.
Definition: Chunk.h:644
std::list< cClientHandle * > cClientHandleList
Definition: Chunk.h:38
cChunkMap * m_ChunkMap
Definition: Chunk.h:619
bool UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
OBSOLETE, use the Vector3i-based overload.
Definition: Chunk.h:505
void BroadcastPendingBlockChanges(void)
Sends m_PendingSendBlocks to all clients.
Definition: Chunk.cpp:777
bool GenericForEachBlockEntity(cFunctionRef< bool(tyEntity &)> a_Callback)
Calls the callback for each tyEntity; returns true if all block entities processed, false if the callback aborted by returning true tBlocktypes are all blocktypes convertible to tyEntity which are to be called.
Definition: Chunk.cpp:1934
std::vector< Vector3i > m_ToTickBlocks
Definition: Chunk.h:606
cChunk * m_NeighborXM
Definition: Chunk.h:628
void MarkRegenerating(void)
Marks all clients attached to this chunk as wanting this chunk.
Definition: Chunk.cpp:181
static Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition, cChunkCoords a_ChunkCoords)
Converts relative block coordinates into absolute coordinates with a known chunk location.
Definition: ChunkDef.h:198
void SetBiomeAt(int a_RelX, int a_RelZ, EMCSBiome a_Biome)
Sets the biome at the specified relative coords.
Definition: Chunk.cpp:1600
bool ForEachFurnace(cFurnaceCallback a_Callback)
Calls the callback for each furnace; returns true if all furnaces processed, false if the callback ab...
Definition: Chunk.cpp:2023
bool DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback a_Callback)
Calls the callback for the dispenser at the specified coords; returns false if there&#39;s no dropspenser...
Definition: Chunk.cpp:2134
void TickBlocks(void)
Ticks several random blocks in the chunk.
Definition: Chunk.cpp:832
This is a base class for all fluid simulator data classes.
void SetLight(const cChunkDef::BlockNibbles &a_BlockLight, const cChunkDef::BlockNibbles &a_SkyLight)
Definition: Chunk.cpp:351
int GetHeight(int a_X, int a_Z)
Definition: Chunk.cpp:1183
std::vector< sSetBlockQueueItem > sSetBlockQueueVector
Definition: Chunk.h:593
bool ForEachDropper(cDropperCallback a_Callback)
Calls the callback for each dropper; returns true if all droppers processed, false if the callback ab...
Definition: Chunk.cpp:2000
The chunk is present.
Definition: Chunk.h:59
bool UnboundedRelFastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Same as FastSetBlock(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or m_ChunkMap...
Definition: Chunk.cpp:1145
std::string AString
Definition: StringUtils.h:13
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: Chunk.cpp:2180
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: Chunk.cpp:2100
int m_BlockTickY
Definition: Chunk.h:626
bool UnboundedRelGetBlock(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Same as GetBlock(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or m_ChunkMap in ...
Definition: Chunk.cpp:997
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:177
cChunkDef::HeightMap m_HeightMap
Definition: Chunk.h:623
bool SetMeta(Vector3i a_RelPos, NIBBLETYPE a_Nibble)
Definition: ChunkData.cpp:209
ePresence
Represents the presence state of the chunk.
Definition: Chunk.h:55
bool UnboundedRelGetBlockLights(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE &a_BlockLight, NIBBLETYPE &a_SkyLight) const
OBSOLETE, use the Vector3i-based overload.
Definition: Chunk.h:493
cWorld * m_World
Definition: Chunk.h:618
cFluidSimulatorData * GetWaterSimulatorData(void)
Definition: Chunk.h:530
int GetPosZ(void) const
Definition: Chunk.h:151
bool HasClient(cClientHandle *a_Client)
Returns true if the specified client is present in this chunk.
Definition: Chunk.cpp:1778
int m_BlockTickZ
Definition: Chunk.h:626
bool UnboundedRelFastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
OBSOLETE, use the Vector3i-based overload.
Definition: Chunk.h:517
void GetBlockInfo(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_Meta, NIBBLETYPE &a_SkyLight, NIBBLETYPE &a_BlockLight)
Definition: Chunk.h:187
cChunk * m_NeighborXP
Definition: Chunk.h:629
cChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ)
Returns the chunk into which the specified block belongs, by walking the neighbors.
Definition: Chunk.cpp:2279
void UnboundedQueueTickBlock(Vector3i a_RelPos)
Same as QueueTickBlock(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s in such a c...
Definition: Chunk.cpp:1166
This class is used to collect information, for each Mob, what is the distance of the closest player i...
Definition: MobCensus.h:25
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: Chunk.cpp:2112
Definition: Entity.h:73
int GrowPlantAt(Vector3i a_RelPos, int a_NumStages=1)
Grows the plant at the specified position by at most a_NumStages.
Definition: Chunk.cpp:987
unsigned int UInt32
Definition: Globals.h:113
void SetPresence(ePresence a_Presence)
Sets the chunk&#39;s presence.
Definition: Chunk.cpp:159
std::unique_ptr< cEntity > OwnedEntity
Definition: ChunkDef.h:32
bool AddClient(cClientHandle *a_Client)
Adds a client to the chunk; returns true if added, false if already there.
Definition: Chunk.cpp:1719
The chunk is not present at all and is not queued in the loader / generator.
Definition: Chunk.h:57
cBlockEntity * GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ)
OBSOLETE, use the Vector3i-based overload instead.
Definition: Chunk.h:544
cChunk(int a_ChunkX, int a_ChunkZ, cChunkMap *a_ChunkMap, cWorld *a_World, cChunk *a_NeighborXM, cChunk *a_NeighborXP, cChunk *a_NeighborZM, cChunk *a_NeighborZP, cAllocationPool< cChunkData::sChunkSection > &a_Pool)
Definition: Chunk.cpp:55
bool UseBlockEntity(cPlayer *a_Player, int a_X, int a_Y, int a_Z)
Use block entity on coordinate.
Definition: Chunk.cpp:1586
void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Definition: Chunk.h:181
NIBBLETYPE BlockNibbles[NumBlocks/2]
The type used for block data in nibble format, AXIS_ORDER ordering.
Definition: ChunkDef.h:153
void SetNextBlockTick(int a_RelX, int a_RelY, int a_RelZ)
Sets the blockticking to start at the specified block.
Definition: Chunk.h:373
void GetBlockInfo(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_Meta, NIBBLETYPE &a_SkyLight, NIBBLETYPE &a_BlockLight)
Definition: Chunk.cpp:2240
void FastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients=true)
Definition: Chunk.h:172
bool IsDirty(void) const
Returns true iff the chunk has changed since it was last saved.
Definition: Chunk.h:88
void TickBlock(int a_RelX, int a_RelY, int a_RelZ)
Ticks a single block.
Definition: Chunk.cpp:719
cChunkClientHandles GetAllClients(void) const
Definition: Chunk.h:562
BLOCKTYPE GetBlock(Vector3i a_RelCoords) const
Definition: Chunk.h:178
NIBBLETYPE GetSkyLightAltered(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:424
bool UnboundedRelGetBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE &a_SkyLight) const
OBSOLETE, use the Vector3i-based overload.
Definition: Chunk.h:481
void SetShouldGenerateIfLoadFailed(bool a_ShouldGenerateIfLoadFailed)
Called to indicate whether the chunk should be queued in the generator if it fails to load...
Definition: Chunk.cpp:172
cFireSimulatorChunkData & GetFireSimulatorData(void)
Definition: Chunk.h:529
void RemoveBlockEntity(cBlockEntity *a_BlockEntity)
Definition: Chunk.cpp:1707
bool HasAnyClients(void) const
Returns true if theres any client in the chunk; false otherwise.
Definition: Chunk.cpp:1787
cItems PickupsFromBlock(Vector3i a_RelPos, const cEntity *a_Digger, const cItem *a_Tool)
Returns the pickups that would be produced, if the specified block was dug up by a_Digger using a_Too...
Definition: Chunk.cpp:970
HEIGHTTYPE HeightMap[Width *Width]
The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the hig...
Definition: ChunkDef.h:142
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta, bool a_ShouldMarkDirty=true, bool a_ShouldInformClients=true)
Definition: Chunk.h:387
void GetAllData(cChunkDataCallback &a_Callback)
Gets all chunk data, calls the a_Callback&#39;s methods for each data type.
Definition: Chunk.cpp:274
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients=true)
Definition: Chunk.cpp:1402
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
Definition: ChunkDef.h:147
bool ForEachBrewingstand(cBrewingstandCallback a_Callback)
Calls the callback for each brewingstand; returns true if all brewingstands processed, false if the callback aborted by returning true.
Definition: Chunk.cpp:1967
void QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ)
OBSOLETE, use the Vector3i-based overload instead.
Definition: Chunk.h:163
Definition: Item.h:36
bool ShouldBeTicked(void) const
Returns true if the chunk should be ticked in the tick-thread.
Definition: Chunk.cpp:1559
signed long long Int64
Definition: Globals.h:107
std::vector< sSetBlock > sSetBlockVector
Definition: ChunkDef.h:564
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:234
void MarkSaving(void)
Definition: Chunk.cpp:223
int m_PosX
Definition: Chunk.h:617
cChunk * m_NeighborZM
Definition: Chunk.h:630
cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void)
Definition: Chunk.h:534
void Stay(bool a_Stay=true)
Sets or resets the internal flag that prevents chunk from being unloaded.
Definition: Chunk.cpp:488
NIBBLETYPE GetMeta(Vector3i a_RelPos) const
Definition: ChunkData.cpp:187
static EMCSBiome GetBiome(const BiomeMap &a_BiomeMap, int a_X, int a_Z)
Definition: ChunkDef.h:367
void SetAllData(cSetChunkData &a_SetChunkData)
Sets all chunk data as either loaded from the storage or generated.
Definition: Chunk.cpp:300
NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:416
~cChunk()
Definition: Chunk.cpp:107
Non-owning view of a chunk&#39;s client handles.
Definition: ChunkDef.h:103
void RemoveClient(cClientHandle *a_Client)
Removes the specified client from the chunk; ignored if client not in chunk.
Definition: Chunk.cpp:1748
bool m_IsDirty
Definition: Chunk.h:602