6 #include "../Defines.h" 7 #include "../Entities/FallingBlock.h" 9 #include "../IniFile.h" 10 #include "../EffectID.h" 30 if (ChunkData.empty())
37 for (cSandSimulatorChunkData::const_iterator itr = ChunkData.begin(), end = ChunkData.end(); itr != end; ++itr)
54 Pos.
x = itr->x + BaseX;
56 Pos.
z = itr->z + BaseZ;
64 auto FallingBlock = cpp14::make_unique<cFallingBlock>(Pos, BlockType, a_Chunk->
GetMeta(itr->x, itr->y, itr->z));
65 auto FallingBlockPtr = FallingBlock.get();
66 if (!FallingBlockPtr->Initialize(std::move(FallingBlock),
m_World))
106 if ((a_Chunk ==
nullptr) || !a_Chunk->
IsValid())
119 for (cSandSimulatorChunkData::iterator itr = ChunkData.begin(); itr != ChunkData.end(); ++itr)
121 if ((itr->x == RelX) && (itr->y == a_Block.
y) && (itr->z == RelZ))
255 return ((a_BlockMeta & 0x08) == 0);
266 cWorld * a_World,
int a_BlockX,
int a_BlockY,
int a_BlockZ,
276 a_World->
SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FallingBlockType, a_FallingBlockMeta);
286 Pickups.
Add(static_cast<ENUM_ITEM_ID>(a_FallingBlockType), 1, a_FallingBlockMeta);
289 static_cast<double>(a_BlockX) + 0.5,
290 static_cast<double>(a_BlockY) + 0.5,
291 static_cast<double>(a_BlockZ) + 0.5
304 a_Chunk->
GetBlockTypeMeta(a_RelX, a_RelY, a_RelZ, FallingBlockType, FallingBlockMeta);
308 for (
int y = a_RelY - 1; y >= 0; y--)
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
BLOCKTYPE GetBlock(Vector3i a_BlockPos)
Returns the block type at the specified position.
static bool IsReplacedOnRematerialization(BLOCKTYPE a_BlockType)
Returns true if the falling block rematerializing will replace the specified block type (e...
bool IsBlockWater(BLOCKTYPE a_BlockType)
static void FinishFalling(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_FallingBlockType, NIBBLETYPE a_FallingBlockMeta)
Called when a block finishes falling at the specified coords, either by insta-fall, or through cFallingBlock entity.
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
unsigned char BLOCKTYPE
The datatype used by blockdata.
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
cSandSimulatorChunkData & GetSandSimulatorData(void)
virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk *a_Chunk) override
Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct acce...
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.
Base class for all block-based physics simulators (such as fluid, fire, falling blocks etc...
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
void Add(const cItem &a_Item)
cSandSimulator(cWorld &a_World, cIniFile &a_IniFile)
cCoordWithIntList cSandSimulatorChunkData
Per-chunk data for the simulator, specified individual chunks to simulate; Data is not used...
static bool CanStartFallingThrough(BLOCKTYPE a_BlockType)
Returns true if a falling-able block can start falling through the specified block type...
static bool CanContinueFallThrough(BLOCKTYPE a_BlockType)
Returns true if an already-falling block can pass through the specified block type (e...
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override
Returns true if the specified block type is "interesting" for this simulator.
virtual void AddBlock(Vector3i a_Block, cChunk *a_Chunk) override
Called to simulate a new block.
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
void DoInstantFall(cChunk *a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
Performs the instant fall of the block - removes it from top, Finishes it at the bottom.
bool GetValueSetB(const AString &keyname, const AString &valuename, const bool defValue=false) override
static bool DoesBreakFallingThrough(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Returns true if the specified block breaks falling blocks while they fall through it (e...
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
cCoordWithData< int > cCoordWithInt
This class bridges a vector of cItem for safe access via Lua.