28 #include "zlib/zlib.h" 29 #include "json/json.h" 67 auto Chunk =
FindChunk(a_ChunkX, a_ChunkZ);
73 cpp14::make_unique<cChunk>(
103 if (!Chunk->IsValid() && !Chunk->IsQueued())
106 Chunk->SetShouldGenerateIfLoadFailed(
true);
121 if (Chunk ==
nullptr)
125 if (!Chunk->IsValid() && !Chunk->IsQueued())
152 auto Chunk =
m_Chunks.find({ a_ChunkX, a_ChunkZ });
153 return (Chunk ==
m_Chunks.end()) ?
nullptr : Chunk->second.get();
166 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
184 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
188 return Chunk->
UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
199 if (Chunk ==
nullptr)
203 return a_Callback(*Chunk);
225 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
240 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
255 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
270 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
288 if (Chunk ==
nullptr)
303 if ((*itr)->ChunkAvailable(ChunkX, ChunkZ))
306 ToBeDisabled.push_back(*itr);
311 for (cChunkStays::iterator itr = ToBeDisabled.begin(), end = ToBeDisabled.end(); itr != end; ++itr)
326 int a_ChunkX,
int a_ChunkZ,
333 if (Chunk ==
nullptr)
337 Chunk->
SetLight(a_BlockLight, a_SkyLight);
354 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
371 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
387 return (Chunk !=
nullptr) && Chunk->
IsQueued();
398 return (Chunk !=
nullptr) && Chunk->
IsValid();
421 int ChunkX, ChunkZ, BlockY = 0;
424 if (Chunk ==
nullptr)
431 return Chunk->
GetHeight(a_BlockX, a_BlockZ);
448 int ChunkX, ChunkZ, BlockY = 0;
451 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
455 a_Height = Chunk->
GetHeight(a_BlockX, a_BlockZ);
469 auto chunk =
GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
470 if ((chunk !=
nullptr) && chunk->IsValid())
472 chunk->FastSetBlock(relPos, a_BlockType, a_BlockMeta);
484 int lastChunkX = 0x7fffffff;
485 int lastChunkZ = 0x7fffffff;
486 for (
auto block: a_Blocks)
489 if ((block.m_ChunkX != lastChunkX) || (block.m_ChunkZ != lastChunkZ))
491 lastChunkX = block.m_ChunkX;
492 lastChunkZ = block.m_ChunkZ;
493 chunk =
GetChunk(lastChunkX, lastChunkZ);
497 if (chunk !=
nullptr)
499 chunk->
SetBlock({block.m_RelX, block.m_RelY, block.m_RelZ}, block.m_BlockType, block.m_BlockMeta);
510 int BlockX =
static_cast<int>(a_Player.
GetPosX());
511 int BlockY =
static_cast<int>(a_Player.
GetPosY());
512 int BlockZ =
static_cast<int>(a_Player.
GetPosZ());
513 int ChunkX = 0, ChunkZ = 0;
515 int OtherChunkX = ChunkX + ((BlockX > 8) ? 1 : -1);
516 int OtherChunkZ = ChunkZ + ((BlockZ > 8) ? 1 : -1);
542 auto chunk =
GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
543 if ((chunk !=
nullptr) && chunk->IsValid())
545 return chunk->GetBlock(relPos);
561 auto chunk =
GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
562 if ((chunk !=
nullptr) && chunk->IsValid())
564 return chunk->GetMeta(relPos);
580 auto chunk =
GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
581 if ((chunk !=
nullptr) && chunk->IsValid())
583 return chunk->GetSkyLight(relPos);
599 auto chunk =
GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
600 if ((chunk !=
nullptr) && chunk->IsValid())
602 return chunk->GetBlockLight(relPos);
618 auto chunk =
GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
619 if ((chunk !=
nullptr) && chunk->IsValid())
621 chunk->SetMeta(relPos, a_BlockMeta, a_ShouldMarkDirty, a_ShouldInformClients);
635 auto chunk =
GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
636 if ((chunk !=
nullptr) && chunk->IsValid())
643 chunk->SetBlock(relPos, a_BlockType, a_BlockMeta);
659 auto chunk =
GetChunk(chunkCoord.m_ChunkX, chunkCoord.m_ChunkZ);
660 if ((chunk !=
nullptr) && chunk->IsValid())
662 chunk->GetBlockTypeMeta(relPos, a_BlockType, a_BlockMeta);
679 auto chunk =
GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
680 if ((chunk !=
nullptr) && chunk->IsValid())
682 chunk->GetBlockInfo(relPos, a_BlockType, a_Meta, a_SkyLight, a_BlockLight);
695 for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
697 auto chunk =
GetChunk(itr->m_ChunkX, itr->m_ChunkZ);
698 if ((chunk ==
nullptr) || !chunk->IsValid())
702 Vector3i relPos(itr->m_RelX, itr->m_RelY, itr->m_RelZ);
703 if (chunk->GetBlock(relPos) == a_FilterBlockType)
705 chunk->SetBlock(relPos, itr->m_BlockType, itr->m_BlockMeta);
717 for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
719 auto chunk =
GetChunk(itr->m_ChunkX, itr->m_ChunkZ);
720 if ((chunk ==
nullptr) || !chunk->IsValid())
724 Vector3i relPos(itr->m_RelX, itr->m_RelY, itr->m_RelZ);
725 switch (chunk->GetBlock(relPos))
729 chunk->SetBlock(relPos, itr->m_BlockType, itr->m_BlockMeta);
737 chunk->SetBlock(relPos, itr->m_BlockType, itr->m_BlockMeta);
751 int ChunkX, ChunkZ, X = a_BlockX, Y = 0, Z = a_BlockZ;
756 if ((Chunk !=
nullptr) && Chunk->
IsValid())
772 int ChunkX, ChunkZ, X = a_BlockX, Y = 0, Z = a_BlockZ;
777 if ((Chunk !=
nullptr) && Chunk->
IsValid())
793 int MinChunkX, MinChunkZ, MinX = a_MinX, MinZ = a_MinZ;
794 int MaxChunkX, MaxChunkZ, MaxX = a_MaxX, MaxZ = a_MaxZ;
801 for (
int x = MinChunkX; x <= MaxChunkX; x++)
803 int MinRelX = (x == MinChunkX) ? MinX : 0;
805 for (
int z = MinChunkZ; z <= MaxChunkZ; z++)
807 int MinRelZ = (z == MinChunkZ) ? MinZ : 0;
810 if ((Chunk !=
nullptr) && Chunk->
IsValid())
812 Chunk->
SetAreaBiome(MinRelX, MaxRelX, MinRelZ, MaxRelZ, a_Biome);
831 for (sSetBlockVector::iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
834 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
836 if (!a_ContinueOnFailure)
843 itr->m_BlockType = Chunk->
GetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ);
844 itr->m_BlockMeta = Chunk->
GetMeta(itr->m_RelX, itr->m_RelY, itr->m_RelZ);
860 auto destChunk =
GetChunk(chunkCoords.m_ChunkX, chunkCoords.m_ChunkZ);
861 if ((destChunk ==
nullptr) || !destChunk->IsValid())
882 auto destChunk =
GetChunk(chunkCoords.m_ChunkX, chunkCoords.m_ChunkZ);
883 if ((destChunk ==
nullptr) || !destChunk->IsValid())
887 return destChunk->PickupsFromBlock(relPos, a_Digger, a_Tool);
901 if ((Chunk !=
nullptr) && (Chunk->
IsValid()))
915 if (Chunk1 ==
nullptr)
920 if (Chunk2 ==
nullptr)
938 for (
auto * Client : Clients1)
940 bool Found = (std::find(Clients2.begin(), Clients2.end(), Client) != Clients2.end());
948 for (
auto * Client : Clients2)
950 bool Found = (std::find(Clients1.begin(), Clients1.end(), Client) != Clients1.end());
953 a_Callback.
Added(Client);
966 if (Chunk ==
nullptr)
981 if (Chunk ==
nullptr)
997 Chunk.second->RemoveClient(a_Client);
1009 if (Chunk ==
nullptr)
1011 LOGWARNING(
"Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.",
1012 static_cast<void *>(a_Entity.get()), a_Entity->GetClass(), a_Entity->GetUniqueID()
1027 if (Chunk ==
nullptr)
1029 LOGWARNING(
"Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.",
1030 static_cast<void *>(a_Entity.get()), a_Entity->GetClass(), a_Entity->GetUniqueID()
1034 if (!Chunk->
HasEntity(a_Entity->GetUniqueID()))
1047 for (
const auto & Chunk :
m_Chunks)
1049 if (Chunk.second->IsValid() && Chunk.second->HasEntity(a_UniqueID))
1066 if (Chunk ==
nullptr)
1082 for (
const auto & Chunk :
m_Chunks)
1084 if (Chunk.second->IsValid() && !Chunk.second->ForEachEntity(a_Callback))
1100 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1121 for (
int z = MinChunkZ; z <= MaxChunkZ; z++)
1123 for (
int x = MinChunkX; x <= MaxChunkX; x++)
1126 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1151 bool ShouldDestroyBlocks =
true;
1156 ShouldDestroyBlocks =
false;
1159 int ExplosionSizeInt =
CeilC(a_ExplosionSize);
1160 int ExplosionSizeSq = ExplosionSizeInt * ExplosionSizeInt;
1162 int bx =
FloorC(a_BlockX);
1163 int by =
FloorC(a_BlockY);
1164 int bz =
FloorC(a_BlockZ);
1166 int MinY = std::max(
FloorC(a_BlockY - ExplosionSizeInt), 0);
1169 if (ShouldDestroyBlocks)
1172 a_BlocksAffected.reserve(8 * static_cast<size_t>(ExplosionSizeInt * ExplosionSizeInt * ExplosionSizeInt));
1173 if (!area.
Read(*
m_World, bx - ExplosionSizeInt, static_cast<int>(ceil(a_BlockX + ExplosionSizeInt)), MinY, MaxY, bz - ExplosionSizeInt, static_cast<int>(ceil(a_BlockZ + ExplosionSizeInt))))
1178 for (
int x = -ExplosionSizeInt; x < ExplosionSizeInt; x++)
1180 for (
int y = -ExplosionSizeInt; y < ExplosionSizeInt; y++)
1187 for (
int z = -ExplosionSizeInt; z < ExplosionSizeInt; z++)
1189 if ((x * x + y * y + z * z) > ExplosionSizeSq)
1204 a_BlocksAffected.push_back(
Vector3i(bx + x, by + y, bz + z));
1242 if (Random.RandBool(0.25))
1262 Vector3i BlockPos(bx + x, by + y, bz + z);
1272 a_BlocksAffected.push_back(
Vector3i(bx + x, by + y, bz + z));
1279 area.
Write(*
m_World, bx - ExplosionSizeInt, MinY, bz - ExplosionSizeInt);
1282 Vector3d ExplosionPos{ a_BlockX, a_BlockY, a_BlockZ };
1284 bbTNT.
Expand(ExplosionSizeInt * 2, ExplosionSizeInt * 2, ExplosionSizeInt * 2);
1309 double Length = DistanceFromExplosion.
Length();
1310 if (Length <= ExplosionSizeInt)
1317 double Impact = (1 - ((Length / ExplosionSizeInt) / 2)) * EntityExposure;
1320 DistanceFromExplosion *= Impact;
1322 a_Entity.
AddSpeed(DistanceFromExplosion);
1331 {bx - ExplosionSizeInt - 1, MinY, bz - ExplosionSizeInt - 1},
1332 {bx + ExplosionSizeInt + 1, MaxY, bz + ExplosionSizeInt + 1}
1344 for (
const auto & Chunk :
m_Chunks)
1346 if (Chunk.second->IsValid() && Chunk.second->DoWithEntityByID(a_UniqueID, a_Callback, res))
1362 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1377 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1392 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1407 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1422 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1437 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1452 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1466 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1470 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1484 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1488 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1492 return Chunk->
DoWithBeaconAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
1502 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1506 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1510 return Chunk->
DoWithBedAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
1520 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1524 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1538 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1542 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1546 return Chunk->
DoWithChestAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
1556 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1560 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1574 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1578 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1582 return Chunk->
DoWithDropperAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
1592 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1596 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1610 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1614 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1618 return Chunk->
DoWithFurnaceAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
1628 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1632 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1646 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1650 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1664 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1668 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1672 return Chunk->
DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
1682 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1686 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1700 int BlockX = a_BlockX, BlockY = a_BlockY, BlockZ = a_BlockZ;
1704 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1708 return Chunk->
GetSignLines(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4);
1738 if (a_Callback !=
nullptr)
1740 a_Callback->Call({a_ChunkX, a_ChunkZ},
true);
1752 if (Chunk ==
nullptr)
1759 if ((Chunk ==
nullptr) || (!Chunk->
IsValid()))
1767 m_ChunkMap(a_CBChunkMap),
1768 m_Callback(a_CBCallback)
1773 virtual void Call(
cChunkCoords a_Coords,
bool a_CBIsSuccess)
override 1778 if (m_Callback !=
nullptr)
1780 m_Callback->Call(a_Coords,
true);
1786 cCSLock CBLock(m_ChunkMap.m_CSChunks);
1789 if (CBChunk ==
nullptr)
1792 if (m_Callback !=
nullptr)
1794 m_Callback->Call(a_Coords,
false);
1813 if (a_Callback !=
nullptr)
1815 a_Callback->
Call({a_ChunkX, a_ChunkZ},
true);
1828 if (Chunk ==
nullptr)
1845 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
1849 return Chunk->
SetSignLines(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4);
1860 if (Chunk ==
nullptr)
1876 if (Chunk ==
nullptr)
1892 for (
int z = a_MinChunkZ; z <= a_MaxChunkZ; z++)
1894 for (
int x = a_MinChunkX; x <= a_MaxChunkX; x++)
1897 if ((Chunk ==
nullptr) || (!Chunk->
IsValid()))
1903 if (!a_Callback.Coords(x, z))
1920 for (
const auto & Chunk :
m_Chunks)
1922 if (Chunk.second->IsValid())
1924 if (a_Callback(Chunk.first.ChunkX, Chunk.first.ChunkZ))
1940 int MinChunkX, MaxChunkX;
1941 int MinChunkZ, MaxChunkZ;
1942 int MinBlockX = a_MinBlockX;
1943 int MinBlockY = a_MinBlockY;
1944 int MinBlockZ = a_MinBlockZ;
1945 int MaxBlockX = a_MinBlockX + a_Area.
GetSizeX();
1946 int MaxBlockY = a_MinBlockY + a_Area.
GetSizeY();
1947 int MaxBlockZ = a_MinBlockZ + a_Area.
GetSizeZ();
1954 for (
int z = MinChunkZ; z <= MaxChunkZ; z++)
1956 for (
int x = MinChunkX; x <= MaxChunkX; x++)
1959 if ((Chunk ==
nullptr) || (!Chunk->
IsValid()))
1965 Chunk->
WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
1977 a_NumChunksValid = 0;
1978 a_NumChunksDirty = 0;
1980 for (
const auto & Chunk :
m_Chunks)
1983 if (Chunk.second->IsDirty())
2000 if (chunk ==
nullptr)
2004 return chunk->GrowPlantAt(relPos, a_NumStages);
2018 if (Chunk !=
nullptr)
2031 for (
const auto & Chunk :
m_Chunks)
2036 if (Chunk.second->IsValid() && Chunk.second->HasAnyClients())
2038 Chunk.second->CollectMobCensus(a_ToFill);
2050 for (
const auto & Chunk :
m_Chunks)
2053 if (Chunk.second->IsValid() && Chunk.second->HasAnyClients())
2055 Chunk.second->SpawnMobs(a_MobSpawner);
2067 for (
const auto & Chunk :
m_Chunks)
2070 if (Chunk.second->IsValid() && Chunk.second->ShouldBeTicked())
2072 Chunk.second->Tick(a_Dt);
2087 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
2091 Chunk->
TickBlock(a_BlockX, a_BlockY, a_BlockZ);
2104 (itr->second->CanUnload()) &&
2124 for (
const auto & Chunk :
m_Chunks)
2126 if (Chunk.second->IsValid() && Chunk.second->IsDirty())
2151 for (
const auto & Chunk :
m_Chunks)
2153 if (Chunk.second->IsValid() && Chunk.second->CanUnloadAfterSaving())
2181 if (Chunk !=
nullptr)
2195 if (Chunk !=
nullptr)
2233 for (cChunkCoordsVector::const_iterator itr = WantedChunks.begin(); itr != WantedChunks.end(); ++itr)
2236 if (Chunk ==
nullptr)
2263 bool HasFound =
false;
2266 if (*itr == &a_ChunkStay)
2276 ASSERT(!
"Removing a cChunkStay that hasn't been added!");
2282 for (cChunkCoordsVector::const_iterator itr = Chunks.begin(), end = Chunks.end(); itr != end; ++itr)
2285 if (Chunk ==
nullptr)
void UntrackInDeadlockDetect(cDeadlockDetect &a_DeadlockDetect)
Removes this chunkmap's CS from the DeadlockDetect's tracked CSs.
double GetPosY(void) const
bool ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCallback a_Callback)
Calls the callback for each dispenser in the specified chunk.
BLOCKTYPE GetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ) const
void MarkChunkDirty(int a_ChunkX, int a_ChunkZ)
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
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.
bool DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback a_Callback)
Calls the callback for the dropper at the specified coords.
void SpawnMobs(cMobSpawner &a_MobSpawner)
Try to Spawn Monsters inside all Chunks.
void Set(void)
Sets the event - releases one thread that has been waiting in Wait().
void AddEntity(OwnedEntity a_Entity)
bool IsLightValid(void) const
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.
BLOCKTYPE GetBlock(Vector3i a_BlockPos)
std::list< cChunkStay * > cChunkStays
bool ForEachDispenser(cDispenserCallback a_Callback)
Calls the callback for each dispenser; returns true if all dispensers processed, false if the callbac...
double GetPosX(void) const
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's no bed at those coor...
bool ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback a_Callback)
Calls the callback for each furnace in the specified chunk.
BLOCKTYPE GetBlock(Vector3i a_BlockPos)
Returns the block type at the specified position.
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Allocates memory storing unused elements in a linked list.
Makes chunks stay loaded until this object is cleared or destroyed Works by setting internal flags in...
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's no dropper at ...
cChunkPtr GetChunkNoGen(cChunkCoords a_Chunk)
Constructs a chunk and queues the chunk for loading if not valid, returning it; doesn't generate...
void WakeUp(Vector3i a_Block, cChunk *a_Chunk)
void QueueChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_CallbackAfter)
Queues the entire chunk for lighting.
virtual void OnBroken(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta)
Called after a block gets broken (replaced with air), either by player or by natural means...
bool IsLockedByCurrentThread(void)
Returns true if the CS is currently locked by the thread calling this function.
The chunk is not present, but is queued for loading / generation.
void SetAlwaysTicked(bool a_AlwaysTicked)
Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter.
cChunkPtr GetChunkNoLoad(cChunkCoords a_Coords)
Constructs a chunk, returning it.
std::unique_ptr< T > make_unique(Args &&...args)
bool ShouldMarkDirty(void) const
Returns whether the chunk should be marked as dirty after its data is set.
cChunk * GetParentChunk()
Returns the chunk responsible for ticking this entity.
void GetBlockTypes(BLOCKTYPE *a_BlockTypes)
Copies m_BlockData into a_BlockTypes, only the block types.
void MarkLoadFailed(void)
Marks the chunk as failed to load.
bool ForEachEntity(cEntityCallback a_Callback)
Calls the callback for each entity in the entire world; returns true if all entities processed...
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.
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's no sign at those coo...
unsigned char BLOCKTYPE
The datatype used by blockdata.
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle &a_Client)
void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle *a_Client)
void TrackInDeadlockDetect(cDeadlockDetect &a_DeadlockDetect, const AString &a_WorldName)
Adds this chunkmap's CS to the DeadlockDetect's tracked CSs.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
double GetMinX(void) const
bool ChunkAvailable(int a_ChunkX, int a_ChunkZ)
Called by cChunkMap when a chunk is available, checks m_NumLoaded and triggers the appropriate callba...
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.
void QueueTickBlock(Vector3i a_AbsPos)
Queues the specified block for ticking (block update)
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.
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's no command...
bool IsQueued(void) const
Returns true iff the chunk is in the queue for loading / generating.
void SetChunkData(cSetChunkData &a_SetChunkData)
Sets the chunk data as either loaded from the storage or generated.
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
Sets the blockticking to start at the specified block.
cChunkMap(cWorld *a_World)
bool IsInside(Vector3d a_Point)
Returns true if the point is inside the bounding box.
static bool IsValidHeight(int a_Height)
Validates a height-coordinate.
void Expand(double a_ExpandX, double a_ExpandY, double a_ExpandZ)
Expands the bounding box by the specified amount in each direction (so the box becomes larger by 2 * ...
void AddEntityIfNotPresent(OwnedEntity a_Entity)
Adds the entity to its appropriate chunk, if the entity is not already added.
long int GetTicksAlive(void) const
Gets number of ticks this entity has existed for.
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's no brewings...
void SetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta)
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.
virtual void Added(cClientHandle *a_Client)=0
Called for clients that are in Chunk2 and not in Chunk1.
UInt32 SpawnFallingBlock(Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Spawns an falling block entity at the given position.
void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked)
Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specifie...
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
void QueueTickBlock(Vector3i a_RelPos)
Queues block for ticking (m_ToTickQueue)
int GetChunkX(void) const
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ)
cChunkPtr ConstructChunk(int a_ChunkX, int a_ChunkZ)
Returns or creates and returns a chunk pointer corresponding to the given chunk coordinates.
bool ForEachChest(cChestCallback a_Callback)
Calls the callback for each chest; returns true if all chests processed, false if the callback aborte...
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...
void CollectPickupsByPlayer(cPlayer &a_Player)
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's no block en...
double GetMinZ(void) const
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's no furnace at th...
OwnedEntity RemoveEntity(cEntity &a_Entity)
Releases ownership of the given entity if it was found in this chunk.
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback a_Callback)
Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn'...
EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ)
Returns the biome at the specified coords.
cSimulatorManager * GetSimulatorManager(void)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
std::vector< Vector3i > cVector3iArray
bool DigBlock(Vector3i a_BlockPos)
Removes the block at the specified coords and wakes up simulators.
cChunkStays m_ChunkStays
The cChunkStay descendants that are currently enabled in this chunkmap.
Represents two sets of coords, minimum and maximum for each direction.
void GetChunkStats(int &a_NumChunksValid, int &a_NumChunksDirty)
Returns the number of valid chunks and the number of dirty chunks.
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's no noteblock a...
void SetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType)
bool HasEntity(UInt32 a_EntityID)
cChunkPtr GetChunk(int a_ChunkX, int a_ChunkZ)
Constructs a chunk and queues it for loading / generating if not valid, returning it...
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
double GetWidth(void) const
static cPluginManager * Get(void)
Returns the instance of the Plugin Manager (there is only ever one)
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.
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.
EMCSBiome GetBiomeAt(int a_RelX, int a_RelZ) const
void ReplaceBlocks(const sSetBlockVector &a_Blocks, BLOCKTYPE a_FilterBlockType)
Replaces world blocks with a_Blocks, if they are of type a_FilterBlockType.
eShrapnelLevel GetTNTShrapnelLevel(void) const
bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback a_Callback)
Calls the callback for the chest at the specified coords.
void DelChunkStay(cChunkStay &a_ChunkStay)
Removes the specified cChunkStay descendant from the internal list of ChunkStays. ...
void CollectMobCensus(cMobCensus &a_ToFill)
Make a Mob census, of all mobs, their family, their chunk and their distance to closest player...
void QueueGenerateChunk(cChunkCoords a_Coords, bool a_ForceRegeneration, cChunkCoordCallback *a_Callback=nullptr)
Queues the chunk for generation If a-ForceGenerate is set, the chunk is regenerated even if the data ...
bool IsChunkValid(int a_ChunkX, int a_ChunkZ)
bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback)
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox...
NIBBLETYPE GetBlockMeta(Vector3i a_BlockPos)
bool GenerateChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback *a_CallAfter=nullptr)
Queues the chunk for generating.
double GetHeight(void) const
bool DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback a_Callback)
Calls the callback for the dropspenser at the specified coords.
bool CallHookChunkUnloading(cWorld &a_World, int a_ChunkX, int a_ChunkZ)
size_t GetNumUnusedDirtyChunks(void)
Returns the number of unused dirty chunks.
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.
void MarkChunkRegenerating(int a_ChunkX, int a_ChunkZ)
Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::Regener...
void ChunkValidated(void)
void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, cVector3iArray &a_BlockAffected)
Destroys and returns a list of blocks destroyed in the explosion at the specified coordinates...
cCriticalSection m_CSChunks
static void BlockToChunk(int a_X, int a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords to chunk coords:
bool ForEachEntity(cEntityCallback a_Callback)
Calls the callback for each entity; returns true if all entities processed, false if the callback abo...
bool DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback a_Callback)
Calls the callback for the beacon at the specified coords.
void TrackCriticalSection(cCriticalSection &a_CS, const AString &a_Name)
Adds the critical section for tracking.
bool UseBlockEntity(cPlayer *a_Player, int a_X, int a_Y, int a_Z)
a_Player rclked block entity at the coords specified, handle it returns true if the use was successfu...
bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback a_Callback)
Calls the callback for the furnace at the specified coords.
bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ)
NIBBLETYPE GetBlockSkyLight(Vector3i a_BlockPos)
IntType RandInt(IntType a_Min, IntType a_Max)
Return a random IntType in the range [a_Min, a_Max].
bool IsBlockLiquid(BLOCKTYPE a_BlockType)
bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback a_Callback)
Calls the callback for each block entity in the specified chunk.
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's no flower pot...
void AddEntity(OwnedEntity a_Entity)
Adds the entity to its appropriate chunk, takes ownership of the entity pointer.
virtual void Removed(cClientHandle *a_Client)=0
Called for clients that are in Chunk1 and not in Chunk2,.
void Wait(void)
Waits until the event has been set.
virtual void Disable(void)
Disables the ChunkStay, the chunks are released and the ChunkStay object can be edited with Add() and...
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's no beacon at thos...
This class is used to determine which monster can be spawned in which place it is essentially static ...
Interface class used for comparing clients of two chunks.
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
cLightingThread & GetLightingThread(void)
void AddChunkStay(cChunkStay &a_ChunkStay)
Adds a new cChunkStay descendant to the internal list of ChunkStays; loads its chunks.
size_t GetNumChunks(void)
bool DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
Calls the callback for the chunk at the block position specified, with ChunkMapCS locked; returns fal...
bool GetChunkBlockTypes(int a_ChunkX, int a_ChunkZ, BLOCKTYPE *a_Blocks)
Copies the chunk's blocktypes into a_Blocks; returns true if successful.
double Length(void) const
void UntrackCriticalSection(cCriticalSection &a_CS)
Removes the CS from the tracking.
void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, cPlayer &a_Player)
Sends the block at the specified coords to the specified player.
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) const
bool CallHookChunkAvailable(cWorld &a_World, int a_ChunkX, int a_ChunkZ)
void AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeedZ)
static void AbsoluteToRelative(int &a_X, int &a_Y, int &a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords into relative (chunk + block) coords:
void PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_CallAfter={})
Queues the chunk for preparing - making sure that it's generated and lit.
AString & Printf(AString &str, const char *format, fmt::ArgList args)
Output the formatted text into the string.
EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ)
Returns the biome at the specified coords.
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)
Sets the sign text.
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.
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ)
Marks the chunk as failed-to-load.
Temporary RAII unlock for a cCSLock.
void QueueSaveChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback *a_Callback=nullptr)
Queues a chunk to be saved, asynchronously.
void UnloadUnusedChunks(void)
bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome)
Sets the biome at the area.
std::map< ChunkCoordinate, std::unique_ptr< cChunk >, ChunkCoordinate::Comparer > m_Chunks
A map of chunk coordinates to chunk pointers Uses a map (as opposed to unordered_map) because sorted ...
void LOGWARNING(const char *a_Format, fmt::ArgList a_ArgList)
void SetBlocks(const sSetBlockVector &a_Blocks)
Performs the specified single-block set operations simultaneously, as if SetBlock() was called for ea...
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.
void MarkRegenerating(void)
Marks all clients attached to this chunk as wanting this chunk.
bool IsChunkQueued(int a_ChunkX, int a_ChunkZ)
Returns true iff the chunk is in the loader / generator queue.
void SetBiomeAt(int a_RelX, int a_RelZ, EMCSBiome a_Biome)
Sets the biome at the specified relative coords.
virtual void OnDisabled(void)=0
Called by the ChunkMap when the ChunkStay is disabled.
bool ForEachFurnace(cFurnaceCallback a_Callback)
Calls the callback for each furnace; returns true if all furnaces processed, false if the callback ab...
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's no dropspenser...
cWorldStorage & GetStorage(void)
bool ForEachLoadedChunk(cFunctionRef< bool(int, int)> a_Callback)
Calls the callback for each loaded chunk.
void SetLight(const cChunkDef::BlockNibbles &a_BlockLight, const cChunkDef::BlockNibbles &a_SkyLight)
bool TryGetHeight(int a_BlockX, int a_BlockZ, int &a_Height)
bool ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpenserCallback a_Callback)
Calls the callback for each dropspenser in the specified chunk.
int GetHeight(int a_X, int a_Z)
cBlockHandler * BlockHandler(BLOCKTYPE a_BlockType)
static bool FullyOccupiesVoxel(BLOCKTYPE a_Type)
bool ForEachDropper(cDropperCallback a_Callback)
Calls the callback for each dropper; returns true if all droppers processed, false if the callback ab...
void TakeDamage(cEntity &a_Attacker)
Makes this pawn take damage from an attack by a_Attacker.
void MarkChunkSaved(int a_ChunkX, int a_ChunkZ)
void TickBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
Ticks a single block.
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's no mob he...
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's no chest at those ...
void ReplaceTreeBlocks(const sSetBlockVector &a_Blocks)
Special function used for growing trees, replaces only blocks that tree may overwrite.
std::unique_ptr< cAllocationPool< cChunkData::sChunkSection > > m_Pool
void QueueLoadChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback *a_Callback=nullptr)
Queues a chunk to be loaded, asynchronously.
cItems PickupsFromBlock(Vector3i a_BlockPos, const cEntity *a_Digger, const cItem *a_Tool)
Returns all the pickups that would result if the a_Digger dug up the block at a_BlockPos using a_Tool...
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
bool SetBiomeAt(int a_BlockX, int a_BlockZ, EMCSBiome a_Biome)
Sets the biome at the specified coords.
cChunkGeneratorThread & GetGenerator(void)
bool Read(cForEachChunkProvider &a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes=baTypes|baMetas|baBlockEntities)
Reads an area of blocks specified.
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_BlockMeta, bool a_ShouldMarkDirty, bool a_ShouldInformClients)
Sets the meta for the specified block, while keeping the blocktype.
void Tick(std::chrono::milliseconds a_Dt)
bool ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallback a_Callback)
Calls the callback for each dropper in the specified chunk.
bool ForEachBrewingstandInChunk(int a_ChunkX, int a_ChunkZ, cBrewingstandCallback a_Callback)
Calls the callback for brewingstand in the specified chunk.
bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback)
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox...
bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback a_Callback)
Calls the callback for the noteblock at the specified coords.
bool ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback a_Callback)
Calls the callback for each chest in the specified chunk.
cItems PickupsFromBlock(Vector3i a_AbsPos, const cEntity *a_Digger=nullptr, const cItem *a_Tool=nullptr)
Returns the pickups that would result if the block at the specified position was mined by a_Digger...
bool GetBlockInfo(Vector3i, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_Meta, NIBBLETYPE &a_SkyLight, NIBBLETYPE &a_BlockLight)
Interface class used as a callback for operations that involve chunk coords.
void WakeUpArea(const cCuboid &a_Area)
Does the same processing as WakeUp, but for all blocks within the specified area. ...
OwnedEntity RemoveEntity(cEntity &a_Entity)
Removes the entity from its appropriate chunk Returns an owning reference to the found entity...
bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback &a_Callback)
Calls the callback for each chunk in the coords specified (all cords are inclusive).
This class is used to collect information, for each Mob, what is the distance of the closest player i...
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's no dispenser a...
RAII for cCriticalSection - locks the CS on creation, unlocks on destruction.
UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec=80, double a_InitialVelocityCoeff=1)
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle &a_Client)
Sends the block entity, if it is at the coords specified, to a_Client.
NIBBLETYPE GetBlockBlockLight(Vector3i a_BlockPos)
bool IsPickup(void) const
int GetChunkZ(void) const
int GrowPlantAt(Vector3i a_BlockPos, int a_NumStages=1)
Grows the plant at the specified position by at most a_NumStages.
bool GetChunkData(cChunkCoords a_Coords, cChunkDataCallback &a_Callback)
Calls the callback with the chunk's data, if available (with ChunkCS locked).
virtual void Call(cChunkCoords a_Coords, bool a_IsSuccess)=0
Called with the chunk's coords, and an optional operation status flag for operations that support it...
std::vector< cChunkCoords > cChunkCoordsVector
double GetMaxX(void) const
bool GetBlocks(sSetBlockVector &a_Blocks, bool a_ContinueOnFailure)
Retrieves block types and metas of the specified blocks.
void SetPresence(ePresence a_Presence)
Sets the chunk's presence.
std::unique_ptr< cEntity > OwnedEntity
bool AddClient(cClientHandle *a_Client)
Adds a client to the chunk; returns true if added, false if already there.
void CollectPickupsByPlayer(cPlayer &a_Player)
Makes the specified player collect all the pickups around them.
bool UseBlockEntity(cPlayer *a_Player, int a_X, int a_Y, int a_Z)
Use block entity on coordinate.
const cChunkCoordsVector & GetChunks(void) const
Returns all the chunks that should be kept.
NIBBLETYPE BlockNibbles[NumBlocks/2]
The type used for block data in nibble format, AXIS_ORDER ordering.
void SetNextBlockTick(int a_RelX, int a_RelY, int a_RelZ)
Sets the blockticking to start at the specified block.
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.
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's no brewings...
bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback a_Callback)
Calls the callback for the dispenser at the specified coords.
double GetPosZ(void) const
bool Write(cForEachChunkProvider &a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
Writes the area back into cWorld at the coords specified.
cChunk * FindChunk(int a_ChunkX, int a_ChunkZ)
Locates a chunk ptr in the chunkmap; doesn't create it when not found; assumes m_CSChunks is locked...
void TickBlock(int a_RelX, int a_RelY, int a_RelZ)
Ticks a single block.
cChunkClientHandles GetAllClients(void) const
virtual void OnPlaced(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Called by cWorld::SetBlock() after the block has been set.
void WakeUpSimulators(Vector3i a_Block)
Wakes up simulators for the specified block.
bool DoWithEntityByID(UInt32 a_EntityID, cEntityCallback a_Callback)
Calls the callback if the entity with the specified ID is found, with the entity object as the callba...
bool HasAnyClients(void) const
Returns true if theres any client in the chunk; false otherwise.
bool HasEntity(UInt32 a_EntityID)
Returns true if the entity with specified ID is present in the chunks.
virtual float GetExplosionExposureRate(Vector3d a_ExplosionPosition, float a_ExlosionPower)
a lightweight calculation approach to get explosion exposure rate
bool IsFallingBlock(void) const
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default)
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ)
void GetAllData(cChunkDataCallback &a_Callback)
Gets all chunk data, calls the a_Callback's methods for each data type.
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.
double GetMaxZ(void) const
virtual float GetEnchantmentBlastKnockbackReduction()
Returns explosion knock back reduction percent from blast protection level.
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.
void RemoveChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle *a_Client)
Removes the client from the chunk.
int GetHeight(int a_BlockX, int a_BlockZ)
#define CASE_TREE_OVERWRITTEN_BLOCKS
bool DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback a_Callback)
Calls the callback for the bed at the specified coords.
void RemoveClientFromChunks(cClientHandle *a_Client)
Removes the client from all chunks it is present in.
static bool IsBlockEntityBlockType(BLOCKTYPE a_BlockType)
Returns true if the specified blocktype is supposed to have an associated block entity.
std::vector< sSetBlock > sSetBlockVector
bool WriteBlockArea(cBlockArea &a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
Writes the block area into the specified coords.
void TouchChunk(int a_ChunkX, int a_ChunkZ)
Touches the chunk, causing it to be loaded or generated.
cClientHandle * GetClientHandle(void) const
Returns the raw client handle associated with the player.
This class bridges a vector of cItem for safe access via Lua.
void Stay(bool a_Stay=true)
Sets or resets the internal flag that prevents chunk from being unloaded.
void SetAllData(cSetChunkData &a_SetChunkData)
Sets all chunk data as either loaded from the storage or generated.
std::enable_if< std::is_arithmetic< T >::value, C >::type CeilC(T a_Value)
Ceils a value, then casts it to C (an int by default)
void RemoveClient(cClientHandle *a_Client)
Removes the specified client from the chunk; ignored if client not in chunk.
void ChunkLighted(int a_ChunkX, int a_ChunkZ, const cChunkDef::BlockNibbles &a_BlockLight, const cChunkDef::BlockNibbles &a_SkyLight)