diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-14 20:30:16 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-14 20:30:16 +0200 |
commit | 41a38e8d9098d6627cd26351577cf032e6996c87 (patch) | |
tree | 34d53e6291c6d353a9c3a37a472b933f9fa5e57d /source/Blocks | |
parent | Initial Floody fluid simulator. (diff) | |
download | cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.gz cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.bz2 cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.lz cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.xz cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.tar.zst cuberite-41a38e8d9098d6627cd26351577cf032e6996c87.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Blocks/BlockFluid.h | 21 | ||||
-rw-r--r-- | source/Blocks/BlockHandler.cpp | 22 | ||||
-rw-r--r-- | source/Blocks/BlockHandler.h | 6 |
3 files changed, 48 insertions, 1 deletions
diff --git a/source/Blocks/BlockFluid.h b/source/Blocks/BlockFluid.h index 40ff621e4..a8cd9c497 100644 --- a/source/Blocks/BlockFluid.h +++ b/source/Blocks/BlockFluid.h @@ -10,6 +10,8 @@ class cBlockFluidHandler :
public cBlockHandler
{
+ typedef cBlockHandler super;
+
public:
cBlockFluidHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
@@ -23,7 +25,24 @@ public: return true;
}
- // TODO: Implement proper fluid physics here
+
+ virtual void Check(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ switch (m_BlockType)
+ {
+ case E_BLOCK_STATIONARY_LAVA:
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LAVA, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ));
+ break;
+ }
+ case E_BLOCK_STATIONARY_WATER:
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ));
+ break;
+ }
+ }
+ super::Check(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ }
} ;
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 977bff87f..eb7a40d62 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -387,3 +387,25 @@ bool cBlockHandler::DoesDropOnUnsuitable(void) +
+void cBlockHandler::Check(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ if (!CanBeAt(a_World, a_BlockX, a_BlockY, a_BlockZ))
+ {
+ if (DoesDropOnUnsuitable())
+ {
+ DropBlock(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ }
+
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ }
+ else
+ {
+ // Wake up the simulators:
+ a_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ);
+ }
+}
+
+
+
+
diff --git a/source/Blocks/BlockHandler.h b/source/Blocks/BlockHandler.h index bfe92b676..c2884fe7d 100644 --- a/source/Blocks/BlockHandler.h +++ b/source/Blocks/BlockHandler.h @@ -91,6 +91,12 @@ public: /// Does this block drop if it gets destroyed by an unsuitable situation? Default: true
virtual bool DoesDropOnUnsuitable(void);
+ /** Called when one of the neighbors gets set; equivalent to MC block update.
+ By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()),
+ and wakes up all simulators on the block.
+ */
+ virtual void Check(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
+
/// Get the blockhandler for a specific block id
static cBlockHandler * GetBlockHandler(BLOCKTYPE a_BlockType);
|