5 #include "../BlockInfo.h"
7 #include "../Defines.h"
8 #include "../Entities/FallingBlock.h"
10 #include "../IniFile.h"
11 #include "../EffectID.h"
31 if (ChunkData.empty())
38 for (cSandSimulatorChunkData::const_iterator itr = ChunkData.begin(), end = ChunkData.end(); itr != end; ++itr)
55 Pos.
x = itr->x + BaseX;
57 Pos.
z = itr->z + BaseZ;
86 for (cSandSimulatorChunkData::iterator itr = ChunkData.begin(); itr != ChunkData.end(); ++itr)
88 if ((itr->x == a_Position.
x) && (itr->y == a_Position.
y) && (itr->z == a_Position.
z))
95 ChunkData.emplace_back(a_Position.
x, a_Position.
y, a_Position.
z);
222 return ((a_BlockMeta & 0x08) == 0);
233 cWorld * a_World,
int a_BlockX,
int a_BlockY,
int a_BlockZ,
239 BLOCKTYPE CurrentBlockType = a_World->
GetBlock({ a_BlockX, a_BlockY, a_BlockZ });
243 a_World->
SetBlock({ a_BlockX, a_BlockY, a_BlockZ }, a_FallingBlockType, a_FallingBlockMeta);
253 Pickups.
Add(
static_cast<ENUM_ITEM_TYPE>(a_FallingBlockType), 1, a_FallingBlockMeta);
256 static_cast<double>(a_BlockX) + 0.5,
257 static_cast<double>(a_BlockY) + 0.5,
258 static_cast<double>(a_BlockZ) + 0.5
294 a_Chunk->
GetBlockTypeMeta(a_RelX, a_RelY, a_RelZ, FallingBlockType, FallingBlockMeta);
298 for (
int y = a_RelY - 1; y >= 0; y--)
bool IsBlockWater(BLOCKTYPE a_BlockType)
@ E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE
@ E_BLOCK_REDSTONE_TORCH_ON
@ E_BLOCK_STONE_PRESSURE_PLATE
@ E_BLOCK_STANDING_BANNER
@ E_BLOCK_REDSTONE_REPEATER_ON
@ E_BLOCK_STATIONARY_LAVA
@ E_BLOCK_MINECART_TRACKS
@ E_BLOCK_CONCRETE_POWDER
@ E_BLOCK_WOODEN_PRESSURE_PLATE
@ E_BLOCK_REDSTONE_TORCH_OFF
@ E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE
@ E_BLOCK_REDSTONE_REPEATER_OFF
@ E_BLOCK_STATIONARY_WATER
@ E_BLOCK_RED_SANDSTONE_SLAB
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
cCoordWithIntList cSandSimulatorChunkData
Per-chunk data for the simulator, specified individual chunks to simulate; Data is not used.
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
cSandSimulatorChunkData & GetSandSimulatorData(void)
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
bool GetValueSetB(const AString &keyname, const AString &valuename, const bool defValue=false) override
This class bridges a vector of cItem for safe access via Lua.
void Add(const cItem &a_Item)
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.
virtual void AddBlock(cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) override
Called to simulate a new block.
static bool IsReplacedOnRematerialization(BLOCKTYPE a_BlockType)
Returns true if the falling block rematerializing will replace the specified block type (e.
static bool CanContinueFallThrough(BLOCKTYPE a_BlockType)
Returns true if an already-falling block can pass through the specified block type (e.
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,...
static bool IsAllowedBlock(BLOCKTYPE a_BlockType)
static bool CanStartFallingThrough(BLOCKTYPE a_BlockType)
Returns true if a falling-able block can start falling through the specified block type.
cSandSimulator(cWorld &a_World, cIniFile &a_IniFile)
static bool DoesBreakFallingThrough(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Returns true if the specified block breaks falling blocks while they fall through it (e.
virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk *a_Chunk) override
Base class for all block-based physics simulators (such as fluid, fire, falling blocks etc....
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
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.
UInt32 SpawnFallingBlock(Vector3d a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Spawns an falling block entity at the given position.
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.