Cuberite
A lightweight, fast and extensible game server for Minecraft
SandSimulator.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Simulator.h"
5 #include "../IniFile.h"
6 
7 
8 
9 
10 
11 // fwd:
12 class cChunk;
13 
14 
15 
16 
17 
20 
21 
22 
23 
24 
27  public cSimulator
28 {
29 public:
30 
31  cSandSimulator(cWorld & a_World, cIniFile & a_IniFile);
32 
34  static bool CanStartFallingThrough(BLOCKTYPE a_BlockType);
35 
37  static bool CanContinueFallThrough(BLOCKTYPE a_BlockType);
38 
40  static bool IsReplacedOnRematerialization(BLOCKTYPE a_BlockType);
41 
43  static bool DoesBreakFallingThrough(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
44 
49  static void FinishFalling(
50  cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ,
51  BLOCKTYPE a_FallingBlockType, NIBBLETYPE a_FallingBlockMeta
52  );
53 
54  static bool IsAllowedBlock(BLOCKTYPE a_BlockType);
55 
56 private:
57 
58  virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
59 
60  bool m_IsInstantFall; // If set to true, blocks don't fall using cFallingBlock entity, but instantly instead
61 
62  int m_TotalBlocks; // Total number of blocks currently in the queue for simulating
63 
64  virtual void AddBlock(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) override;
65 
67  void DoInstantFall(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
68 };
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
std::list< cCoordWithInt > cCoordWithIntList
Definition: ChunkDef.h:502
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
cCoordWithIntList cSandSimulatorChunkData
Per-chunk data for the simulator, specified individual chunks to simulate; Data is not used.
Definition: SandSimulator.h:12
Definition: Chunk.h:36
Despite the class name, this simulator takes care of all blocks that fall when suspended in the air.
Definition: SandSimulator.h:28
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....
Definition: Simulator.h:22
Definition: World.h:53