2013-11-13 08:50:47 -05:00
# pragma once
# ifndef _WIN32
# include "BlockID.h"
# else
enum ENUM_ITEM_ID ;
# endif
# define MAX_PLAYERS 65535
2016-11-18 14:00:04 -05:00
# include <functional>
2013-11-13 08:50:47 -05:00
# include "Simulator/SimulatorManager.h"
# include "ChunkMap.h"
# include "WorldStorage/WorldStorage.h"
# include "Generating/ChunkGenerator.h"
2014-03-11 10:01:17 -04:00
# include "Vector3.h"
2013-11-13 08:50:47 -05:00
# include "ChunkSender.h"
# include "Defines.h"
# include "LightingThread.h"
# include "Item.h"
# include "Mobs/Monster.h"
# include "Entities/ProjectileEntity.h"
2014-01-20 13:15:19 -05:00
# include "ForEachChunkProvider.h"
2014-01-19 07:20:57 -05:00
# include "Scoreboard.h"
2014-02-20 09:38:37 -05:00
# include "MapManager.h"
2014-01-25 14:14:14 -05:00
# include "Blocks/WorldInterface.h"
2014-01-26 09:20:39 -05:00
# include "Blocks/BroadcastInterface.h"
2014-10-19 09:10:18 -04:00
# include "FastRandom.h"
2015-11-23 18:39:19 -05:00
# include "EffectID.h"
2013-11-13 08:50:47 -05:00
class cFireSimulator ;
class cFluidSimulator ;
class cSandSimulator ;
2014-02-07 16:59:08 -05:00
class cRedstoneSimulator ;
2013-11-13 08:50:47 -05:00
class cItem ;
class cPlayer ;
class cClientHandle ;
2015-01-24 14:17:00 -05:00
typedef SharedPtr < cClientHandle > cClientHandlePtr ;
typedef std : : list < cClientHandlePtr > cClientHandlePtrs ;
typedef std : : list < cClientHandle * > cClientHandles ;
2013-11-13 08:50:47 -05:00
class cEntity ;
class cBlockEntity ;
class cWorldGenerator ; // The generator that actually generates the chunks for a single world
class cChunkGenerator ; // The thread responsible for generating chunks
2014-07-30 16:19:51 -04:00
class cBeaconEntity ;
2015-09-24 04:48:33 -04:00
class cBrewingstandEntity ;
2013-11-13 08:50:47 -05:00
class cChestEntity ;
class cDispenserEntity ;
2014-03-06 19:30:34 -05:00
class cFlowerPotEntity ;
2013-11-13 08:50:47 -05:00
class cFurnaceEntity ;
2013-12-14 11:52:22 -05:00
class cNoteEntity ;
2014-02-19 08:45:09 -05:00
class cMobHeadEntity ;
2014-02-15 17:16:44 -05:00
class cCompositeChat ;
2014-02-18 07:06:18 -05:00
class cCuboid ;
2014-07-24 12:32:05 -04:00
class cSetChunkData ;
2015-03-21 13:17:26 -04:00
class cBroadcaster ;
2017-01-17 16:38:04 -05:00
class cDeadlockDetect ;
2013-11-13 08:50:47 -05:00
typedef std : : list < cPlayer * > cPlayerList ;
2016-08-22 13:43:43 -04:00
typedef std : : list < std : : pair < cPlayer * , cWorld * > > cAwaitingPlayerList ;
2013-11-13 08:50:47 -05:00
2014-07-24 12:32:05 -04:00
typedef SharedPtr < cSetChunkData > cSetChunkDataPtr ; // TODO: Change to unique_ptr once we go C++11
typedef std : : vector < cSetChunkDataPtr > cSetChunkDataPtrs ;
2014-01-18 08:16:47 -05:00
typedef cItemCallback < cPlayer > cPlayerListCallback ;
typedef cItemCallback < cEntity > cEntityCallback ;
2014-07-30 16:19:51 -04:00
typedef cItemCallback < cBeaconEntity > cBeaconCallback ;
2015-09-24 04:48:33 -04:00
typedef cItemCallback < cBrewingstandEntity > cBrewingstandCallback ;
2014-01-18 08:16:47 -05:00
typedef cItemCallback < cChestEntity > cChestCallback ;
typedef cItemCallback < cDispenserEntity > cDispenserCallback ;
typedef cItemCallback < cFurnaceEntity > cFurnaceCallback ;
typedef cItemCallback < cNoteEntity > cNoteBlockCallback ;
typedef cItemCallback < cCommandBlockEntity > cCommandBlockCallback ;
2014-03-07 05:44:16 -05:00
typedef cItemCallback < cMobHeadEntity > cMobHeadCallback ;
2014-03-06 19:30:34 -05:00
typedef cItemCallback < cFlowerPotEntity > cFlowerPotCallback ;
2013-11-13 08:50:47 -05:00
2016-10-12 08:38:45 -04:00
typedef std : : function < bool ( cPlayer * ) > cLambdaPlayerCallback ;
typedef std : : function < bool ( cEntity * ) > cLambdaEntityCallback ;
2013-11-13 08:50:47 -05:00
// tolua_begin
2014-02-18 02:25:29 -05:00
class cWorld :
public cForEachChunkProvider ,
public cWorldInterface ,
2014-02-23 08:03:40 -05:00
public cBroadcastInterface
2013-11-13 08:50:47 -05:00
{
public :
// tolua_end
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the destructor */
2013-11-13 08:50:47 -05:00
class cLock :
public cCSLock
{
typedef cCSLock super ;
public :
cLock ( cWorld & a_World ) ;
2015-06-22 22:00:15 -04:00
} ;
2013-11-13 08:50:47 -05:00
static const char * GetClassStatic ( void ) // Needed for ManualBindings's ForEach templates
{
return " cWorld " ;
}
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// tolua_begin
int GetTicksUntilWeatherChange ( void ) const { return m_WeatherInterval ; }
2014-08-06 19:07:32 -04:00
2015-05-09 03:25:09 -04:00
/** Is the daylight cycle enabled? */
2014-08-10 10:46:03 -04:00
virtual bool IsDaylightCycleEnabled ( void ) const { return m_IsDaylightCycleEnabled ; }
2014-08-06 19:07:32 -04:00
2015-05-09 03:25:09 -04:00
/** Sets the daylight cycle to true / false. */
2014-08-10 10:46:03 -04:00
virtual void SetDaylightCycleEnabled ( bool a_IsDaylightCycleEnabled )
2014-08-06 19:07:32 -04:00
{
2014-08-10 10:46:03 -04:00
m_IsDaylightCycleEnabled = a_IsDaylightCycleEnabled ;
2014-08-06 19:07:32 -04:00
BroadcastTimeUpdate ( ) ;
}
2015-01-11 16:12:26 -05:00
virtual Int64 GetWorldAge ( void ) const override { return std : : chrono : : duration_cast < cTickTimeLong > ( m_WorldAge ) . count ( ) ; }
virtual int GetTimeOfDay ( void ) const override { return std : : chrono : : duration_cast < cTickTime > ( m_TimeOfDay ) . count ( ) ; }
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
void SetTicksUntilWeatherChange ( int a_WeatherInterval )
{
m_WeatherInterval = a_WeatherInterval ;
}
2014-09-08 14:07:45 -04:00
virtual void SetTimeOfDay ( int a_TimeOfDay ) override
2013-11-13 08:50:47 -05:00
{
2015-01-11 16:12:26 -05:00
m_TimeOfDay = cTickTime ( a_TimeOfDay ) ;
2014-08-06 19:07:32 -04:00
UpdateSkyDarkness ( ) ;
2013-11-13 08:50:47 -05:00
BroadcastTimeUpdate ( ) ;
}
2016-02-05 16:45:45 -05:00
2014-03-03 14:55:04 -05:00
/** Returns the default weather interval for the specific weather type.
Returns - 1 for any unknown weather . */
2014-03-02 15:04:01 -05:00
int GetDefaultWeatherInterval ( eWeather a_Weather ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the current game mode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable */
2013-11-13 08:50:47 -05:00
eGameMode GetGameMode ( void ) const { return m_GameMode ; }
2014-01-19 17:49:19 -05:00
/** Returns true if the world is in Creative mode */
2013-11-13 08:50:47 -05:00
bool IsGameModeCreative ( void ) const { return ( m_GameMode = = gmCreative ) ; }
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Returns true if the world is in Survival mode */
2013-11-13 08:50:47 -05:00
bool IsGameModeSurvival ( void ) const { return ( m_GameMode = = gmSurvival ) ; }
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Returns true if the world is in Adventure mode */
2013-11-13 08:50:47 -05:00
bool IsGameModeAdventure ( void ) const { return ( m_GameMode = = gmAdventure ) ; }
2016-02-05 16:45:45 -05:00
2014-09-16 14:05:55 -04:00
/** Returns true if the world is in Spectator mode */
2014-09-17 11:32:37 -04:00
bool IsGameModeSpectator ( void ) const { return ( m_GameMode = = gmSpectator ) ; }
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
bool IsPVPEnabled ( void ) const { return m_bEnabledPVP ; }
bool IsDeepSnowEnabled ( void ) const { return m_IsDeepSnowEnabled ; }
2016-02-05 16:45:45 -05:00
2013-12-04 13:48:42 -05:00
bool ShouldLavaSpawnFire ( void ) const { return m_ShouldLavaSpawnFire ; }
2016-02-05 16:45:45 -05:00
2014-01-27 16:02:19 -05:00
bool VillagersShouldHarvestCrops ( void ) const { return m_VillagersShouldHarvestCrops ; }
2015-05-23 07:56:08 -04:00
virtual eDimension GetDimension ( void ) const override { return m_Dimension ; }
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */
2015-05-23 07:56:08 -04:00
virtual int GetHeight ( int a_BlockX , int a_BlockZ ) override ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// tolua_end
2014-01-19 17:49:19 -05:00
/** Retrieves the world height at the specified coords; returns false if chunk not loaded / generated */
2013-11-13 08:50:47 -05:00
bool TryGetHeight ( int a_BlockX , int a_BlockZ , int & a_Height ) ; // Exported in ManualBindings.cpp
// Broadcast respective packets to all clients of the chunk where the event is taking place
// (Please keep these alpha-sorted)
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
void BroadcastAttachEntity ( const cEntity & a_Entity , const cEntity & a_Vehicle ) ;
2015-05-19 06:50:59 -04:00
void BroadcastBlockAction ( int a_BlockX , int a_BlockY , int a_BlockZ , Byte a_Byte1 , Byte a_Byte2 , BLOCKTYPE a_BlockType , const cClientHandle * a_Exclude = nullptr ) ; // tolua_export
2015-03-21 10:18:17 -04:00
void BroadcastBlockBreakAnimation ( UInt32 a_EntityID , int a_BlockX , int a_BlockY , int a_BlockZ , char a_Stage , const cClientHandle * a_Exclude = nullptr ) ;
2014-10-20 16:55:07 -04:00
void BroadcastBlockEntity ( int a_BlockX , int a_BlockY , int a_BlockZ , const cClientHandle * a_Exclude = nullptr ) ; ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
2014-02-05 18:24:02 -05:00
2014-02-07 13:58:52 -05:00
// tolua_begin
2014-10-20 16:55:07 -04:00
void BroadcastChat ( const AString & a_Message , const cClientHandle * a_Exclude = nullptr , eMessageType a_ChatPrefix = mtCustom ) ;
void BroadcastChatInfo ( const AString & a_Message , const cClientHandle * a_Exclude = nullptr ) { BroadcastChat ( a_Message , a_Exclude , mtInformation ) ; }
void BroadcastChatFailure ( const AString & a_Message , const cClientHandle * a_Exclude = nullptr ) { BroadcastChat ( a_Message , a_Exclude , mtFailure ) ; }
void BroadcastChatSuccess ( const AString & a_Message , const cClientHandle * a_Exclude = nullptr ) { BroadcastChat ( a_Message , a_Exclude , mtSuccess ) ; }
void BroadcastChatWarning ( const AString & a_Message , const cClientHandle * a_Exclude = nullptr ) { BroadcastChat ( a_Message , a_Exclude , mtWarning ) ; }
void BroadcastChatFatal ( const AString & a_Message , const cClientHandle * a_Exclude = nullptr ) { BroadcastChat ( a_Message , a_Exclude , mtFailure ) ; }
void BroadcastChatDeath ( const AString & a_Message , const cClientHandle * a_Exclude = nullptr ) { BroadcastChat ( a_Message , a_Exclude , mtDeath ) ; }
void BroadcastChat ( const cCompositeChat & a_Message , const cClientHandle * a_Exclude = nullptr ) ;
2014-02-05 18:24:02 -05:00
// tolua_end
2016-12-15 14:21:43 -05:00
void BroadcastCollectEntity ( const cEntity & a_Pickup , const cPlayer & a_Player , int a_Count , const cClientHandle * a_Exclude = nullptr ) ;
2014-10-20 16:55:07 -04:00
void BroadcastDestroyEntity ( const cEntity & a_Entity , const cClientHandle * a_Exclude = nullptr ) ;
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
void BroadcastDetachEntity ( const cEntity & a_Entity , const cEntity & a_PreviousVehicle ) ;
2014-10-20 16:55:07 -04:00
void BroadcastEntityEffect ( const cEntity & a_Entity , int a_EffectID , int a_Amplifier , short a_Duration , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastEntityEquipment ( const cEntity & a_Entity , short a_SlotNum , const cItem & a_Item , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastEntityHeadLook ( const cEntity & a_Entity , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastEntityLook ( const cEntity & a_Entity , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastEntityMetadata ( const cEntity & a_Entity , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastEntityRelMove ( const cEntity & a_Entity , char a_RelX , char a_RelY , char a_RelZ , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastEntityRelMoveLook ( const cEntity & a_Entity , char a_RelX , char a_RelY , char a_RelZ , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastEntityStatus ( const cEntity & a_Entity , char a_Status , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastEntityVelocity ( const cEntity & a_Entity , const cClientHandle * a_Exclude = nullptr ) ;
virtual void BroadcastEntityAnimation ( const cEntity & a_Entity , char a_Animation , const cClientHandle * a_Exclude = nullptr ) override ; // tolua_export
void BroadcastPlayerListAddPlayer ( const cPlayer & a_Player , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastPlayerListRemovePlayer ( const cPlayer & a_Player , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastPlayerListUpdateGameMode ( const cPlayer & a_Player , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastPlayerListUpdatePing ( const cPlayer & a_Player , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastPlayerListUpdateDisplayName ( const cPlayer & a_Player , const AString & a_CustomName , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastRemoveEntityEffect ( const cEntity & a_Entity , int a_EffectID , const cClientHandle * a_Exclude = nullptr ) ;
2014-09-18 12:50:17 -04:00
void BroadcastScoreboardObjective ( const AString & a_Name , const AString & a_DisplayName , Byte a_Mode ) ;
void BroadcastScoreUpdate ( const AString & a_Objective , const AString & a_Player , cObjective : : Score a_Score , Byte a_Mode ) ;
void BroadcastDisplayObjective ( const AString & a_Objective , cScoreboard : : eDisplaySlot a_Display ) ;
2015-05-23 07:56:08 -04:00
void BroadcastSoundEffect ( const AString & a_SoundName , double a_X , double a_Y , double a_Z , float a_Volume , float a_Pitch , const cClientHandle * a_Exclude = nullptr ) override ; // tolua_export
2016-07-07 03:55:07 -04:00
virtual void BroadcastSoundParticleEffect ( const EffectID a_EffectID , int a_SrcX , int a_SrcY , int a_SrcZ , int a_Data , const cClientHandle * a_Exclude = nullptr ) override ; // tolua_export
2014-10-20 16:55:07 -04:00
void BroadcastSpawnEntity ( cEntity & a_Entity , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastTeleportEntity ( const cEntity & a_Entity , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastThunderbolt ( int a_BlockX , int a_BlockY , int a_BlockZ , const cClientHandle * a_Exclude = nullptr ) ;
void BroadcastTimeUpdate ( const cClientHandle * a_Exclude = nullptr ) ;
2014-09-18 12:50:17 -04:00
virtual void BroadcastUseBed ( const cEntity & a_Entity , int a_BlockX , int a_BlockY , int a_BlockZ ) override ;
2014-10-20 16:55:07 -04:00
void BroadcastWeather ( eWeather a_Weather , const cClientHandle * a_Exclude = nullptr ) ;
2016-02-05 16:45:45 -05:00
2014-03-16 16:56:14 -04:00
virtual cBroadcastInterface & GetBroadcastManager ( void ) override
2014-01-26 09:20:39 -05:00
{
2014-02-01 08:06:32 -05:00
return * this ;
2014-01-26 09:20:39 -05:00
}
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** If there is a block entity at the specified coords, sends it to the client specified */
2013-11-13 08:50:47 -05:00
void SendBlockEntity ( int a_BlockX , int a_BlockY , int a_BlockZ , cClientHandle & a_Client ) ;
2016-02-05 16:45:45 -05:00
2016-04-18 06:30:23 -04:00
void MarkChunkDirty ( int a_ChunkX , int a_ChunkZ ) ;
2013-11-13 08:50:47 -05:00
void MarkChunkSaving ( int a_ChunkX , int a_ChunkZ ) ;
void MarkChunkSaved ( int a_ChunkX , int a_ChunkZ ) ;
2016-02-05 16:45:45 -05:00
2014-07-24 12:32:05 -04:00
/** Puts the chunk data into a queue to be set into the chunkmap in the tick thread.
If the chunk data doesn ' t contain valid biomes , the biomes are calculated before adding the data into the queue . */
void QueueSetChunkData ( const cSetChunkDataPtr & a_SetChunkData ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
void ChunkLighted (
int a_ChunkX , int a_ChunkZ ,
const cChunkDef : : BlockNibbles & a_BlockLight ,
const cChunkDef : : BlockNibbles & a_SkyLight
) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
bool GetChunkData ( int a_ChunkX , int a_ChunkZ , cChunkDataCallback & a_Callback ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Gets the chunk's blocks, only the block types */
2013-11-13 08:50:47 -05:00
bool GetChunkBlockTypes ( int a_ChunkX , int a_ChunkZ , BLOCKTYPE * a_BlockTypes ) ;
2016-02-05 16:45:45 -05:00
2014-09-05 16:16:48 -04:00
/** Returns true iff the chunk is in the loader / generator queue. */
bool IsChunkQueued ( int a_ChunkX , int a_ChunkZ ) const ;
/** Returns true iff the chunk is present and valid. */
bool IsChunkValid ( int a_ChunkX , int a_ChunkZ ) const ;
2013-11-13 08:50:47 -05:00
bool HasChunkAnyClients ( int a_ChunkX , int a_ChunkZ ) const ;
2016-02-05 16:45:45 -05:00
2015-07-31 10:49:10 -04:00
/** Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading. */
2014-02-10 20:00:07 -05:00
void QueueUnloadUnusedChunks ( void ) ; // tolua_export
2016-02-05 16:45:45 -05:00
2014-10-15 13:01:55 -04:00
void CollectPickupsByPlayer ( cPlayer & a_Player ) ;
2013-11-13 08:50:47 -05:00
2014-06-08 15:58:08 -04:00
/** Adds the player to the world.
Uses a queue to store the player object until the Tick thread processes the addition event .
2016-08-22 13:43:43 -04:00
Also adds the player as an entity in the chunkmap , and the player ' s ClientHandle , if any , for ticking .
If a_OldWorld is provided , a corresponding ENTITY_CHANGED_WORLD event is triggerred after the addition . */
void AddPlayer ( cPlayer * a_Player , cWorld * a_OldWorld = nullptr ) ;
2014-06-08 15:58:08 -04:00
/** Removes the player from the world.
Removes the player from the addition queue , too , if appropriate .
2014-07-29 15:50:30 -04:00
If the player has a ClientHandle , the ClientHandle is removed from all chunks in the world and will not be ticked by this world anymore .
@ param a_RemoveFromChunk determines if the entity should be removed from its chunk as well . Should be false when ticking from cChunk . */
void RemovePlayer ( cPlayer * a_Player , bool a_RemoveFromChunk ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */
2014-03-16 16:56:14 -04:00
virtual bool ForEachPlayer ( cPlayerListCallback & a_Callback ) override ; // >> EXPORTED IN MANUALBINDINGS <<
2014-01-19 17:49:19 -05:00
2014-11-30 05:11:47 -05:00
/** Calls the callback for the player of the given name; returns true if the player was found and the callback called, false if player not found.
Callback return value is ignored . If there are multiple players of the same name , only ( random ) one is processed by the callback . */
2014-01-19 17:49:19 -05:00
bool DoWithPlayer ( const AString & a_PlayerName , cPlayerListCallback & a_Callback ) ; // >> EXPORTED IN MANUALBINDINGS <<
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Finds a player from a partial or complete player name and calls the callback - case-insensitive */
2014-07-17 10:33:09 -04:00
bool FindAndDoWithPlayer ( const AString & a_PlayerNameHint , cPlayerListCallback & a_Callback ) ; // >> EXPORTED IN MANUALBINDINGS <<
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
2014-07-17 10:33:09 -04:00
cPlayer * FindClosestPlayer ( const Vector3d & a_Pos , float a_SightLimit , bool a_CheckLineOfSight = true ) ;
2016-02-05 16:45:45 -05:00
2014-11-05 15:57:38 -05:00
/** Finds the player over his uuid and calls the callback */
bool DoWithPlayerByUUID ( const AString & a_PlayerUUID , cPlayerListCallback & a_Callback ) ; // >> EXPORTED IN MANUALBINDINGS <<
2016-10-12 08:38:45 -04:00
bool DoWithPlayerByUUID ( const AString & a_PlayerUUID , cLambdaPlayerCallback a_Callback ) ; // Lambda version
2014-11-12 15:59:42 -05:00
2013-11-13 08:50:47 -05:00
void SendPlayerList ( cPlayer * a_DestPlayer ) ; // Sends playerlist to the player
2014-06-06 16:31:16 -04:00
/** Adds the entity into its appropriate chunk; takes ownership of the entity ptr.
The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread . */
2013-11-13 08:50:47 -05:00
void AddEntity ( cEntity * a_Entity ) ;
2016-02-05 16:45:45 -05:00
2015-03-21 10:18:17 -04:00
/** Returns true if an entity with the specified UniqueID exists in the world.
Note : Only loaded chunks are considered . */
bool HasEntity ( UInt32 a_UniqueID ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachEntity ( cEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each entity in the specified chunk; returns true if all entities processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachEntityInChunk ( int a_ChunkX , int a_ChunkZ , cEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-09-03 11:00:26 -04:00
/** Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.
Returns true if all entities processed , false if the callback aborted by returning true .
If any chunk in the box is missing , ignores the entities in that chunk silently . */
bool ForEachEntityInBox ( const cBoundingBox & a_Box , cEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2015-03-21 10:18:17 -04:00
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param.
Returns true if entity found and callback returned false . */
bool DoWithEntityByID ( UInt32 a_UniqueID , cEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2016-10-12 08:38:45 -04:00
bool DoWithEntityByID ( UInt32 a_UniqueID , cLambdaEntityCallback a_Callback ) ; // Lambda version
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Compares clients of two chunks, calls the callback accordingly */
2013-11-13 08:50:47 -05:00
void CompareChunkClients ( int a_ChunkX1 , int a_ChunkZ1 , int a_ChunkX2 , int a_ChunkZ2 , cClientDiffCallback & a_Callback ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Adds client to a chunk, if not already present; returns true if added, false if present */
2013-11-13 08:50:47 -05:00
bool AddChunkClient ( int a_ChunkX , int a_ChunkZ , cClientHandle * a_Client ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Removes client from the chunk specified */
2013-11-13 08:50:47 -05:00
void RemoveChunkClient ( int a_ChunkX , int a_ChunkZ , cClientHandle * a_Client ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Removes the client from all chunks it is present in */
2013-11-13 08:50:47 -05:00
void RemoveClientFromChunks ( cClientHandle * a_Client ) ;
2016-02-05 16:45:45 -05:00
2014-02-18 07:06:18 -05:00
/** Sends the chunk to the client specified, if the client doesn't have the chunk yet.
If chunk not valid , the request is postponed ( ChunkSender will send that chunk when it becomes valid + lighted ) . */
2014-10-06 15:27:53 -04:00
void SendChunkTo ( int a_ChunkX , int a_ChunkZ , cChunkSender : : eChunkPriority a_Priority , cClientHandle * a_Client ) ;
2016-02-05 16:45:45 -05:00
2014-02-18 07:06:18 -05:00
/** Sends the chunk to the client specified, even if the client already has the chunk.
If the chunk ' s not valid , the request is postponed ( ChunkSender will send that chunk when it becomes valid + lighted ) . */
2014-10-06 15:27:53 -04:00
void ForceSendChunkTo ( int a_ChunkX , int a_ChunkZ , cChunkSender : : eChunkPriority a_Priority , cClientHandle * a_Client ) ;
2014-10-11 22:39:55 -04:00
2014-01-19 17:49:19 -05:00
/** Removes client from ChunkSender's queue of chunks to be sent */
2013-11-13 08:50:47 -05:00
void RemoveClientFromChunkSender ( cClientHandle * a_Client ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Touches the chunk, causing it to be loaded or generated */
2014-08-28 05:36:35 -04:00
void TouchChunk ( int a_ChunkX , int a_ChunkZ ) ;
2014-12-10 16:35:16 -05:00
/** Queues the chunk for preparing - making sure that it's generated and lit.
The specified chunk is queued to be loaded or generated , and lit if needed .
The specified callback is called after the chunk has been prepared . If there ' s no preparation to do , only the callback is called .
It is legal to call with no callback . */
2015-05-30 06:11:17 -04:00
void PrepareChunk ( int a_ChunkX , int a_ChunkZ , std : : unique_ptr < cChunkCoordCallback > a_CallAfter = { } ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Marks the chunk as failed-to-load: */
2014-08-28 05:36:35 -04:00
void ChunkLoadFailed ( int a_ChunkX , int a_ChunkZ ) ;
2016-02-05 16:45:45 -05:00
2014-11-15 09:16:52 -05:00
/** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be nullptr. Returns true if sign text changed. */
2014-10-20 16:55:07 -04:00
bool SetSignLines ( int a_BlockX , int a_BlockY , int a_BlockZ , const AString & a_Line1 , const AString & a_Line2 , const AString & a_Line3 , const AString & a_Line4 , cPlayer * a_Player = nullptr ) ; // Exported in ManualBindings.cpp
2013-11-13 08:50:47 -05:00
2014-01-23 07:57:04 -05:00
/** Sets the command block command. Returns true if command changed. */
2014-07-17 10:33:09 -04:00
bool SetCommandBlockCommand ( int a_BlockX , int a_BlockY , int a_BlockZ , const AString & a_Command ) ; // tolua_export
2014-01-23 07:57:04 -05:00
2014-03-02 10:16:22 -05:00
/** Is the trapdoor open? Returns false if there is no trapdoor at the specified coords. */
2014-03-02 10:01:37 -05:00
bool IsTrapdoorOpen ( int a_BlockX , int a_BlockY , int a_BlockZ ) ; // tolua_export
2014-04-27 12:35:41 -04:00
/** Set the state of a trapdoor. Returns true if the trapdoor was updated, false if there was no trapdoor at those coords. */
2014-03-02 10:01:37 -05:00
bool SetTrapdoorOpen ( int a_BlockX , int a_BlockY , int a_BlockZ , bool a_Open ) ; // tolua_export
2014-01-19 17:49:19 -05:00
/** Regenerate the given chunk: */
2014-07-17 10:33:09 -04:00
void RegenerateChunk ( int a_ChunkX , int a_ChunkZ ) ; // tolua_export
2016-02-05 16:45:45 -05:00
2014-08-29 14:19:45 -04:00
/** Generates the given chunk */
2014-07-17 10:33:09 -04:00
void GenerateChunk ( int a_ChunkX , int a_ChunkZ ) ; // tolua_export
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */
2015-05-30 06:11:17 -04:00
void QueueLightChunk ( int a_ChunkX , int a_ChunkZ , std : : unique_ptr < cChunkCoordCallback > a_Callback = { } ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
bool IsChunkLighted ( int a_ChunkX , int a_ChunkZ ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each chunk in the coords specified (all cords are inclusive). Returns true if all chunks have been processed successfully */
2014-03-16 16:56:14 -04:00
virtual bool ForEachChunkInRect ( int a_MinChunkX , int a_MaxChunkX , int a_MinChunkZ , int a_MaxChunkZ , cChunkDataCallback & a_Callback ) override ;
2013-11-13 08:50:47 -05:00
2015-09-24 10:43:31 -04:00
/** Calls the callback for each loaded chunk. Returns true if all chunks have been processed successfully */
bool ForEachLoadedChunk ( std : : function < bool ( int , int ) > a_Callback ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// tolua_begin
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
/** Sets the block at the specified coords to the specified value.
Full processing , incl . updating neighbors , is performed .
*/
2014-05-25 08:46:34 -04:00
void SetBlock ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta , bool a_SendToClients = true ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
/** Sets the block at the specified coords to the specified value.
The replacement doesn ' t trigger block updates .
The replaced blocks aren ' t checked for block entities ( block entity is leaked if it exists at this block )
*/
2014-01-26 09:20:39 -05:00
void FastSetBlock ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta )
{
m_ChunkMap - > FastSetBlock ( a_BlockX , a_BlockY , a_BlockZ , a_BlockType , a_BlockMeta ) ;
}
2016-02-05 16:45:45 -05:00
2014-01-26 09:20:39 -05:00
BLOCKTYPE GetBlock ( int a_BlockX , int a_BlockY , int a_BlockZ )
{
return m_ChunkMap - > GetBlock ( a_BlockX , a_BlockY , a_BlockZ ) ;
}
2016-02-05 16:45:45 -05:00
2014-01-26 09:20:39 -05:00
NIBBLETYPE GetBlockMeta ( int a_BlockX , int a_BlockY , int a_BlockZ )
{
return m_ChunkMap - > GetBlockMeta ( a_BlockX , a_BlockY , a_BlockZ ) ;
}
2016-04-06 09:16:16 -04:00
2016-07-06 06:39:56 -04:00
void SetBlockMeta ( int a_BlockX , int a_BlockY , int a_BlockZ , NIBBLETYPE a_MetaData , bool a_ShouldMarkDirty = true , bool a_ShouldInformClients = true ) ;
2013-11-13 08:50:47 -05:00
NIBBLETYPE GetBlockSkyLight ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
NIBBLETYPE GetBlockBlockLight ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// tolua_end
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
bool GetBlockTypeMeta ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE & a_BlockType , NIBBLETYPE & a_BlockMeta ) ; // TODO: Exported in ManualBindings.cpp
bool GetBlockInfo ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE & a_BlockType , NIBBLETYPE & a_Meta , NIBBLETYPE & a_SkyLight , NIBBLETYPE & a_BlockLight ) ; // TODO: Exported in ManualBindings.cpp
// TODO: NIBBLETYPE GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ);
// tolua_begin
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// Vector3i variants:
2014-07-21 09:19:48 -04:00
void FastSetBlock ( const Vector3i & a_Pos , BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta ) { FastSetBlock ( a_Pos . x , a_Pos . y , a_Pos . z , a_BlockType , a_BlockMeta ) ; }
BLOCKTYPE GetBlock ( const Vector3i & a_Pos ) { return GetBlock ( a_Pos . x , a_Pos . y , a_Pos . z ) ; }
NIBBLETYPE GetBlockMeta ( const Vector3i & a_Pos ) { return GetBlockMeta ( a_Pos . x , a_Pos . y , a_Pos . z ) ; }
void SetBlockMeta ( const Vector3i & a_Pos , NIBBLETYPE a_MetaData ) { SetBlockMeta ( a_Pos . x , a_Pos . y , a_Pos . z , a_MetaData ) ; }
2015-07-16 00:47:51 -04:00
NIBBLETYPE GetBlockBlockLight ( const Vector3i & a_Pos ) { return GetBlockBlockLight ( a_Pos . x , a_Pos . y , a_Pos . z ) ; }
2013-11-13 08:50:47 -05:00
// tolua_end
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
/** Writes the block area into the specified coords.
Returns true if all chunks have been processed .
Prefer cBlockArea : : Write ( ) instead , this is the internal implementation ; cBlockArea does error checking , too .
a_DataTypes is a bitmask of cBlockArea : : baXXX constants ORed together .
*/
2014-02-18 02:25:29 -05:00
virtual bool WriteBlockArea ( cBlockArea & a_Area , int a_MinBlockX , int a_MinBlockY , int a_MinBlockZ , int a_DataTypes ) override ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// tolua_begin
2014-01-19 17:49:19 -05:00
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
2014-03-22 11:43:54 -04:00
virtual void SpawnItemPickups ( const cItems & a_Pickups , double a_BlockX , double a_BlockY , double a_BlockZ , double a_FlyAwaySpeed = 1.0 , bool IsPlayerCreated = false ) override ;
2016-02-05 16:45:45 -05:00
2015-03-21 10:18:17 -04:00
/** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified. */
2014-03-22 11:43:54 -04:00
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 IsPlayerCreated = false ) override ;
2016-02-05 16:45:45 -05:00
2015-03-21 10:18:17 -04:00
/** Spawns an falling block entity at the given position.
Returns the UniqueID of the spawned falling block , or cEntity : : INVALID_ID on failure . */
UInt32 SpawnFallingBlock ( int a_X , int a_Y , int a_Z , BLOCKTYPE BlockType , NIBBLETYPE BlockMeta ) ;
2013-12-07 08:26:52 -05:00
2015-03-21 10:18:17 -04:00
/** Spawns an minecart at the given coordinates.
Returns the UniqueID of the spawned minecart , or cEntity : : INVALID_ID on failure . */
UInt32 SpawnMinecart ( double a_X , double a_Y , double a_Z , int a_MinecartType , const cItem & a_Content = cItem ( ) , int a_BlockHeight = 1 ) ;
2014-01-12 08:33:32 -05:00
2016-05-29 04:30:47 -04:00
/** Spawns a boat at the given coordinates.
Returns the UniqueID of the spawned boat , or cEntity : : INVALID_ID on failure . */
UInt32 SpawnBoat ( double a_X , double a_Y , double a_Z ) ;
2015-03-21 10:18:17 -04:00
/** Spawns an experience orb at the given location with the given reward.
Returns the UniqueID of the spawned experience orb , or cEntity : : INVALID_ID on failure . */
virtual UInt32 SpawnExperienceOrb ( double a_X , double a_Y , double a_Z , int a_Reward ) override ;
2013-11-25 15:03:26 -05:00
2015-03-21 10:18:17 -04:00
/** Spawns a new primed TNT entity at the specified block coords and specified fuse duration.
Initial velocity is given based on the relative coefficient provided .
Returns the UniqueID of the created entity , or cEntity : : INVALID_ID on failure . */
UInt32 SpawnPrimedTNT ( double a_X , double a_Y , double a_Z , int a_FuseTimeInSec = 80 , double a_InitialVelocityCoeff = 1 ) ;
2013-11-13 08:50:47 -05:00
// tolua_end
2014-12-24 01:20:17 -05:00
/** Performs the specified single-block set operations simultaneously, as if SetBlock() was called for each item.
Is more efficient than calling SetBlock ( ) multiple times .
If the chunk for any of the blocks is not loaded , the set operation is ignored silently . */
void SetBlocks ( const sSetBlockVector & a_Blocks ) ;
2014-01-19 17:49:19 -05:00
/** Replaces world blocks with a_Blocks, if they are of type a_FilterBlockType */
2013-11-13 08:50:47 -05:00
void ReplaceBlocks ( const sSetBlockVector & a_Blocks , BLOCKTYPE a_FilterBlockType ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Retrieves block types of the specified blocks. If a chunk is not loaded, doesn't modify the block. Returns true if all blocks were read. */
2013-11-13 08:50:47 -05:00
bool GetBlocks ( sSetBlockVector & a_Blocks , bool a_ContinueOnFailure ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// tolua_begin
bool DigBlock ( int a_X , int a_Y , int a_Z ) ;
2014-03-22 11:43:54 -04:00
virtual void SendBlockTo ( int a_X , int a_Y , int a_Z , cPlayer * a_Player ) override ;
2013-11-13 08:50:47 -05:00
2016-09-12 17:21:15 -04:00
/** Set default spawn at the given coordinates.
Returns false if the new spawn couldn ' t be stored in the INI file . */
2016-08-15 04:41:32 -04:00
bool SetSpawn ( double a_X , double a_Y , double a_Z ) ;
2013-11-13 08:50:47 -05:00
double GetSpawnX ( void ) const { return m_SpawnX ; }
double GetSpawnY ( void ) const { return m_SpawnY ; }
double GetSpawnZ ( void ) const { return m_SpawnZ ; }
2014-01-19 17:49:19 -05:00
/** Wakes up the simulators for the specified block */
2014-07-02 13:46:00 -04:00
virtual void WakeUpSimulators ( int a_BlockX , int a_BlockY , int a_BlockZ ) override ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Wakes up the simulators for the specified area of blocks */
2013-11-13 08:50:47 -05:00
void WakeUpSimulatorsInArea ( int a_MinBlockX , int a_MaxBlockX , int a_MinBlockY , int a_MaxBlockY , int a_MinBlockZ , int a_MaxBlockZ ) ;
// tolua_end
2014-10-10 10:33:19 -04:00
inline cSimulatorManager * GetSimulatorManager ( void ) { return m_SimulatorManager . get ( ) ; }
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
inline cFluidSimulator * GetWaterSimulator ( void ) { return m_WaterSimulator ; }
inline cFluidSimulator * GetLavaSimulator ( void ) { return m_LavaSimulator ; }
2014-10-25 16:54:00 -04:00
inline cRedstoneSimulator * GetRedstoneSimulator ( void ) { return m_RedstoneSimulator ; }
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each block entity in the specified chunk; returns true if all block entities processed, false if the callback aborted by returning true */
2013-11-20 15:53:29 -05:00
bool ForEachBlockEntityInChunk ( int a_ChunkX , int a_ChunkZ , cBlockEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2016-02-05 16:45:45 -05:00
2015-09-24 04:48:33 -04:00
/** Calls the callback for each brewingstand in the specified chunk; returns true if all brewingstands processed, false if the callback aborted by returning true */
bool ForEachBrewingstandInChunk ( int a_ChunkX , int a_ChunkZ , cBrewingstandCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for each chest in the specified chunk; returns true if all chests processed, false if the callback aborted by returning true */
2013-11-20 15:53:29 -05:00
bool ForEachChestInChunk ( int a_ChunkX , int a_ChunkZ , cChestCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each dispenser in the specified chunk; returns true if all dispensers processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachDispenserInChunk ( int a_ChunkX , int a_ChunkZ , cDispenserCallback & a_Callback ) ;
2014-01-19 17:49:19 -05:00
/** Calls the callback for each dropper in the specified chunk; returns true if all droppers processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachDropperInChunk ( int a_ChunkX , int a_ChunkZ , cDropperCallback & a_Callback ) ;
2014-01-19 17:49:19 -05:00
/** Calls the callback for each dropspenser in the specified chunk; returns true if all dropspensers processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachDropSpenserInChunk ( int a_ChunkX , int a_ChunkZ , cDropSpenserCallback & a_Callback ) ;
2014-01-19 17:49:19 -05:00
/** Calls the callback for each furnace in the specified chunk; returns true if all furnaces processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachFurnaceInChunk ( int a_ChunkX , int a_ChunkZ , cFurnaceCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2016-02-05 16:45:45 -05:00
2015-12-16 09:04:47 -05:00
/** Does an explosion with the specified strength at the specified coordinates.
Executes the HOOK_EXPLODING and HOOK_EXPLODED hooks as part of the processing .
a_SourceData exact type depends on the a_Source , see the declaration of the esXXX constants in BlockID . h for details .
Exported to Lua manually in ManualBindings_World . cpp in order to support the variable a_SourceData param . */
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 ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
2014-06-16 19:15:38 -04:00
virtual bool DoWithBlockEntityAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cBlockEntityCallback & a_Callback ) override ; // Exported in ManualBindings.cpp
2013-11-20 15:53:29 -05:00
2014-07-30 16:19:51 -04:00
/** Calls the callback for the beacon at the specified coords; returns false if there's no beacon at those coords, true if found */
bool DoWithBeaconAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cBeaconCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2015-09-24 04:48:33 -04:00
/** Calls the callback for the brewingstand at the specified coords; returns false if there's no brewingstand at those coords, true if found */
bool DoWithBrewingstandAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cBrewingstandCallback & a_Callback ) ; // Lua-acessible
2014-01-19 17:49:19 -05:00
/** Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found */
2013-11-20 15:53:29 -05:00
bool DoWithChestAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cChestCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords or callback returns true, returns true if found */
2013-11-13 08:50:47 -05:00
bool DoWithDispenserAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cDispenserCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for the dropper at the specified coords; returns false if there's no dropper at those coords or callback returns true, returns true if found */
2013-11-13 08:50:47 -05:00
bool DoWithDropperAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cDropperCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for the dropspenser at the specified coords; returns false if there's no dropspenser at those coords or callback returns true, returns true if found */
2013-11-13 08:50:47 -05:00
bool DoWithDropSpenserAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cDropSpenserCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords or callback returns true, returns true if found */
2013-11-13 08:50:47 -05:00
bool DoWithFurnaceAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cFurnaceCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2013-12-14 11:52:22 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the noteblock at the specified coords; returns false if there's no noteblock at those coords or callback returns true, returns true if found */
2013-12-14 11:52:22 -05:00
bool DoWithNoteBlockAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cNoteBlockCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-18 08:16:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the command block at the specified coords; returns false if there's no command block at those coords or callback returns true, returns true if found */
2014-01-18 09:59:33 -05:00
bool DoWithCommandBlockAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cCommandBlockCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-03-06 19:30:34 -05:00
2014-02-19 08:45:09 -05:00
/** Calls the callback for the mob head block at the specified coords; returns false if there's no mob head block at those coords or callback returns true, returns true if found */
2014-03-07 05:44:16 -05:00
bool DoWithMobHeadAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cMobHeadCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-03-06 19:30:34 -05:00
/** Calls the callback for the flower pot at the specified coords; returns false if there's no flower pot at those coords or callback returns true, returns true if found */
bool DoWithFlowerPotAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cFlowerPotCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found */
2013-11-13 08:50:47 -05:00
bool GetSignLines ( int a_BlockX , int a_BlockY , int a_BlockZ , AString & a_Line1 , AString & a_Line2 , AString & a_Line3 , AString & a_Line4 ) ; // Exported in ManualBindings.cpp
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** a_Player is using block entity at [x, y, z], handle that: */
2013-11-13 08:50:47 -05:00
void UseBlockEntity ( cPlayer * a_Player , int a_BlockX , int a_BlockY , int a_BlockZ ) { m_ChunkMap - > UseBlockEntity ( a_Player , a_BlockX , a_BlockY , a_BlockZ ) ; } // tolua_export
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */
2013-11-13 08:50:47 -05:00
bool DoWithChunk ( int a_ChunkX , int a_ChunkZ , cChunkCallback & a_Callback ) ;
2015-06-10 10:16:05 -04:00
bool DoWithChunk ( int a_ChunkX , int a_ChunkZ , std : : function < bool ( cChunk & ) > a_Callback ) ;
2013-11-13 08:50:47 -05:00
2015-07-31 10:49:10 -04:00
/** Calls the callback for the chunk at the block position specified, with ChunkMapCS locked.
Returns false if the chunk isn ' t loaded , otherwise returns the same value as the callback */
2015-03-21 13:17:26 -04:00
bool DoWithChunkAt ( Vector3i a_BlockPos , std : : function < bool ( cChunk & ) > a_Callback ) ;
2013-11-13 08:50:47 -05:00
void GrowTreeImage ( const sSetBlockVector & a_Blocks ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// tolua_begin
2014-01-19 17:49:19 -05:00
/** Grows a tree at the specified coords, either from a sapling there, or based on the biome */
2013-11-13 08:50:47 -05:00
void GrowTree ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Grows a tree at the specified coords, based on the sapling meta provided */
2013-11-13 08:50:47 -05:00
void GrowTreeFromSapling ( int a_BlockX , int a_BlockY , int a_BlockZ , NIBBLETYPE a_SaplingMeta ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Grows a tree at the specified coords, based on the biome in the place */
2013-11-13 08:50:47 -05:00
void GrowTreeByBiome ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Grows the plant at the specified block to its ripe stage (bonemeal used); returns false if the block is not growable. If a_IsBonemeal is true, block is not grown if not allowed in world.ini */
2013-11-13 08:50:47 -05:00
bool GrowRipePlant ( int a_BlockX , int a_BlockY , int a_BlockZ , bool a_IsByBonemeal = false ) ;
2016-02-05 16:45:45 -05:00
2016-05-29 04:30:47 -04:00
/** Grows a cactus present at the block specified by the amount of blocks specified, up to the max height specified in the config; returns the amount of blocks the cactus grew inside this call */
int GrowCactus ( int a_BlockX , int a_BlockY , int a_BlockZ , int a_NumBlocksToGrow ) ;
2013-11-13 08:50:47 -05:00
2016-05-29 04:30:47 -04:00
/** Grows a melon or a pumpkin next to the block specified (assumed to be the stem); returns true if the pumpkin or melon sucessfully grew. */
bool GrowMelonPumpkin ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE a_BlockType ) ;
2013-11-13 08:50:47 -05:00
2016-05-29 04:30:47 -04:00
/** Grows a sugarcane present at the block specified by the amount of blocks specified, up to the max height specified in the config; returns the amount of blocks the sugarcane grew inside this call */
int GrowSugarcane ( int a_BlockX , int a_BlockY , int a_BlockZ , int a_NumBlocksToGrow ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */
2014-02-03 15:26:17 -05:00
EMCSBiome GetBiomeAt ( int a_BlockX , int a_BlockZ ) ;
2016-02-05 16:45:45 -05:00
2014-02-18 07:06:18 -05:00
/** Sets the biome at the specified coords. Returns true if successful, false if not (chunk not loaded).
Doesn ' t resend the chunk to clients , use ForceSendChunkTo ( ) for that . */
bool SetBiomeAt ( int a_BlockX , int a_BlockZ , EMCSBiome a_Biome ) ;
2016-02-05 16:45:45 -05:00
2014-02-18 07:06:18 -05:00
/** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded).
( Re ) sends the chunks to their relevant clients if successful . */
bool SetAreaBiome ( int a_MinX , int a_MaxX , int a_MinZ , int a_MaxZ , EMCSBiome a_Biome ) ;
2016-02-05 16:45:45 -05:00
2014-02-18 07:06:18 -05:00
/** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded).
2014-02-18 07:44:40 -05:00
( Re ) sends the chunks to their relevant clients if successful .
The cuboid needn ' t be sorted . */
2014-02-18 07:06:18 -05:00
bool SetAreaBiome ( const cCuboid & a_Area , EMCSBiome a_Biome ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the name of the world */
2013-11-13 08:50:47 -05:00
const AString & GetName ( void ) const { return m_WorldName ; }
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the name of the world.ini file used by this world */
2013-11-13 08:50:47 -05:00
const AString & GetIniFileName ( void ) const { return m_IniFileName ; }
2014-01-19 07:20:57 -05:00
2014-02-23 08:03:40 -05:00
/** Returns the associated scoreboard instance. */
2014-01-21 08:58:17 -05:00
cScoreboard & GetScoreBoard ( void ) { return m_Scoreboard ; }
2014-01-23 07:57:04 -05:00
2014-02-23 08:03:40 -05:00
/** Returns the associated map manager instance. */
cMapManager & GetMapManager ( void ) { return m_MapManager ; }
2014-01-23 07:57:04 -05:00
bool AreCommandBlocksEnabled ( void ) const { return m_bCommandBlocksEnabled ; }
void SetCommandBlocksEnabled ( bool a_Flag ) { m_bCommandBlocksEnabled = a_Flag ; }
2014-02-07 13:58:52 -05:00
2014-03-19 19:06:39 -04:00
eShrapnelLevel GetTNTShrapnelLevel ( void ) const { return m_TNTShrapnelLevel ; }
void SetTNTShrapnelLevel ( eShrapnelLevel a_Flag ) { m_TNTShrapnelLevel = a_Flag ; }
2014-03-10 14:35:02 -04:00
2014-10-30 16:24:10 -04:00
int GetMaxViewDistance ( void ) const { return m_MaxViewDistance ; }
2016-11-18 14:00:04 -05:00
void SetMaxViewDistance ( int a_MaxViewDistance ) ;
2014-10-30 16:24:10 -04:00
2014-02-07 13:58:52 -05:00
bool ShouldUseChatPrefixes ( void ) const { return m_bUseChatPrefixes ; }
void SetShouldUseChatPrefixes ( bool a_Flag ) { m_bUseChatPrefixes = a_Flag ; }
2014-06-04 15:00:55 -04:00
2014-07-26 18:39:39 -04:00
bool ShouldBroadcastDeathMessages ( void ) const { return m_BroadcastDeathMessages ; }
bool ShouldBroadcastAchievementMessages ( void ) const { return m_BroadcastAchievementMessages ; }
2014-07-30 04:06:18 -04:00
2015-03-21 10:20:31 -04:00
AString GetLinkedNetherWorldName ( void ) const { return m_LinkedNetherWorldName ; }
void SetLinkedNetherWorldName ( const AString & a_Name ) { m_LinkedNetherWorldName = a_Name ; }
2014-06-04 15:00:55 -04:00
2015-03-21 10:20:31 -04:00
AString GetLinkedEndWorldName ( void ) const { return m_LinkedEndWorldName ; }
void SetLinkedEndWorldName ( const AString & a_Name ) { m_LinkedEndWorldName = a_Name ; }
2014-06-10 15:43:27 -04:00
2015-03-21 10:20:31 -04:00
AString GetLinkedOverworldName ( void ) const { return m_LinkedOverworldName ; }
void SetLinkedOverworldName ( const AString & a_Name ) { m_LinkedOverworldName = a_Name ; }
2016-02-05 16:45:45 -05:00
2015-06-13 08:57:51 -04:00
/** Returns or sets the minumim or maximum netherportal width */
virtual int GetMinNetherPortalWidth ( void ) const override { return m_MinNetherPortalWidth ; }
virtual int GetMaxNetherPortalWidth ( void ) const override { return m_MaxNetherPortalWidth ; }
virtual void SetMinNetherPortalWidth ( int a_NewMinWidth ) override { m_MinNetherPortalWidth = a_NewMinWidth ; }
virtual void SetMaxNetherPortalWidth ( int a_NewMaxWidth ) override { m_MaxNetherPortalWidth = a_NewMaxWidth ; }
/** Returns or sets the minumim or maximum netherportal height */
virtual int GetMinNetherPortalHeight ( void ) const override { return m_MinNetherPortalHeight ; }
virtual int GetMaxNetherPortalHeight ( void ) const override { return m_MaxNetherPortalHeight ; }
virtual void SetMinNetherPortalHeight ( int a_NewMinHeight ) override { m_MinNetherPortalHeight = a_NewMinHeight ; }
virtual void SetMaxNetherPortalHeight ( int a_NewMaxHeight ) override { m_MaxNetherPortalHeight = a_NewMaxHeight ; }
2013-11-13 08:50:47 -05:00
// tolua_end
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */
2013-11-13 08:50:47 -05:00
void SaveAllChunks ( void ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Queues a task to save all chunks onto the tick thread. The prefferred way of saving chunks from external sources */
2013-11-13 08:50:47 -05:00
void QueueSaveAllChunks ( void ) ; // tolua_export
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Queues a task onto the tick thread. The task object will be deleted once the task is finished */
2015-09-25 13:56:49 -04:00
void QueueTask ( std : : function < void ( cWorld & ) > a_Task ) ; // Exported in ManualBindings.cpp
2016-02-05 16:45:45 -05:00
2015-06-22 22:00:15 -04:00
/** Queues a lambda task onto the tick thread, with the specified delay. */
2015-09-25 13:56:49 -04:00
void ScheduleTask ( int a_DelayTicks , std : : function < void ( cWorld & ) > a_Task ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the number of chunks loaded */
2016-09-03 11:38:29 -04:00
size_t GetNumChunks ( ) const ; // tolua_export
/** Returns the number of unused dirty chunks. That's the number of chunks that we can save and then unload. */
size_t GetNumUnusedDirtyChunks ( void ) const ; // tolua_export
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the number of chunks loaded and dirty, and in the lighting queue */
2013-11-13 08:50:47 -05:00
void GetChunkStats ( int & a_NumValid , int & a_NumDirty , int & a_NumInLightingQueue ) ;
// Various queues length queries (cannot be const, they lock their CS):
2014-07-22 18:36:13 -04:00
inline int GetGeneratorQueueLength ( void ) { return m_Generator . GetQueueLength ( ) ; } // tolua_export
2014-03-30 14:02:30 -04:00
inline size_t GetLightingQueueLength ( void ) { return m_Lighting . GetQueueLength ( ) ; } // tolua_export
inline size_t GetStorageLoadQueueLength ( void ) { return m_Storage . GetLoadQueueLength ( ) ; } // tolua_export
inline size_t GetStorageSaveQueueLength ( void ) { return m_Storage . GetSaveQueueLength ( ) ; } // tolua_export
2013-11-13 08:50:47 -05:00
2014-11-25 18:03:33 -05:00
cLightingThread & GetLightingThread ( void ) { return m_Lighting ; }
2013-11-13 08:50:47 -05:00
void InitializeSpawn ( void ) ;
2016-02-05 16:45:45 -05:00
2017-01-17 16:38:04 -05:00
/** Starts threads that belong to this world.
a_DeadlockDetect is used for tracking this world ' s age , detecting a possible deadlock . */
void Start ( cDeadlockDetect & a_DeadlockDetect ) ;
2016-02-05 16:45:45 -05:00
2017-01-17 16:38:04 -05:00
/** Stops threads that belong to this world (part of deinit).
a_DeadlockDetect is used for tracking this world ' s age , detecting a possible deadlock . */
void Stop ( cDeadlockDetect & a_DeadlockDetect ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Processes the blocks queued for ticking with a delay (m_BlockTickQueue[]) */
2013-11-13 08:50:47 -05:00
void TickQueuedBlocks ( void ) ;
struct BlockTickQueueItem
{
int X ;
int Y ;
int Z ;
int TicksToWait ;
} ;
2014-01-19 17:49:19 -05:00
/** Queues the block to be ticked after the specified number of game ticks */
2013-11-13 08:50:47 -05:00
void QueueBlockForTick ( int a_BlockX , int a_BlockY , int a_BlockZ , int a_TicksToWait ) ; // tolua_export
// tolua_begin
2014-01-19 17:49:19 -05:00
/** Casts a thunderbolt at the specified coords */
2013-11-13 08:50:47 -05:00
void CastThunderbolt ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */
2014-07-22 18:36:13 -04:00
void SetWeather ( eWeather a_NewWeather ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Forces a weather change in the next game tick */
2014-07-22 18:36:13 -04:00
void ChangeWeather ( void ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */
2014-07-22 18:36:13 -04:00
eWeather GetWeather ( void ) const { return m_Weather ; }
2016-02-05 16:45:45 -05:00
2014-06-11 08:01:52 -04:00
/** Returns true if the current weather is sun */
2013-11-13 08:50:47 -05:00
bool IsWeatherSunny ( void ) const { return ( m_Weather = = wSunny ) ; }
2016-02-05 16:45:45 -05:00
2014-06-11 08:37:04 -04:00
/** Returns true if it is sunny at the specified location. This takes into account biomes. */
2014-06-11 11:23:53 -04:00
bool IsWeatherSunnyAt ( int a_BlockX , int a_BlockZ )
2014-06-11 08:01:52 -04:00
{
2014-06-11 08:37:04 -04:00
return ( IsWeatherSunny ( ) | | IsBiomeNoDownfall ( GetBiomeAt ( a_BlockX , a_BlockZ ) ) ) ;
2014-06-11 05:33:16 -04:00
}
2016-02-05 16:45:45 -05:00
2014-06-11 08:01:52 -04:00
/** Returns true if the current weather is rain */
bool IsWeatherRain ( void ) const { return ( m_Weather = = wRain ) ; }
2016-02-05 16:45:45 -05:00
2014-06-11 08:37:04 -04:00
/** Returns true if it is raining at the specified location. This takes into account biomes. */
2014-07-22 18:36:13 -04:00
bool IsWeatherRainAt ( int a_BlockX , int a_BlockZ )
2014-06-11 08:01:52 -04:00
{
2014-06-11 08:40:34 -04:00
return ( IsWeatherRain ( ) & & ! IsBiomeNoDownfall ( GetBiomeAt ( a_BlockX , a_BlockZ ) ) ) ;
2014-06-11 05:33:16 -04:00
}
2016-02-05 16:45:45 -05:00
2014-06-11 08:01:52 -04:00
/** Returns true if the current weather is stormy */
2013-11-13 08:50:47 -05:00
bool IsWeatherStorm ( void ) const { return ( m_Weather = = wStorm ) ; }
2014-06-14 04:57:07 -04:00
2014-06-11 08:37:04 -04:00
/** Returns true if the weather is stormy at the specified location. This takes into account biomes. */
2014-06-11 11:23:53 -04:00
bool IsWeatherStormAt ( int a_BlockX , int a_BlockZ )
2014-06-11 08:01:52 -04:00
{
2014-06-11 08:40:34 -04:00
return ( IsWeatherStorm ( ) & & ! IsBiomeNoDownfall ( GetBiomeAt ( a_BlockX , a_BlockZ ) ) ) ;
2014-06-11 05:33:16 -04:00
}
2016-02-05 16:45:45 -05:00
2014-06-11 08:01:52 -04:00
/** Returns true if the current weather has any precipitation - rain, storm or snow */
2014-06-14 05:14:04 -04:00
bool IsWeatherWet ( void ) const { return ! IsWeatherSunny ( ) ; }
2016-02-05 16:45:45 -05:00
2014-06-11 08:37:04 -04:00
/** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */
2015-05-23 07:56:08 -04:00
virtual bool IsWeatherWetAt ( int a_BlockX , int a_BlockZ ) override
2014-06-11 08:01:52 -04:00
{
2014-06-11 08:40:34 -04:00
return ( IsWeatherWet ( ) & & ! IsBiomeNoDownfall ( GetBiomeAt ( a_BlockX , a_BlockZ ) ) ) ;
2014-06-11 05:33:16 -04:00
}
2014-05-29 11:58:40 -04:00
2016-01-08 13:43:23 -05:00
/** Returns the seed of the world. */
int GetSeed ( void ) { return m_Generator . GetSeed ( ) ; }
2013-11-13 08:50:47 -05:00
// tolua_end
cChunkGenerator & GetGenerator ( void ) { return m_Generator ; }
cWorldStorage & GetStorage ( void ) { return m_Storage ; }
2014-10-10 10:33:19 -04:00
cChunkMap * GetChunkMap ( void ) { return m_ChunkMap . get ( ) ; }
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call */
2013-11-13 08:50:47 -05:00
void SetNextBlockTick ( int a_BlockX , int a_BlockY , int a_BlockZ ) ; // tolua_export
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
int GetMaxSugarcaneHeight ( void ) const { return m_MaxSugarcaneHeight ; } // tolua_export
int GetMaxCactusHeight ( void ) const { return m_MaxCactusHeight ; } // tolua_export
bool IsBlockDirectlyWatered ( int a_BlockX , int a_BlockY , int a_BlockZ ) ; // tolua_export
2016-02-05 16:45:45 -05:00
2015-03-21 10:18:17 -04:00
/** Spawns a mob of the specified type. Returns the mob's UniqueID if recognized and spawned, cEntity::INVALID_ID otherwise */
2015-07-16 09:06:54 -04:00
virtual UInt32 SpawnMob ( double a_PosX , double a_PosY , double a_PosZ , eMonsterType a_MonsterType , bool a_Baby = false ) override ; // tolua_export
2015-03-21 10:18:17 -04:00
UInt32 SpawnMobFinalize ( cMonster * a_Monster ) ;
2016-02-05 16:45:45 -05:00
2015-03-21 10:18:17 -04:00
/** Creates a projectile of the specified type. Returns the projectile's UniqueID if successful, cEntity::INVALID_ID otherwise
Item parameter is currently used for Fireworks to correctly set entity metadata based on item metadata . */
UInt32 CreateProjectile ( double a_PosX , double a_PosY , double a_PosZ , cProjectileEntity : : eKind a_Kind , cEntity * a_Creator , const cItem * a_Item , const Vector3d * a_Speed = nullptr ) ; // tolua_export
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */
2015-05-24 07:56:56 -04:00
int GetTickRandomNumber ( int a_Range ) { return static_cast < int > ( m_TickRand . randInt ( a_Range ) ) ; }
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Appends all usernames starting with a_Text (case-insensitive) into Results */
2013-11-13 08:50:47 -05:00
void TabCompleteUserName ( const AString & a_Text , AStringVector & a_Results ) ;
2014-01-19 17:49:19 -05:00
/** Get the current darkness level based on the time */
2013-11-13 08:50:47 -05:00
NIBBLETYPE GetSkyDarkness ( ) { return m_SkyDarkness ; }
2016-02-05 16:45:45 -05:00
2014-07-10 12:18:32 -04:00
/** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk.
If the m_AlwaysTicked counter is greater than zero , the chunk is ticked in the tick - thread regardless of
whether it has any clients or not .
This function allows nesting and task - concurrency ( multiple separate tasks can request ticking and as long
as at least one requests is active the chunk will be ticked ) . */
void SetChunkAlwaysTicked ( int a_ChunkX , int a_ChunkZ , bool a_AlwaysTicked = true ) ; // tolua_export
2015-03-21 13:17:26 -04:00
cBroadcaster GetBroadcaster ( ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
private :
friend class cRoot ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
class cTickThread :
public cIsThread
{
typedef cIsThread super ;
public :
cTickThread ( cWorld & a_World ) ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
protected :
cWorld & m_World ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
// cIsThread overrides:
virtual void Execute ( void ) override ;
} ;
2016-02-05 16:45:45 -05:00
2014-01-10 16:22:54 -05:00
/** Implementation of the callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
class cChunkGeneratorCallbacks :
public cChunkGenerator : : cChunkSink ,
public cChunkGenerator : : cPluginInterface
{
cWorld * m_World ;
2016-02-05 16:45:45 -05:00
2014-01-10 16:22:54 -05:00
// cChunkSink overrides:
virtual void OnChunkGenerated ( cChunkDesc & a_ChunkDesc ) override ;
virtual bool IsChunkValid ( int a_ChunkX , int a_ChunkZ ) override ;
virtual bool HasChunkAnyClients ( int a_ChunkX , int a_ChunkZ ) override ;
2014-09-05 16:16:48 -04:00
virtual bool IsChunkQueued ( int a_ChunkX , int a_ChunkZ ) override ;
2016-02-05 16:45:45 -05:00
2014-01-10 16:22:54 -05:00
// cPluginInterface overrides:
virtual void CallHookChunkGenerating ( cChunkDesc & a_ChunkDesc ) override ;
virtual void CallHookChunkGenerated ( cChunkDesc & a_ChunkDesc ) override ;
2016-02-05 16:45:45 -05:00
2014-01-10 16:22:54 -05:00
public :
cChunkGeneratorCallbacks ( cWorld & a_World ) ;
} ;
2014-01-19 17:49:19 -05:00
2016-09-03 11:38:29 -04:00
/** The maximum number of allowed unused dirty chunks for this world.
Loaded from config , enforced every 10 seconds by freeing some unused dirty chunks
if this was exceeded . */
size_t m_UnusedDirtyChunksCap ;
2013-11-13 08:50:47 -05:00
AString m_WorldName ;
2014-06-10 15:43:27 -04:00
2015-03-21 10:20:31 -04:00
/** The name of the overworld that portals in this world should link to.
Only has effect if this world is a Nether or End world . */
AString m_LinkedOverworldName ;
2014-06-10 15:43:27 -04:00
2013-11-13 08:50:47 -05:00
AString m_IniFileName ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Name of the storage schema used to load and save chunks */
2013-11-13 08:50:47 -05:00
AString m_StorageSchema ;
2016-02-05 16:45:45 -05:00
2014-01-17 14:01:14 -05:00
int m_StorageCompressionFactor ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** The dimension of the world, used by the client to provide correct lighting scheme */
2013-11-13 08:50:47 -05:00
eDimension m_Dimension ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** This random generator is to be used only in the Tick() method, and thus only in the World-Tick-thread (MTRand is not exactly thread-safe) */
2013-11-13 08:50:47 -05:00
MTRand m_TickRand ;
2013-12-20 13:10:07 -05:00
bool m_IsSpawnExplicitlySet ;
2013-11-13 08:50:47 -05:00
double m_SpawnX ;
double m_SpawnY ;
double m_SpawnZ ;
2015-06-13 08:57:51 -04:00
// Variables defining the minimum and maximum size for a nether portal
int m_MinNetherPortalWidth ;
int m_MaxNetherPortalWidth ;
int m_MinNetherPortalHeight ;
int m_MaxNetherPortalHeight ;
2014-07-26 18:39:39 -04:00
bool m_BroadcastDeathMessages ;
bool m_BroadcastAchievementMessages ;
2015-01-11 16:53:20 -05:00
bool m_IsDaylightCycleEnabled ;
2017-01-19 16:45:23 -05:00
/** The age of the world.
Monotonic , always increasing each game tick , persistent across server restart . */
std : : chrono : : milliseconds m_WorldAge ;
2015-01-11 16:12:26 -05:00
std : : chrono : : milliseconds m_TimeOfDay ;
cTickTimeLong m_LastTimeUpdate ; // The tick in which the last time update has been sent.
2016-09-03 11:38:29 -04:00
cTickTimeLong m_LastChunkCheck ; // The last WorldAge (in ticks) in which unloading and possibly saving was triggered
2015-01-11 16:12:26 -05:00
cTickTimeLong m_LastSave ; // The last WorldAge (in ticks) in which save-all was triggerred
std : : map < cMonster : : eFamily , cTickTimeLong > m_LastSpawnMonster ; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
2013-11-13 08:50:47 -05:00
NIBBLETYPE m_SkyDarkness ;
eGameMode m_GameMode ;
bool m_bEnabledPVP ;
bool m_IsDeepSnowEnabled ;
2013-12-04 13:48:42 -05:00
bool m_ShouldLavaSpawnFire ;
2014-01-27 16:02:19 -05:00
bool m_VillagersShouldHarvestCrops ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
std : : vector < BlockTickQueueItem * > m_BlockTickQueue ;
2014-07-17 16:15:34 -04:00
std : : vector < BlockTickQueueItem * > m_BlockTickQueueCopy ; // Second is for safely removing the objects from the queue
2013-11-13 08:50:47 -05:00
2014-10-12 07:44:59 -04:00
std : : unique_ptr < cSimulatorManager > m_SimulatorManager ;
std : : unique_ptr < cSandSimulator > m_SandSimulator ;
cFluidSimulator * m_WaterSimulator ;
cFluidSimulator * m_LavaSimulator ;
std : : unique_ptr < cFireSimulator > m_FireSimulator ;
2014-10-25 16:54:00 -04:00
cRedstoneSimulator * m_RedstoneSimulator ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
cCriticalSection m_CSPlayers ;
cPlayerList m_Players ;
cWorldStorage m_Storage ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
unsigned int m_MaxPlayers ;
2014-10-10 10:33:19 -04:00
std : : unique_ptr < cChunkMap > m_ChunkMap ;
2013-11-13 08:50:47 -05:00
bool m_bAnimals ;
2014-09-17 13:40:10 -04:00
std : : set < eMonsterType > m_AllowedMobs ;
2013-11-13 08:50:47 -05:00
eWeather m_Weather ;
int m_WeatherInterval ;
2015-09-27 19:02:17 -04:00
int m_MaxSunnyTicks , m_MinSunnyTicks ;
int m_MaxRainTicks , m_MinRainTicks ;
int m_MaxThunderStormTicks , m_MinThunderStormTicks ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
int m_MaxCactusHeight ;
int m_MaxSugarcaneHeight ;
2017-02-14 05:13:55 -05:00
bool m_IsBeetrootsBonemealable ;
2013-11-13 08:50:47 -05:00
bool m_IsCactusBonemealable ;
bool m_IsCarrotsBonemealable ;
bool m_IsCropsBonemealable ;
bool m_IsGrassBonemealable ;
bool m_IsMelonStemBonemealable ;
bool m_IsMelonBonemealable ;
bool m_IsPotatoesBonemealable ;
bool m_IsPumpkinStemBonemealable ;
bool m_IsPumpkinBonemealable ;
bool m_IsSaplingBonemealable ;
bool m_IsSugarcaneBonemealable ;
2016-05-29 16:10:35 -04:00
bool m_IsBigFlowerBonemealable ;
bool m_IsTallGrassBonemealable ;
2013-11-13 08:50:47 -05:00
2014-02-07 13:58:52 -05:00
/** Whether command blocks are enabled or not */
2014-01-23 07:57:04 -05:00
bool m_bCommandBlocksEnabled ;
2016-02-05 16:45:45 -05:00
2014-02-07 13:58:52 -05:00
/** Whether prefixes such as [INFO] are prepended to SendMessageXXX() / BroadcastChatXXX() functions */
bool m_bUseChatPrefixes ;
2014-03-10 14:35:02 -04:00
2014-03-18 16:45:10 -04:00
/** The level of DoExplosionAt() projecting random affected blocks as FallingBlock entities
2014-03-19 19:06:39 -04:00
See the eShrapnelLevel enumeration for details
2014-03-18 16:45:10 -04:00
*/
2014-03-19 19:06:39 -04:00
eShrapnelLevel m_TNTShrapnelLevel ;
2014-06-04 15:00:55 -04:00
2014-10-30 16:38:32 -04:00
/** The maximum view distance that a player can have in this world. */
2014-10-30 16:24:10 -04:00
int m_MaxViewDistance ;
2015-03-21 10:20:31 -04:00
/** Name of the nether world - where Nether portals should teleport.
Only used when this world is an Overworld . */
AString m_LinkedNetherWorldName ;
2014-06-04 15:00:55 -04:00
2015-03-21 10:20:31 -04:00
/** Name of the End world - where End portals should teleport.
Only used when this world is an Overworld . */
AString m_LinkedEndWorldName ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
cChunkGenerator m_Generator ;
2014-01-19 07:20:57 -05:00
cScoreboard m_Scoreboard ;
2014-02-23 08:03:40 -05:00
cMapManager m_MapManager ;
2016-02-05 16:45:45 -05:00
2014-01-10 16:22:54 -05:00
/** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
cChunkGeneratorCallbacks m_GeneratorCallbacks ;
2016-02-05 16:45:45 -05:00
2013-11-13 08:50:47 -05:00
cChunkSender m_ChunkSender ;
cLightingThread m_Lighting ;
cTickThread m_TickThread ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Guards the m_Tasks */
2013-11-13 08:50:47 -05:00
cCriticalSection m_CSTasks ;
2016-02-05 16:45:45 -05:00
2015-09-25 13:56:49 -04:00
/** Tasks that have been queued onto the tick thread, possibly to be executed at target tick in the future; guarded by m_CSTasks */
std : : vector < std : : pair < Int64 , std : : function < void ( cWorld & ) > > > m_Tasks ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Guards m_Clients */
2013-11-13 08:50:47 -05:00
cCriticalSection m_CSClients ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** List of clients in this world, these will be ticked by this world */
2015-01-24 14:17:00 -05:00
cClientHandlePtrs m_Clients ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Clients that are scheduled for removal (ticked in another world), waiting for TickClients() to remove them */
2015-01-24 14:17:00 -05:00
cClientHandles m_ClientsToRemove ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Clients that are scheduled for adding, waiting for TickClients to add them */
2015-01-24 14:17:00 -05:00
cClientHandlePtrs m_ClientsToAdd ;
2013-11-13 08:50:47 -05:00
2014-06-06 16:31:16 -04:00
/** Guards m_EntitiesToAdd */
cCriticalSection m_CSEntitiesToAdd ;
/** List of entities that are scheduled for adding, waiting for the Tick thread to add them. */
cEntityList m_EntitiesToAdd ;
2014-06-08 15:58:08 -04:00
/** Guards m_PlayersToAdd */
cCriticalSection m_CSPlayersToAdd ;
/** List of players that are scheduled for adding, waiting for the Tick thread to add them. */
2016-08-22 13:43:43 -04:00
cAwaitingPlayerList m_PlayersToAdd ;
2016-02-05 16:45:45 -05:00
2014-07-24 12:32:05 -04:00
/** CS protecting m_SetChunkDataQueue. */
cCriticalSection m_CSSetChunkDataQueue ;
2016-02-05 16:45:45 -05:00
2014-07-24 12:32:05 -04:00
/** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */
cSetChunkDataPtrs m_SetChunkDataQueue ;
2014-06-08 15:58:08 -04:00
2013-11-13 08:50:47 -05:00
2015-03-21 10:20:31 -04:00
cWorld ( const AString & a_WorldName , eDimension a_Dimension = dimOverworld , const AString & a_LinkedOverworldName = " " ) ;
2014-02-11 05:56:29 -05:00
virtual ~ cWorld ( ) ;
2013-11-13 08:50:47 -05:00
2015-01-11 16:12:26 -05:00
void Tick ( std : : chrono : : milliseconds a_Dt , std : : chrono : : milliseconds a_LastTickDurationMSec ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Handles the weather in each tick */
2013-11-13 08:50:47 -05:00
void TickWeather ( float a_Dt ) ;
2016-02-05 16:45:45 -05:00
2015-05-09 03:25:09 -04:00
/** Handles the mob spawning / moving / destroying each tick */
2015-01-11 16:12:26 -05:00
void TickMobs ( std : : chrono : : milliseconds a_Dt ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Executes all tasks queued onto the tick thread */
2013-11-13 08:50:47 -05:00
void TickQueuedTasks ( void ) ;
2016-02-05 16:45:45 -05:00
2014-01-19 17:49:19 -05:00
/** Ticks all clients that are in this world */
2013-11-13 08:50:47 -05:00
void TickClients ( float a_Dt ) ;
2015-07-31 10:49:10 -04:00
/** Unloads all chunks immediately. */
2014-02-11 14:38:28 -05:00
void UnloadUnusedChunks ( void ) ;
2013-11-26 16:54:40 -05:00
void UpdateSkyDarkness ( void ) ;
2015-07-31 10:49:10 -04:00
/** Generates a random spawnpoint on solid land by walking chunks and finding their biomes */
2015-11-13 10:08:16 -05:00
void GenerateRandomSpawn ( int a_MaxSpawnRadius ) ;
/** Can the specified coordinates be used as a spawn point?
Returns true if spawn position is valid and sets a_Y to the valid spawn height */
bool CanSpawnAt ( double a_X , double & a_Y , double a_Z ) ;
2014-04-25 19:55:38 -04:00
2015-07-31 10:49:10 -04:00
/** Check if player starting point is acceptable */
2015-03-12 14:37:39 -04:00
bool CheckPlayerSpawnPoint ( int a_PosX , int a_PosY , int a_PosZ ) ;
2015-07-31 10:49:10 -04:00
/** Chooses a reasonable transition from the current weather to a new weather */
2014-04-25 19:55:38 -04:00
eWeather ChooseNewWeather ( void ) ;
2014-01-19 17:49:19 -05:00
/** Creates a new fluid simulator, loads its settings from the inifile (a_FluidName section) */
2013-11-13 08:50:47 -05:00
cFluidSimulator * InitializeFluidSimulator ( cIniFile & a_IniFile , const char * a_FluidName , BLOCKTYPE a_SimulateBlock , BLOCKTYPE a_StationaryBlock ) ;
2014-02-07 16:13:55 -05:00
2015-07-31 10:49:10 -04:00
/** Creates a new redstone simulator. */
2014-10-25 16:54:00 -04:00
cRedstoneSimulator * InitializeRedstoneSimulator ( cIniFile & a_IniFile ) ;
2014-06-08 15:58:08 -04:00
/** Adds the players queued in the m_PlayersToAdd queue into the m_Players list.
Assumes it is called from the Tick thread . */
void AddQueuedPlayers ( void ) ;
2014-07-21 17:49:06 -04:00
/** Sets generator values to dimension specific defaults, if those values do not exist */
void InitialiseGeneratorDefaults ( cIniFile & a_IniFile ) ;
/** Sets mob spawning values if nonexistant to their dimension specific defaults */
void InitialiseAndLoadMobSpawningValues ( cIniFile & a_IniFile ) ;
2014-07-24 12:32:05 -04:00
/** Sets the specified chunk data into the chunkmap. Called in the tick thread.
Modifies the a_SetChunkData - moves the entities contained in it into the chunk . */
void SetChunkData ( cSetChunkData & a_SetChunkData ) ;
2014-07-29 10:27:19 -04:00
2014-07-17 13:13:23 -04:00
} ; // tolua_export
2014-10-20 16:55:07 -04:00