Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
cSandSimulator Class Reference

Despite the class name, this simulator takes care of all blocks that fall when suspended in the air. More...

#include <SandSimulator.h>

Inheritance diagram for cSandSimulator:
Inheritance graph
[legend]
Collaboration diagram for cSandSimulator:
Collaboration graph
[legend]

Public Member Functions

 cSandSimulator (cWorld &a_World, cIniFile &a_IniFile)
 
- Public Member Functions inherited from cSimulator
 cSimulator (cWorld &a_World)
 
virtual ~cSimulator ()
 

Static Public Member Functions

static bool CanContinueFallThrough (BLOCKTYPE a_BlockType)
 Returns true if an already-falling block can pass through the specified block type (e. More...
 
static bool CanStartFallingThrough (BLOCKTYPE a_BlockType)
 Returns true if a falling-able block can start falling through the specified block type. More...
 
static bool DoesBreakFallingThrough (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 Returns true if the specified block breaks falling blocks while they fall through it (e. More...
 
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. More...
 
static bool IsAllowedBlock (BLOCKTYPE a_BlockType)
 
static bool IsReplacedOnRematerialization (BLOCKTYPE a_BlockType)
 Returns true if the falling block rematerializing will replace the specified block type (e. More...
 
- Static Public Member Functions inherited from cSimulator
static std::array< Vector3i, 5 > GetLinkedOffsets (Vector3i Offset)
 For a given offset from a position, return the offsets that represent the adjacents of the newly offset position, excluding the old position. More...
 

Private Member Functions

virtual void AddBlock (cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) override
 Called to simulate a new block. More...
 
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. More...
 
virtual void SimulateChunk (std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk *a_Chunk) override
 

Private Attributes

bool m_IsInstantFall
 
int m_TotalBlocks
 

Additional Inherited Members

- Static Public Attributes inherited from cSimulator
static constexpr std::array< Vector3i, 6 > AdjacentOffsets
 Contains offsets for direct adjacents of any position. More...
 
- Protected Member Functions inherited from cSimulator
virtual void Simulate (float a_Dt)
 
virtual void WakeUp (cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
 Called to simulate a single new block, typically as a result of a single block break or change. More...
 
virtual void WakeUp (cChunk &a_Chunk, Vector3i a_Position, Vector3i a_Offset, BLOCKTYPE a_Block)
 Called to simulate a single block, synthesised by the simulator manager. More...
 
- Protected Attributes inherited from cSimulator
cWorldm_World
 

Detailed Description

Despite the class name, this simulator takes care of all blocks that fall when suspended in the air.

Definition at line 26 of file SandSimulator.h.

Constructor & Destructor Documentation

◆ cSandSimulator()

cSandSimulator::cSandSimulator ( cWorld a_World,
cIniFile a_IniFile 
)

Definition at line 17 of file SandSimulator.cpp.

Member Function Documentation

◆ AddBlock()

void cSandSimulator::AddBlock ( cChunk a_Chunk,
Vector3i  a_Position,
BLOCKTYPE  a_Block 
)
overrideprivatevirtual

Called to simulate a new block.

Unlike WakeUp this function will perform minimal checking. It queues the block to be simulated as fast as possible, suitable for area wakeups.

Implements cSimulator.

Definition at line 77 of file SandSimulator.cpp.

◆ CanContinueFallThrough()

bool cSandSimulator::CanContinueFallThrough ( BLOCKTYPE  a_BlockType)
static

Returns true if an already-falling block can pass through the specified block type (e.

g. torch)

Definition at line 125 of file SandSimulator.cpp.

◆ CanStartFallingThrough()

bool cSandSimulator::CanStartFallingThrough ( BLOCKTYPE  a_BlockType)
static

Returns true if a falling-able block can start falling through the specified block type.

Definition at line 102 of file SandSimulator.cpp.

◆ DoesBreakFallingThrough()

bool cSandSimulator::DoesBreakFallingThrough ( BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)
static

Returns true if the specified block breaks falling blocks while they fall through it (e.

g. halfslabs)

Definition at line 213 of file SandSimulator.cpp.

◆ DoInstantFall()

void cSandSimulator::DoInstantFall ( cChunk a_Chunk,
int  a_RelX,
int  a_RelY,
int  a_RelZ 
)
private

Performs the instant fall of the block - removes it from top, Finishes it at the bottom.

Definition at line 289 of file SandSimulator.cpp.

◆ FinishFalling()

void cSandSimulator::FinishFalling ( cWorld a_World,
int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
BLOCKTYPE  a_FallingBlockType,
NIBBLETYPE  a_FallingBlockMeta 
)
static

Called when a block finishes falling at the specified coords, either by insta-fall, or through cFallingBlock entity.

It either rematerializes the block (a_FallingBlockType) at the specified coords, or creates a pickup, based on the block currently present in the world at the dest specified coords.

Definition at line 232 of file SandSimulator.cpp.

◆ IsAllowedBlock()

bool cSandSimulator::IsAllowedBlock ( BLOCKTYPE  a_BlockType)
static

Definition at line 266 of file SandSimulator.cpp.

◆ IsReplacedOnRematerialization()

bool cSandSimulator::IsReplacedOnRematerialization ( BLOCKTYPE  a_BlockType)
static

Returns true if the falling block rematerializing will replace the specified block type (e.

g. tall grass)

Definition at line 185 of file SandSimulator.cpp.

◆ SimulateChunk()

void cSandSimulator::SimulateChunk ( std::chrono::milliseconds  a_Dt,
int  a_ChunkX,
int  a_ChunkZ,
cChunk a_Chunk 
)
overrideprivatevirtual

Implements cSimulator.

Definition at line 28 of file SandSimulator.cpp.

Member Data Documentation

◆ m_IsInstantFall

bool cSandSimulator::m_IsInstantFall
private

Definition at line 60 of file SandSimulator.h.

◆ m_TotalBlocks

int cSandSimulator::m_TotalBlocks
private

Definition at line 62 of file SandSimulator.h.


The documentation for this class was generated from the following files: