136 virtual int GetHeight(
int a_BlockX,
int a_BlockZ)
override;
148 bool TryGetHeight(
int a_BlockX,
int a_BlockZ,
int & a_Height);
220 int a_ChunkX,
int a_ChunkZ,
311 void PrepareChunk(
int a_ChunkX,
int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_CallAfter = {});
330 bool SetTrapdoorOpen(
int a_BlockX,
int a_BlockY,
int a_BlockZ,
bool a_Open);
339 void QueueLightChunk(
int a_ChunkX,
int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_Callback = {});
344 virtual bool ForEachChunkInRect(
int a_MinChunkX,
int a_MaxChunkX,
int a_MinChunkZ,
int a_MaxChunkZ, cChunkDataCallback & a_Callback)
override;
406 virtual bool WriteBlockArea(
cBlockArea & a_Area,
int a_MinBlockX,
int a_MinBlockY,
int a_MinBlockZ,
int a_DataTypes)
override;
422 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
432 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
434 return SpawnItemPickups(a_Pickups, {a_BlockX, a_BlockY, a_BlockZ}, {a_SpeedX, a_SpeedY, a_SpeedZ}, a_IsPlayerCreated);
442 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
444 return SpawnItemPickup({a_PosX, a_PosY, a_PosZ}, a_Item, {a_SpeedX, a_SpeedY, a_SpeedZ}, a_LifetimeTicks, a_CanCombine);
476 return SpawnMinecart({a_X, a_Y, a_Z}, a_MinecartType, a_Content, a_BlockHeight);
482 LOGWARNING(
"cWorld::SpawnBoat(double, double, double) is deprecated, use cWorld::SpawnBoat(Vector3d) instead.");
483 return SpawnBoat({a_X, a_Y, a_Z}, a_Material);
519 UInt32 SpawnPrimedTNT(
double a_X,
double a_Y,
double a_Z,
int a_FuseTimeInSec = 80,
double a_InitialVelocityCoeff = 1,
bool a_ShouldPlayFuseSound =
true)
521 LOGWARNING(
"cWorld::SpawnPrimedTNT(double, double, double) is deprecated, use cWorld::SpawnPrimedTNT(Vector3d) instead.");
522 return SpawnPrimedTNT({a_X, a_Y, a_Z}, a_FuseTimeInSec, a_InitialVelocityCoeff, a_ShouldPlayFuseSound);
560 return DigBlock({a_X, a_Y, a_Z}, a_Digger);
579 virtual void SendBlockTo(
int a_X,
int a_Y,
int a_Z,
const cPlayer & a_Player)
override;
583 bool SetSpawn(
int a_X,
int a_Y,
int a_Z);
610 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;
667 bool GrowRipePlant(
int a_BlockX,
int a_BlockY,
int a_BlockZ,
bool a_IsByBonemeal =
false)
670 LOGWARNING(
"Warning: cWorld:GrowRipePlant function expects Vector3i-based coords rather than int-based coords. Emulating old-style call.");
763 void GetChunkStats(
int & a_NumValid,
int & a_NumDirty,
int & a_NumInLightingQueue);
794 void QueueBlockForTick(
int a_BlockX,
int a_BlockY,
int a_BlockZ,
int a_TicksToWait);
864 virtual UInt32 SpawnMob(
double a_PosX,
double a_PosY,
double a_PosZ,
eMonsterType a_MonsterType,
bool a_Baby =
false)
override;
912 virtual void Execute(
void)
override;
1096 std::vector<std::pair<std::chrono::milliseconds, std::function<void(
cWorld &)>>>
m_Tasks;
1110 void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
1119 void TickMobs(std::chrono::milliseconds a_Dt);
1141 bool CanSpawnAt(
int a_X,
int & a_Y,
int a_Z);
bool IsBiomeNoDownfall(EMCSBiome a_Biome)
Returns true if the biome has no downfall - deserts and savannas.
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
std::vector< sSetBlock > sSetBlockVector
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
std::unique_ptr< cEntity > OwnedEntity
unsigned char BLOCKTYPE
The datatype used by blockdata.
eDimension
Dimension of a world.
eExplosionSource
The source of an explosion.
std::chrono::duration< signed long long int, cTickTime::period > cTickTimeLong
std::chrono::duration< signed int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 > >> cTickTime
void LOGWARNING(std::string_view a_Format, const Args &... args)
eMonsterType
Identifies individual monster type.
std::vector< AString > AStringVector
Vector3< double > Vector3d
virtual void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, const cPlayer &a_Player)=0
Sends the block on those coords to the player.
Represents two sets of coords, minimum and maximum for each direction.
Wraps the chunk coords into a single structure.
NIBBLETYPE BlockNibbles[NumBlocks/2]
The type used for block data in nibble format, AXIS_ORDER ordering.
Interface class used for comparing clients of two chunks.
Takes requests for generating chunks and processes them in a separate thread one by one.
size_t GetQueueLength() const
The interface through which the plugins are called for their OnChunkGenerating / OnChunkGenerated hoo...
The interface through which the generated chunks are handed to the cWorld or whoever created us.
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
NIBBLETYPE GetBlockMeta(Vector3i a_BlockPos) const
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...
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
Priority
Tag indicating urgency of chunk to be sent.
Container for a single chat message composed of multiple functional parts.
eKind
The kind of the projectile.
The interface that all chunk generators must implement to provide the generated chunks.
This class bridges a vector of cItem for safe access via Lua.
size_t GetQueueLength(void)
Manages the in-game maps of a single world - Thread safe.
RAII for cCriticalSection - locks the CS on creation, unlocks on destruction.
cCSLock(cCriticalSection *a_CS)
cIsThread(AString &&a_ThreadName)
Contains the data for a loaded / generated chunk, ready to be set into a cWorld.
The fire simulator takes care of the fire blocks.
Despite the class name, this simulator takes care of all blocks that fall when suspended in the air.
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.
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).
bool ShouldUseChatPrefixes(void) const
cRedstoneSimulator * InitializeRedstoneSimulator(cIniFile &a_IniFile)
Creates a new redstone simulator.
bool IsSlimeChunk(int a_ChunkX, int a_ChunkZ) const
Returns true if slimes should spawn in the chunk.
virtual void BroadcastUnleashEntity(const cEntity &a_Entity) override
bool IsWeatherSunny(void) const
Returns true if the current weather is sunny.
cChunkGeneratorThread & GetGenerator(void)
virtual void BroadcastScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode) override
void ScheduleTask(cTickTime a_DelayTicks, std::function< void(cWorld &)> a_Task)
Queues a lambda task onto the tick thread, with the specified delay.
int GetSeed(void) const
Returns the seed of the world.
std::vector< std::pair< std::chrono::milliseconds, 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...
void MarkChunkDirty(int a_ChunkX, int a_ChunkZ)
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.
virtual void BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle *a_Exclude=nullptr) override
bool m_bCommandBlocksEnabled
Whether command blocks are enabled or not.
UInt32 SpawnMobFinalize(std::unique_ptr< cMonster > a_Monster)
Wraps cEntity::Initialize, doing Monster-specific things before spawning the monster.
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ)
Marks the chunk as failed-to-load:
void TickMobs(std::chrono::milliseconds a_Dt)
Handles the mob spawning / moving / destroying each tick.
cScoreboard & GetScoreBoard(void)
Returns the associated scoreboard instance.
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.
cChunkSender m_ChunkSender
virtual void BroadcastPlayerListUpdateGameMode(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
bool ShouldLavaSpawnFire(void) const
void BroadcastEntityProperties(const cEntity &a_Entity)
UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec=80, double a_InitialVelocityCoeff=1, bool a_ShouldPlayFuseSound=true)
int GetTicksUntilWeatherChange(void) const
bool IsGameModeSpectator(void) const
Returns true if the world is in Spectator mode.
bool IsSavingEnabled(void) const
Get whether saving chunks is enabled.
virtual ~cWorld() override
void RemoveClientFromChunks(cClientHandle *a_Client)
Removes the client from all chunks it is present in.
bool CheckPlayerSpawnPoint(int a_PosX, int a_PosY, int a_PosZ)
Check if player starting point is acceptable.
eShrapnelLevel m_TNTShrapnelLevel
The level of DoExplosionAt() projecting random affected blocks as FallingBlock entities See the eShra...
bool DoWithPlayerByUUID(const cUUID &a_PlayerUUID, cPlayerListCallback a_Callback)
Finds the player over his uuid and calls the callback.
virtual void BroadcastChatDeath(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
cFluidSimulator * GetWaterSimulator(void)
void AddEntity(OwnedEntity a_Entity, cWorld *a_OldWorld=nullptr)
Adds the entity into its appropriate chunk; takes ownership of the entity ptr.
UInt32 SpawnExperienceOrb(Vector3d a_Pos, int a_Reward)
Spawns an experience orb at the given location with the given reward.
const AString & GetDataPath(void) const
Returns the data path to the world data.
std::chrono::milliseconds m_WorldDate
The fully controllable age of the world.
int GetSpawnX(void) const
bool IsWeatherRain(void) const
Returns true if the current weather is rainy.
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:
std::unique_ptr< cSandSimulator > m_SandSimulator
virtual void BroadcastPlayerListUpdatePing() override
bool DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
Calls the callback for the chunk at the block position specified, with ChunkMapCS locked.
size_t GetPlayerCount() const
Returns the number of players currently in this world.
cLightingThread m_Lighting
bool IsGameModeSurvival(void) const
Returns true if the world is in Survival mode.
virtual void BroadcastTimeUpdate(const cClientHandle *a_Exclude=nullptr) override
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.
virtual void BroadcastDetachEntity(const cEntity &a_Entity, const cEntity &a_PreviousVehicle) override
int m_MinThunderStormTicks
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.
void SetLinkedEndWorldName(const AString &a_Name)
void RegenerateChunk(int a_ChunkX, int a_ChunkZ)
Regenerate the given chunk.
void UnloadUnusedChunks(void)
Unloads all chunks immediately.
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.
std::chrono::milliseconds m_WorldAge
The age of the world.
std::vector< BlockTickQueueItem * > m_BlockTickQueueCopy
bool GetBlockInfo(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_Meta, NIBBLETYPE &a_SkyLight, NIBBLETYPE &a_BlockLight) const
Queries the whole block specification from the world.
void QueueSetChunkData(SetChunkData &&a_SetChunkData)
Puts the chunk data into a queue to be set into the chunkmap in the tick thread.
virtual cBroadcastInterface & GetBroadcastManager(void) override
void SetLinkedNetherWorldName(const AString &a_Name)
virtual void BroadcastAttachEntity(const cEntity &a_Entity, const cEntity &a_Vehicle) override
cRedstoneSimulator * m_RedstoneSimulator
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
void TabCompleteUserName(const AString &a_Text, AStringVector &a_Results)
Appends all usernames starting with a_Text (case-insensitive) into Results.
UInt32 SpawnBoat(double a_X, double a_Y, double a_Z, cBoat::eMaterial a_Material)
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...
virtual void BroadcastChatFailure(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
NIBBLETYPE GetBlockSkyLight(Vector3i a_BlockPos) const
Returns the sky light value at the specified block position.
virtual void BroadcastChatWarning(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastPlayerListAddPlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
bool CanSpawnAt(int a_X, int &a_Y, int a_Z)
Can the specified coordinates be used as a spawn point? Returns true if spawn position is valid and s...
bool IsPVPEnabled(void) const
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation, const cClientHandle *a_Exclude=nullptr) override
int GrowPlantAt(Vector3i a_BlockPos, int a_NumStages=1)
Grows the plant at the specified position by at most a_NumStages.
bool GrowRipePlant(Vector3i a_BlockPos)
Grows the plant at the specified block to its ripe stage.
int GetDefaultWeatherInterval(eWeather a_Weather) const
Returns the default weather interval for the specific weather type.
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback a_Callback)
Calls the callback for the chunk specified, with ChunkMapCS locked.
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.
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
bool GetLargeTreeAdjustment(Vector3i &a_BlockPos, NIBBLETYPE a_SaplingMeta)
Checks if the sapling at the specified block coord is a part of a large-tree sapling (2x2).
bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome)
Sets the biome at the area.
eShrapnelLevel GetTNTShrapnelLevel(void) const
virtual void BroadcastCollectEntity(const cEntity &a_Collected, const cEntity &a_Collector, unsigned a_Count, const cClientHandle *a_Exclude=nullptr) override
void SetSavingEnabled(bool a_IsSavingEnabled)
Set whether saving chunks is enabled.
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.
int GetTickRandomNumber(int a_Range)
Returns a random number in range [0 .
void QueueUnloadUnusedChunks(void)
Queues a task to unload unused chunks onto the tick thread.
int m_MaxNetherPortalHeight
cCriticalSection m_CSTasks
Guards the m_Tasks.
bool IsDeepSnowEnabled(void) const
virtual cTickTimeLong GetWorldAge(void) const override
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.
bool GetChunkData(cChunkCoords a_Coords, cChunkDataCallback &a_Callback) const
Calls the callback with the chunk's data, if available (with ChunkCS locked).
bool IsGameModeAdventure(void) const
Returns true if the world is in Adventure mode.
void TickQueuedChunkDataSets()
Sets the chunk data queued in the m_SetChunkDataQueue queue into their chunk.
AString GetLinkedNetherWorldName(void) const
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...
void MarkChunkSaved(int a_ChunkX, int a_ChunkZ)
NIBBLETYPE GetBlockBlockLight(Vector3i a_BlockPos) const
Returns the block-light value at the specified block position.
void RemoveChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle *a_Client)
Removes client from the chunk specified.
std::vector< cPlayer * > m_Players
UInt32 SpawnEnderCrystal(Vector3d a_Pos, bool a_ShowBottom)
Spawns a new ender crystal at the specified block coords.
const AString & GetName(void) const
Returns the name of the world.
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.
virtual void BroadcastPlayerListHeaderFooter(const cCompositeChat &a_Header, const cCompositeChat &a_Footer) override
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Retrieves the block type and meta at the specified coords.
bool m_BroadcastAchievementMessages
bool m_bUseChatPrefixes
Whether prefixes such as [INFO] are prepended to SendMessageXXX() / BroadcastChatXXX() functions.
int m_StorageCompressionFactor
void TickWeather(float a_Dt)
Handles the weather in each tick.
void GetChunkStats(int &a_NumValid, int &a_NumDirty, int &a_NumInLightingQueue)
Returns the number of chunks loaded and dirty, and in the lighting queue.
int m_MaxViewDistance
The maximum view distance that a player can have in this world.
virtual void SetMinNetherPortalWidth(int a_NewMinWidth) override
virtual void BroadcastEntityHeadLook(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
std::atomic< bool > m_IsSavingEnabled
Whether or not writing chunks to disk is currently enabled.
bool IsChunkValid(int a_ChunkX, int a_ChunkZ) const
Returns true iff the chunk is present and valid.
int GetMaxCactusHeight(void) const
void QueueTask(std::function< void(cWorld &)> a_Task)
Queues a task onto the tick thread.
AString GetLinkedOverworldName(void) const
bool SetCommandBlockCommand(Vector3i a_BlockPos, const AString &a_Command)
UInt32 SpawnFallingBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Spawns an falling block entity at the given position.
virtual void SetMinNetherPortalHeight(int a_NewMinHeight) override
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
bool ShouldBroadcastDeathMessages(void) const
AString GetLinkedEndWorldName(void) const
bool m_IsDaylightCycleEnabled
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.
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.
bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ) const
Returns true if it is sunny at the specified location.
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...
bool ShouldBroadcastAchievementMessages(void) const
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.
void GenerateRandomSpawn(int a_MaxSpawnRadius)
Generates a random spawnpoint on solid land by walking chunks and finding their biomes.
virtual void SetMaxNetherPortalWidth(int a_NewMaxWidth) override
bool IsWeatherRainAt(int a_BlockX, int a_BlockZ)
Returns true if it is raining at the specified location.
int GetSpawnZ(void) const
cLightingThread & GetLightingThread(void)
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.
virtual void BroadcastBossBarUpdateHealth(const cEntity &a_Entity, UInt32 a_UniqueID, float a_FractionFilled) override
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
bool VillagersShouldHarvestCrops(void) const
void TickClients(std::chrono::milliseconds a_Dt)
Ticks all clients that are in this world.
virtual void BroadcastChatSuccess(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
int GetMaxViewDistance(void) const
void SetTicksUntilWeatherChange(int a_WeatherInterval)
virtual eDimension GetDimension(void) const override
void SaveAllChunks(void)
Saves all chunks immediately.
void SendPlayerList(cPlayer *a_DestPlayer)
virtual void SetDaylightCycleEnabled(bool a_IsDaylightCycleEnabled)
Sets the daylight cycle to true / false.
eGameMode GetGameMode(void) const
Returns the current game mode.
void TickQueuedTasks(void)
Executes all tasks queued onto the tick thread.
std::unique_ptr< cFireSimulator > m_FireSimulator
UInt32 SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
OBSOLETE, use the Vector3-based overload instead.
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...
void SetNextBlockToTick(const Vector3i a_BlockPos)
Causes the specified block to be ticked on the next Tick() call.
virtual void BroadcastEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item, const cClientHandle *a_Exclude=nullptr) override
int m_MaxNetherPortalWidth
void InitializeSpawn(void)
bool DigBlock(Vector3i a_BlockPos, const cEntity *a_Digger=nullptr)
Replaces the specified block with air, and calls the OnBroken block handler.
void SetShouldUseChatPrefixes(bool a_Flag)
void GenerateChunk(int a_ChunkX, int a_ChunkZ)
Generates the given chunk.
std::vector< UInt32 > SpawnSplitExperienceOrbs(double a_X, double a_Y, double a_Z, int a_Reward)
OBSOLETE, use the Vector3d-based overload instead.
void InitializeAndLoadMobSpawningValues(cIniFile &a_IniFile)
Sets mob spawning values if nonexistant to their dimension specific defaults.
void ForceSendChunkTo(int a_ChunkX, int a_ChunkZ, cChunkSender::Priority a_Priority, cClientHandle *a_Client)
Sends the chunk to the client specified, even if the client already has the chunk.
bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ)
bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const
Returns true iff the chunk is in the loader / generator queue.
size_t m_UnusedDirtyChunksCap
The maximum number of allowed unused dirty chunks for this world.
cFluidSimulator * m_LavaSimulator
cChunkGeneratorThread m_Generator
The thread responsible for generating chunks.
virtual void BroadcastSpawnEntity(cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
NIBBLETYPE GetBlockMeta(Vector3i a_BlockPos) const
Returns the block meta at the specified position.
virtual void BroadcastPlayerListUpdateDisplayName(const cPlayer &a_Player, const AString &a_CustomName, const cClientHandle *a_Exclude=nullptr) override
virtual bool IsDaylightCycleEnabled(void) const
Is the daylight cycle enabled?
AString m_LinkedOverworldName
The name of the overworld that portals in this world should link to.
bool GrowTreeFromSapling(Vector3i a_BlockPos)
Grows a tree from the sapling at the specified coords.
bool SetSignLines(Vector3i a_BlockPos, 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.
void CollectPickupsByEntity(cEntity &a_Entity)
bool m_BroadcastDeathMessages
bool m_ShouldLavaSpawnFire
std::set< eMonsterType > m_AllowedMobs
void SendChunkTo(int a_ChunkX, int a_ChunkZ, cChunkSender::Priority a_Priority, cClientHandle *a_Client)
Sends the chunk to the client specified, if the client doesn't have the chunk yet.
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.
virtual int GetMinNetherPortalWidth(void) const override
Returns or sets the minumim or maximum netherportal width.
virtual void WakeUpSimulators(Vector3i a_Block) override
Wakes up the simulators for the specified block.
bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString &a_Command)
Sets the command block command.
virtual void BroadcastEntityLook(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastEntityVelocity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open)
Set the state of a trapdoor.
size_t GetGeneratorQueueLength(void)
void Start()
Starts threads that belong to this world.
void TickQueuedBlocks(void)
Processes the blocks queued for ticking with a delay (m_BlockTickQueue[])
eWeather GetWeather(void) const
Returns the current weather.
eDimension m_Dimension
The dimension of the world, used by the client to provide correct lighting scheme.
virtual void BroadcastWeather(eWeather a_Weather, const cClientHandle *a_Exclude=nullptr) override
void ChunkLighted(int a_ChunkX, int a_ChunkZ, const cChunkDef::BlockNibbles &a_BlockLight, const cChunkDef::BlockNibbles &a_SkyLight)
bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const
void ChangeWeather(void)
Forces a weather change in the next game tick.
std::unique_ptr< cSimulatorManager > m_SimulatorManager
bool IsWeatherStormAt(int a_BlockX, int a_BlockZ)
Returns true if the weather is stormy at the specified location.
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.
AString m_LinkedNetherWorldName
Name of the nether world - where Nether portals should teleport.
void SetCommandBlocksEnabled(bool a_Flag)
NIBBLETYPE GetSkyDarkness()
Get the current darkness level based on the time.
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.
bool GrowTreeImage(const sSetBlockVector &a_Blocks)
Imprints the specified blocks into the world, as long as each log block replaces only allowed blocks.
bool ForEachEntity(cEntityCallback a_Callback)
Calls the callback for each entity in the entire world; returns true if all entities processed,...
bool SetSpawn(int a_X, int a_Y, int a_Z)
Set default spawn at the given coordinates.
void TickQueuedEntityAdditions(void)
Adds the entities queued in the m_EntitiesToAdd queue into their chunk.
std::map< cMonster::eFamily, cTickTimeLong > m_LastSpawnMonster
size_t GetNumUnusedDirtyChunks(void) const
Returns the number of unused dirty chunks.
cTickTimeLong m_WorldTickAge
The time since this world began, in ticks.
size_t GetStorageSaveQueueLength(void)
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ)
void PlaceBlock(const Vector3i a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta)
Replaces the specified block with another, and calls the OnPlaced block handler.
virtual void BroadcastLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo) override
virtual void BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, Int8 a_Stage, const cClientHandle *a_Exclude=nullptr) override
virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) override
Returns true if it is raining or storming at the specified location.
cChunkGeneratorCallbacks m_GeneratorCallbacks
The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins.
cCriticalSection m_CSEntitiesToAdd
Guards m_EntitiesToAdd.
virtual void BroadcastChat(const AString &a_Message, const cClientHandle *a_Exclude=nullptr, eMessageType a_ChatPrefix=mtCustom) override
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.
unsigned int m_MaxPlayers
bool GrowTreeByBiome(Vector3i a_BlockPos)
Grows a tree at the specified coords, based on the biome in the place.
bool GrowTree(Vector3i a_BlockPos)
Grows a tree at the specified coords.
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.
void QueueSaveAllChunks(void)
Queues a task to save all chunks onto the tick thread.
virtual void SetMaxNetherPortalHeight(int a_NewMaxHeight) override
std::vector< SetChunkData > m_SetChunkDataQueue
Queue for the chunk data to be set into m_ChunkMap by the tick thread.
virtual int GetMaxNetherPortalWidth(void) const override
std::chrono::milliseconds m_LastChunkCheck
EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ)
Returns the biome at the specified coords.
cRedstoneSimulator * GetRedstoneSimulator(void)
AString m_StorageSchema
Name of the storage schema used to load and save chunks.
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...
bool m_bFarmlandTramplingEnabled
UInt32 SpawnMinecart(Vector3d a_Pos, int a_MinecartType, const cItem &a_Content=cItem(), int a_BlockHeight=1)
Spawns an minecart at the given coordinates.
bool IsFarmlandTramplingEnabled(void) const
Returns true if farmland trampling is enabled.
virtual void BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle *a_Exclude=nullptr) override
const AString & GetIniFileName(void) const
Returns the name of the world.ini file used by this world.
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...
int m_MaxThunderStormTicks
bool GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal=false)
OBSOLETE, use the Vector3-based overload instead.
virtual cTickTime GetTimeOfDay(void) const override
bool SetBiomeAt(int a_BlockX, int a_BlockZ, EMCSBiome a_Biome)
Sets the biome at the specified coords.
cFluidSimulator * GetLavaSimulator(void)
virtual bool DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback) override
Calls the callback for the block entity at the specified coords; returns false if there's no block en...
virtual bool IsWeatherWetAtXYZ(Vector3i a_Position) override
Returns true if it is raining or storming at the specified location, and the rain reaches (the bottom...
virtual UInt32 SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) override
OBSOLETE, use the Vector3d-based overload instead.
std::vector< std::pair< OwnedEntity, cWorld * > > m_EntitiesToAdd
List of entities that are scheduled for adding, waiting for the Tick thread to add them.
int m_MinNetherPortalWidth
cMapManager & GetMapManager(void)
Returns the associated map manager instance.
virtual void BroadcastChatFatal(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
cTickTimeLong GetWorldTickAge() const
virtual std::vector< UInt32 > SpawnSplitExperienceOrbs(Vector3d a_Pos, int a_Reward) override
Spawns experience orbs of the specified total value at the given location.
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.
virtual int GetMaxNetherPortalHeight(void) const override
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)
virtual void BroadcastEntityPosition(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
bool DigBlock(int a_X, int a_Y, int a_Z, cEntity *a_Digger=nullptr)
OBSOLETE, use the Vector3-based overload instead.
virtual void BroadcastChatInfo(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
AString m_DataPath
The path to the root directory for the world files.
std::vector< BlockTickQueueItem * > m_BlockTickQueue
std::chrono::milliseconds m_LastSave
virtual void BroadcastEntityEffect(const cEntity &a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle *a_Exclude=nullptr) override
eWeather ChooseNewWeather(void)
Chooses a reasonable transition from the current weather to a new weather.
cWorldStorage & GetStorage(void)
void CastThunderbolt(Vector3i a_Block)
Casts a thunderbolt at the specified coords.
UInt32 SpawnFallingBlock(Vector3d a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Spawns an falling block entity at the given position.
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.
void SetLinkedOverworldName(const AString &a_Name)
void SetMaxViewDistance(int a_MaxViewDistance)
size_t GetLightingQueueLength(void)
size_t GetStorageLoadQueueLength(void)
size_t GetNumChunks() const
Returns the number of chunks loaded
AString m_LinkedEndWorldName
Name of the End world - where End portals should teleport.
virtual void BroadcastDestroyEntity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
cCriticalSection m_CSSetChunkDataQueue
CS protecting m_SetChunkDataQueue.
virtual void BroadcastScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode) override
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
virtual void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, const cPlayer &a_Player)=0
Sends the block on those coords to the player.
bool GetBlocks(sSetBlockVector &a_Blocks, bool a_ContinueOnFailure)
Retrieves block types of the specified blocks.
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,...
bool ForEachLoadedChunk(cFunctionRef< bool(int, int)> a_Callback)
Calls the callback for each loaded chunk.
int GetMaxSugarcaneHeight(void) const
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.
int GetSpawnY(void) const
void WakeUpSimulatorsInArea(const cCuboid &a_Area)
Wakes up the simulators for the specified area of blocks.
cTickTimeLong GetWorldDate() const
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData)
Sets the meta for the specified block, while keeping the blocktype.
cChunkMap * GetChunkMap(void)
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 UpdateSkyDarkness(void)
bool IsWeatherWet(void) const
Returns true if the world currently has any precipitation - rain, storm or snow.
virtual void BroadcastPlayerListRemovePlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
cSimulatorManager * GetSimulatorManager(void)
virtual void BroadcastDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display) override
bool AreCommandBlocksEnabled(void) const
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ)
int m_MinNetherPortalHeight
OwnedEntity RemoveEntity(cEntity &a_Entity)
Removes the entity from the world.
bool m_VillagersShouldHarvestCrops
void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
virtual bool ForEachPlayer(cPlayerListCallback a_Callback) override
Calls the callback for each player in the list; returns true if all players processed,...
virtual void BroadcastRemoveEntityEffect(const cEntity &a_Entity, int a_EffectID, const cClientHandle *a_Exclude=nullptr) override
void SetTNTShrapnelLevel(eShrapnelLevel a_Flag)
virtual void SetTimeOfDay(cTickTime a_TimeOfDay) override
bool IsWeatherStorm(void) const
Returns true if the current weather is stormy.
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
void SetWeather(eWeather a_NewWeather)
Sets the specified weather; resets weather interval; asks and notifies plugins of the change.
bool IsGameModeCreative(void) const
Returns true if the world is in Creative mode.
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.
virtual int GetMinNetherPortalHeight(void) const override
Returns or sets the minumim or maximum netherportal height.
void Stop(cDeadlockDetect &a_DeadlockDetect)
Stops threads that belong to this world (part of deinit).
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.
bool m_IsSpawnExplicitlySet
cFluidSimulator * m_WaterSimulator
A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the dest...
cLock(const cWorld &a_World)
cTickThread(cWorld &a_World)
virtual void Execute(void) override
This function, overloaded by the descendants, is called in the new thread.
Implementation of the callbacks that the ChunkGenerator uses to store new chunks and interface to plu...
virtual bool IsChunkValid(cChunkCoords a_Coords) override
Called just before the chunk generation is started, to verify that it hasn't been generated in the me...
cChunkGeneratorCallbacks(cWorld &a_World)
virtual void CallHookChunkGenerated(cChunkDesc &a_ChunkDesc) override
Called after the chunk is generated, before it is handed to the chunk sink.
virtual void CallHookChunkGenerating(cChunkDesc &a_ChunkDesc) override
Called when the chunk is about to be generated.
virtual bool HasChunkAnyClients(cChunkCoords a_Coords) override
Called when the generator is overloaded to skip chunks that are no longer needed.
virtual void OnChunkGenerated(cChunkDesc &a_ChunkDesc) override
Called after the chunk has been generated The interface may store the chunk, send it over network,...
virtual bool IsChunkQueued(cChunkCoords a_Coords) override
Called to check whether the specified chunk is in the queued state.
The actual world storage class.
size_t GetSaveQueueLength(void)
size_t GetLoadQueueLength(void)