Cuberite
A lightweight, fast and extensible game server for Minecraft
VaporizeFluidSimulator.cpp
Go to the documentation of this file.
1 
2 // VaporizeFluidSimulator.cpp
3 
4 // Implements the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
5 
6 #include "Globals.h"
8 #include "../OpaqueWorld.h"
9 #include "../Chunk.h"
10 #include "../Blocks/BroadcastInterface.h"
11 
12 
13 
14 
15 
17  super(a_World, a_Fluid, a_StationaryFluid)
18 {
19 }
20 
21 
22 
23 
24 
26 {
27  if (a_Chunk == nullptr)
28  {
29  return;
30  }
31  auto relPos = cChunkDef::AbsoluteToRelative(a_Block);
32  auto blockType = a_Chunk->GetBlock(relPos);
33  if (
34  (blockType == m_FluidBlock) ||
35  (blockType == m_StationaryFluidBlock)
36  )
37  {
38  a_Chunk->SetBlock(relPos, E_BLOCK_AIR, 0);
40  "block.fire.extinguish",
41  Vector3d(a_Block),
42  1.0f,
43  0.6f
44  );
45  }
46 }
47 
48 
49 
50 
51 
53 {
54  // Nothing needed
55 }
56 
57 
58 
59 
cVaporizeFluidSimulator(cWorld &a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid)
cBroadcastInterface * GetBroadcastInterface(cWorld *a_World)
Definition: World.cpp:74
BLOCKTYPE m_FluidBlock
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
virtual void Simulate(float a_Dt) override
Called in each tick, a_Dt is the time passed since the last tick, in msec.
BLOCKTYPE m_StationaryFluidBlock
virtual void AddBlock(Vector3i a_Block, cChunk *a_Chunk) override
Called to simulate a new block.
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Definition: Chunk.cpp:1313
Definition: Chunk.h:49
cWorld & m_World
Definition: Simulator.h:60
Base class for all block-based physics simulators (such as fluid, fire, falling blocks etc...
Definition: Simulator.h:19
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr)=0
Definition: World.h:65
Vector3< double > Vector3d
Definition: Vector3.h:445
static void AbsoluteToRelative(int &a_X, int &a_Y, int &a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords into relative (chunk + block) coords:
Definition: ChunkDef.h:163
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:177